GeoJSON Data Definitions

The GeoJSON specification (https://tools.ietf.org/html/rfc7946) states that for a JSON object to be a geometry, it requires two fields, type and coordinates. The value of the type field specifies the kind of geometric shape the object describes. The value of the type field must be one of the following strings, corresponding to different kinds of geometries:
  • Point

  • LineSegment

  • Polygon

  • MultiPoint

  • MultiLineString

  • MultiPolygon

  • GeometryCollection

The coordinates value is an array with elements that define the geometrical shape. An exception to this is the GeometryCollection type, which is described below. The coordinates value depends on the geometric shape, but in all cases, specifies a number of positions. A position defines a position on the surface of the earth as an array of two double numbers, where the first number is the longitude and the second number is the latitude. Longitude and latitude are specified as degrees and must range between -180 – +180 and -90 – +90, respectively.

Note:

The GeoJSON specification allows a third coordinate for the altitude of the position, but Oracle NoSQL Database does not support altitudes.

The kinds of geometries are defined as follows, each with an example of such an object:

Point — For type Point, the coordinates field is a single position:
{ "type" : "point", "coordinates" : [ 23.549, 35.2908 ] }
LineString — A LineString is one or more connected lines, with the end-point of one line being the start-point of the next. The coordinates field is an array of two or more positions. The first position is the start point of the first line, and each subsequent position is the end point of the previous line and the start of the next line. Lines can cross each other.
{         
"type" : "LineString",
"coordinates" : [ 
[-121.9447, 37.2975],
[-121.9500, 37.3171],
[-121.9892, 37.3182],
[-122.1554, 37.3882],
[-122.2899, 37.4589],
[-122.4273, 37.6032],
[-122.4304, 37.6267],                           
[-122.3975, 37.6144]
]
}

Polygon — A polygon defines a surface area by specifying its outer perimeter and the perimeters of any potential holes inside the area. More precisely, a polygon consists of one or more linear rings, where (a) a linear ring is a closed LineString with four or more positions, (b) the first and last positions are equivalent, and they must contain identical values, (c) a linear ring is the boundary of a surface or the boundary of a hole in a surface, and (d) a linear ring must follow the right-hand rule with respect to the area it bounds. That is, positions for exterior rings must be ordered counterclockwise, and positions for holes must be ordered clockwise. Then, the coordinates field of a polygon must be an array of linear ring coordinate arrays, where the first must be the exterior ring, and any others must be interior rings.

The exterior ring bounds the surface, and the interior rings (if present) bound holes within the surface. The example below shows a polygon with no holes.
{         
"type" : "polygon", 
"coordinates" : [ [
[23.48, 35.16],
[24.30, 35.16],
[24.30, 35.50],
[24.16, 35.61],
[23.74, 35.70],
[23.56, 35.60],
[23.48, 35.16]
]
]
}  
MultiPoint — For type MultiPoint, the coordinates field is an array of two or more positions:
{         
"type" : "MultiPoint",
"coordinates" : [ 
[-121.9447, 37.2975],
[-121.9500, 37.3171],
[-122.3975, 37.6144]
]
}
MultiLineString — For type MultiLineString, the coordinates member is an array of LineString coordinate arrays.
{    
"type": "MultiLineString",
"coordinates": [ 
[ [100.0, 0.0], [01.0, 1.0] ],
[ [102.0, 2.0], [103.0, 3.0] ]
]  
} 
MultiPolygon — For type MultiPolygon, the coordinates member is an array of Polygon coordinate arrays.
 {    
"type": "MultiPolygon",
"coordinates": [
[                       
[
[102.0, 2.0],
[103.0, 2.0],                         
[103.0, 3.0],                         
[102.0, 3.0],                         
[102.0, 2.0]                       
]                     
],
                     
[                       
[                         
[100.0, 0.0],                         
[101.0, 0.0],                         
[101.0, 1.0],                         
[100.0, 1.0],                         
[100.0, 0.0]
]                     
]                   
] 
}     
GeometryCollection — Instead of a coordinates field, a GeometryCollection has a geometries” field. The value of geometries is an array. Each element of this array is a GeoJSON object whose kind is one of the six kinds defined above. In general, a GeometryCollection is a heterogeneous composition of smaller geometries.
{    "type": "GeometryCollection",    
"geometries": [
{
"type": "Point",
"coordinates": [100.0, 0.0]
},                    
{"type": "LineString",                      
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
}                  
] 
}

Note:

The GeoJSON specification defines two additional kinds of entities, Feature and FeatureCollection. The Oracle NoSQL Database does not support these entities.