-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
geojson.txt
206 lines (147 loc) · 4.97 KB
/
geojson.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
.. _geospatial-indexes-store-geojson:
===============
GeoJSON Objects
===============
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: twocols
Overview
--------
MongoDB supports the GeoJSON object types listed on this page.
.. include:: /includes/extracts/geojson-specification-general.rst
.. _geojson-point:
``Point``
---------
The following example specifies a GeoJSON `Point
<https://tools.ietf.org/html/rfc7946#section-3.1.2>`_:
.. code-block:: javascript
{ type: "Point", coordinates: [ 40, 5 ] }
.. _geojson-linestring:
``LineString``
--------------
The following example specifies a GeoJSON `LineString
<https://tools.ietf.org/html/rfc7946#section-3.1.4>`_:
.. code-block:: javascript
{ type: "LineString", coordinates: [ [ 40, 5 ], [ 41, 6 ] ] }
.. _geojson-polygon:
``Polygon``
-----------
`Polygons <https://tools.ietf.org/html/rfc7946#section-3.1.6>`_ consist of
an array of GeoJSON ``LinearRing`` coordinate arrays. These
``LinearRings`` are closed ``LineStrings``. Closed ``LineStrings`` have
at least four coordinate pairs and specify the same position as the
first and last coordinates.
The line that joins two points on a curved surface may or may not contain
the same set of co-ordinates that joins those two points on a flat
surface. The line that joins two points on a curved surface will be a
geodesic. Carefully check points to avoid errors with shared edges, as
well as overlaps and other types of intersections.
Polygons with a Single Ring
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following example specifies a GeoJSON ``Polygon`` with an exterior
ring and no interior rings (or holes). The first and last coordinates
must match in order to close the polygon:
.. code-block:: javascript
{
type: "Polygon",
coordinates: [ [ [ 0 , 0 ] , [ 3 , 6 ] , [ 6 , 1 ] , [ 0 , 0 ] ] ]
}
For Polygons with a single ring, the ring cannot self-intersect.
Polygons with Multiple Rings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Polygons with multiple rings:
- The first described ring must be the exterior ring.
- The exterior ring cannot self-intersect.
- Any interior ring must be entirely contained by the outer ring.
- Interior rings cannot intersect or overlap each other. Interior
rings cannot share an edge.
The following example represents a GeoJSON polygon with an interior ring:
.. code-block:: javascript
{
type : "Polygon",
coordinates : [
[ [ 0 , 0 ] , [ 3 , 6 ] , [ 6 , 1 ] , [ 0 , 0 ] ],
[ [ 2 , 2 ] , [ 3 , 3 ] , [ 4 , 2 ] , [ 2 , 2 ] ]
]
}
.. include:: /images/index-2dsphere-polygon-with-ring.rst
.. _geojson-multipoint:
``MultiPoint``
--------------
Requires :ref:`2dsphere-v2`
GeoJSON `MultiPoint <https://tools.ietf.org/html/rfc7946#section-3.1.3>`_
embedded documents encode a list of points.
.. code-block:: javascript
{
type: "MultiPoint",
coordinates: [
[ -73.9580, 40.8003 ],
[ -73.9498, 40.7968 ],
[ -73.9737, 40.7648 ],
[ -73.9814, 40.7681 ]
]
}
.. _geojson-multilinestring:
``MultiLineString``
-------------------
Requires :ref:`2dsphere-v2`
The following example specifies a GeoJSON `MultiLineString
<https://tools.ietf.org/html/rfc7946#section-3.1.5>`_:
.. code-block:: javascript
{
type: "MultiLineString",
coordinates: [
[ [ -73.96943, 40.78519 ], [ -73.96082, 40.78095 ] ],
[ [ -73.96415, 40.79229 ], [ -73.95544, 40.78854 ] ],
[ [ -73.97162, 40.78205 ], [ -73.96374, 40.77715 ] ],
[ [ -73.97880, 40.77247 ], [ -73.97036, 40.76811 ] ]
]
}
.. _geojson-multipolygon:
``MultiPolygon``
----------------
Requires :ref:`2dsphere-v2`
The following example specifies a GeoJSON `MultiPolygon
<https://tools.ietf.org/html/rfc7946#section-3.1.7>`_:
.. code-block:: javascript
{
type: "MultiPolygon",
coordinates: [
[ [ [ -73.958, 40.8003 ], [ -73.9498, 40.7968 ], [ -73.9737, 40.7648 ], [ -73.9814, 40.7681 ], [ -73.958, 40.8003 ] ] ],
[ [ [ -73.958, 40.8003 ], [ -73.9498, 40.7968 ], [ -73.9737, 40.7648 ], [ -73.958, 40.8003 ] ] ]
]
}
.. _geojson-geometrycollection:
``GeometryCollection``
----------------------
Requires :ref:`2dsphere-v2`
The following example stores coordinates of GeoJSON type
`GeometryCollection
<https://tools.ietf.org/html/rfc7946#section-3.1.8>`_:
.. code-block:: javascript
{
type: "GeometryCollection",
geometries: [
{
type: "MultiPoint",
coordinates: [
[ -73.9580, 40.8003 ],
[ -73.9498, 40.7968 ],
[ -73.9737, 40.7648 ],
[ -73.9814, 40.7681 ]
]
},
{
type: "MultiLineString",
coordinates: [
[ [ -73.96943, 40.78519 ], [ -73.96082, 40.78095 ] ],
[ [ -73.96415, 40.79229 ], [ -73.95544, 40.78854 ] ],
[ [ -73.97162, 40.78205 ], [ -73.96374, 40.77715 ] ],
[ [ -73.97880, 40.77247 ], [ -73.97036, 40.76811 ] ]
]
}
]
}