Mongodb地理空间索引
1. LBS地理空间索引 关于LBS相关项目,一般存储每个地点的经纬度的坐标, 如果要查询附近的场所,则需要建立索引来提升查询效率。 Mongodb专门针对这种查询建立了地理空间索引。 2d和2dsphere索引。 2. 创建索引 建立places集合,来存放地点, loc字段用来存
1. LBS地理空间索引
关于LBS相关项目,一般存储每个地点的经纬度的坐标, 如果要查询附近的场所,则需要建立索引来提升查询效率。 Mongodb专门针对这种查询建立了地理空间索引。 2d和2dsphere索引。2. 创建索引
建立places集合,来存放地点, loc字段用来存放地区数据GeoJSON Point。db.places.insert( { loc : { type: "Point", coordinates: [ -73.97, 40.77 ] }, name: "Central Park", category : "Parks" } ) db.places.insert( { loc : { type: "Point", coordinates: [ -73.88, 40.78 ] }, name: "La Guardia Airport", category : "Airport" } )
db.places.ensureIndex( { loc : "2dsphere" } )
db.places.ensureIndex( { loc : "2dsphere" , category : -1, name: 1 } )
3. 查询
$geometry表示查询的几何图片.3.1 查询多边形范围的值
type表示类型:polygon 多边形db.places.find( { loc : { $geoWithin : { $geometry : { type : "Polygon" , coordinates : [ [ [ 0 , 0 ] , [ 3 , 6 ] , [ 6 , 1 ] , [ 0 , 0 ] ] ] } } } } )
3.2 查询附近的值
使用$near来查询附近的地点。db.places.find( { loc : { $near : { $geometry : { type : "Point" , coordinates : [ <longitude> , <latitude> ] } , $maxDistance : <distance in meters> } } } )
3.3 查询圆形内的值
查询圆时,需要指定圆心, 半径。db.places.find( { loc : { $geoWithin : { $centerSphere : [ [ -88 , 30 ] , 10 ] } } } )
地址:http://blog.csdn.net/yonggang7/article/details/28109463

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

It is recommended to use the latest version of MongoDB (currently 5.0) as it provides the latest features and improvements. When selecting a version, you need to consider functional requirements, compatibility, stability, and community support. For example, the latest version has features such as transactions and aggregation pipeline optimization. Make sure the version is compatible with the application. For production environments, choose the long-term support version. The latest version has more active community support.

Node.js is a server-side JavaScript runtime, while Vue.js is a client-side JavaScript framework for creating interactive user interfaces. Node.js is used for server-side development, such as back-end service API development and data processing, while Vue.js is used for client-side development, such as single-page applications and responsive user interfaces.

The data of the MongoDB database is stored in the specified data directory, which can be located in the local file system, network file system or cloud storage. The specific location is as follows: Local file system: The default path is Linux/macOS:/data/db, Windows: C:\data\db. Network file system: The path depends on the file system. Cloud Storage: The path is determined by the cloud storage provider.

The MongoDB database is known for its flexibility, scalability, and high performance. Its advantages include: a document data model that allows data to be stored in a flexible and unstructured way. Horizontal scalability to multiple servers via sharding. Query flexibility, supporting complex queries and aggregation operations. Data replication and fault tolerance ensure data redundancy and high availability. JSON support for easy integration with front-end applications. High performance for fast response even when processing large amounts of data. Open source, customizable and free to use.

As we all know, if the system disk occupied is too large after the system installation is completed, it may cause system lags, delays, and even file loss. Therefore, before you install the win11 system, you need to know how much C drive space is required to upgrade win11. Let’s take a look with the editor. How much C drive space is required to upgrade win11: Answer: Upgrading win11 requires 20-30GB of C drive space. 1. According to Microsoft’s win11 configuration requirements, you can see that win11 installation requires 64GB of hard drive space. 2. But in fact, generally speaking, there is no need for such a large space. 3. According to feedback from users who have already installed win11, the win11 upgrade requires about 20-30GB of C drive space. 4. But if our door only has

Swap space plays an important role in Linux systems, especially when the system is low on memory. It acts as a backup memory storage space that helps the system run smoothly and maintain stability even under high load. This article provides you with a detailed guide to adding swap space on Ubuntu 22.04LTS to ensure that your system performance is optimized and can handle various workloads. Understanding Swap Space Swap space provides virtual memory that is used to supplement the system's physical RAM. When the system is low on RAM, the kernel swaps data to disk to prevent out-of-memory and system crashes. Linux systems commonly use swap space to handle this situation. Run multiple memory-intensive applications simultaneously to process very large files or data

MongoDB is a document-oriented, distributed database system used to store and manage large amounts of structured and unstructured data. Its core concepts include document storage and distribution, and its main features include dynamic schema, indexing, aggregation, map-reduce and replication. It is widely used in content management systems, e-commerce platforms, social media websites, IoT applications, and mobile application development.

The MongoDB database file is located in the MongoDB data directory, which is /data/db by default, which contains .bson (document data), ns (collection information), journal (write operation records), wiredTiger (data when using the WiredTiger storage engine ) and config (database configuration information) and other files.
