About GeoJson Data

The GeoJson specification (Internet Engineering Task Force) defines the structure and content of json objects that are supposed to represent geographical shapes on earth (called geometries). Oracle NoSQL Database implements a number of functions that do indeed interpret such json objects as geometries and allow for the search for rows containing geometries that satisfy certain conditions. Search is made efficient via the use of special indexes.

According to the GeoJson specification, for a json object to be a geometry object it must have two fields called "type" and "coordinates", where the value of the "type" field specifies the kind of geometry and the value of "coordinates" must be an array whose elements define the geometrical shape (the GeometryCollection kind is an exception to this rule, as we will see below). The value of the "type" field must be one of the following 7 strings, corresponding to 7 different kinds of geometry objects: "Point", "LineSegment", "Polygon", "MultiPoint", "MultiLineString", "MultiPolygon", and "GeometryCollection". The value of "coordinates" depends on the kind of geometry, but in all cases it is composed of a number of positions. A position specifies a position on the surface of the earth as an array of 2 double numbers, where the first number is the longitude and the second number is the latitude of the position (GeoJson allows the position’s altitude as a 3rd coordinate, but Oracle NoSQL Database does not support altitudes). Longitude and latitude are specified as degrees and must range between -180 to +180 and -90 to +90, respectively.

The 7 kinds of geometry objects are defined as follows: (with an example given in each case)

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; the end-point of one line is the start-point of the next line. The "coordinates" member is an array of two or more positions: the 1st position is the start point of the 1st line and each subsequent position is the end point of the current line and the start of the next line. Lines may 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, i.e., for exterior rings their positions must be ordered counterclockwise, and for holes their position 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 6 kinds defined earlier. So, in general, a GeometryCollection is a heterogeneous composition of geometries.
{
"type": "GeometryCollection",
"geometries": [
{
"type": "Point",
"coordinates": [100.0, 0.0]
},
{
"type": "LineString",
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}

The GeoJson specification defines 2 additional kinds of entities, called Feature and FeatureCollection, which allow for combining geometries with other, non-geometrical properties. The specification uses defined above) or a Feature or a FeatureCollection. Feature and FeatureCollection are defined as follows:

Feature
A Feature object has a "type" member with the value "Feature". A Feature object has a "geometry" member, whose value either a geometry object of the 7 kinds defined above or the JSON null value. A Feature object has a "properties" member, whose value is any JSON object or the JSON null value.
FeatureCollection
A FeatureCollection object has a "type" member with the value "FeatureCollection". A FeatureCollection object has a "features" member, whose value is a JSON array. Each element of the array is a Feature object as defined above. It is possible for this array to be empty.