@@ -4,14 +4,12 @@ Using Geospatial Data
4
4
5
5
.. default-domain:: mongodb
6
6
7
- MongoDB supports location-based applications using geospatial
8
- coordinate with rich location aware queries that return documents
9
- based on location, and a special geospatial index type to support
10
- these queries. This document introduces geospatial data modeling,
11
- indexing operations, and queries using the special :ref:`geospatial
12
- query operators <geospatial-query-operators>`. For more information about
13
- the geospatial indexes and its operations see :doc:`Geospatial Indexes
14
- </core/geospatial-indexes>`.
7
+ MongoDB provides rich location aware queries that return documents
8
+ based on location with a special geospatial index type. This document
9
+ introduces geospatial data modeling, indexing operations, and provides
10
+ example queries using the :ref:`geospatial query operators
11
+ <geospatial-query-operators>`. For more information about the
12
+ geospatial indexes and operations see the :doc:`/applications/geospatial-indexes`.
15
13
16
14
.. _geospatial-coordinates:
17
15
47
45
~~~~~
48
46
49
47
You can use the :func:`find() <db.collection.find()>` method to query
50
- directly for an exact match on a location. These queries take the
48
+ for an exact match on a location. These queries take the
51
49
following prototypical form:
52
50
53
51
.. code-block:: javascript
@@ -63,7 +61,7 @@ field that are exactly ``[ 42, 42 ]``, consider the following example:
63
61
64
62
db.places.find( { "loc": [ 42, 42 ] } )
65
63
66
- Exact geospatial queries are only useful in a limited selection of
64
+ Exact geospatial queries only have applicability for a limited selection of
67
65
cases, :ref:`proximity <geospatial-query-proximity>` and :ref:`bounded
68
66
<geospatial-query-bounded>` provide more useful results.
69
67
@@ -96,8 +94,8 @@ This operation will return documents from a collection named
96
94
coordinates ``[ -74, 40.74 ]``.
97
95
98
96
In addition to :operator:`near`, the :dbcommand:`geoNear` command
99
- provides equivalent geospatial query functionality, but provides
100
- additional options * and* returns additional information for each
97
+ provides equivalent functionality. :dbcommand:`geoNear` adds
98
+ additional options and returns more information for each
101
99
document found. In its most simple form, the :dbcommand:`geoNear`
102
100
command has the following prototype form:
103
101
@@ -166,25 +164,24 @@ provides the :operator:`$maxDistance` operator that you can use in
166
164
167
165
db.runCommand( { geoNear: "collection", near: [ x, y ], maxDistance: z } )
168
166
169
- The distance specified in :operator:` maxDistance` is in the same units
170
- as the coordinate system specifed . For example, if the indexed
171
- location data is in meters, the distance unit is also in meters.
167
+ Specify the distance in the `` maxDistance`` option using the same units
168
+ as the coordinate system specified . For example, if the indexed
169
+ location data is in meters, the distance units are also in meters.
172
170
173
171
.. _geospatial-within:
174
172
.. _geospatial-query-bounded:
175
173
176
174
Bounded
177
175
~~~~~~~
178
176
179
- MongoDB provides the ability to return documents using geospatial
180
- index that have coordinates located inside of a bounded shape. Bounded
181
- queries use the :operator:`$within` operator, and MongoDB does not
182
- sort the result set. Because result sets from bounded queries are not
183
- sorted, they are faster than :ref:`proximity
177
+ Bounded queries return results within the boundaries of a shape
178
+ specified in the query. The :operator:`$within` operator allows you to
179
+ construct these quires. Bounded queries do not return sorted results:
180
+ as a result these queries are faster than :ref:`proximity
184
181
<geospatial-query-proximity>` queries.
185
182
186
- The :operator:`$within` operator returns points within the following
187
- shapes:
183
+ Using the :operator:`$within`, you can specify boundaries with the
184
+ following shapes:
188
185
189
186
- circles,
190
187
- rectangles (i.e. "boxes,") or
@@ -322,7 +319,6 @@ you specify the ``{ spherical: true }`` option to the command.
322
319
The radius of the Earth is ``3963.192`` miles or ``6378.137``
323
320
kilometers.
324
321
325
-
326
322
The following query would return documents from the ``places``
327
323
collection, within the circle described by the center ``[ -74, 40.74 ]``
328
324
with a radius of ``100`` kilometers:
@@ -429,4 +425,7 @@ in the following example:
429
425
430
426
db.records.ensureIndex( { "addresses.loc": "2d" } )
431
427
428
+ .. the following is a section about the limitations of geospatial
429
+ indexes in sharding:
430
+
432
431
.. includes:: /includes/geospatial-sharding.rst
0 commit comments