GeoJSON

GeoJSON is a format designed to represent geographical features. The system supports GeoJSON data inside a document field. The syntax for a geometry field: <FIELD>: { type: <GEOSPATIAL_TYPE> , coordinates: <COORDINATES> }. Type GeometryCollection has a special syntax: <FIELD>: { type: "GeometryCollection", geometries: <GEOMETRIES> }.

Following examples use place document and attribute location to demonstrate GeoJSON primitives. Functionality is not limited to specific type and attribute. Any resource type/field can contain GeoJSON data.

Prerequisite to test following examples is to have an API key with permissions:

Path Methods ACL
/resources/place GET, POST off

Point

Point coordinates are pair x, y (or longitude, latitude) of a single position.

Example data:

{
  "type": "Point",
  "coordinates": [ 45.37916095, 12.1824646 ]
}

API request creating place document with an attribute location containing a Point:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "Pizzeria Super Mario",
      "location": {
        "type": "Point",
        "coordinates": [ 45.37916095, 12.1824646 ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59ed14a6ac6105371b44ccb9",
    "attributes": {
      "name": "Pizzeria Super Mario",
      "location": {
        "type": "Point",
        "coordinates": [ 45.37916095, 12.1824646 ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59ed14a6ac6105371b44ccb9"
    }
  }
}

Searching for place documents within 35 km from a given location can be done using the following query:

{
  "location": {
    "$nearSphere": {
      "$geometry": {
        "type": "Point",
        "coordinates": [ 45.58809519, 12.20375061 ]
      },
      "$maxDistance": 35000
    }
  }
}

Complete API request with URL encoded search query:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%20%5B45.58809519%2C12.20375061%5D%7D%2C%22%24maxDistance%22%3A35000%7D%7D%7D

The response contains place document:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59ed14a6ac6105371b44ccb9",
      "attributes": {
        "name": "Pizzeria Super Mario",
        "location": {
          "type": "Point",
          "coordinates": [ 45.37916095, 12.1824646 ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59ed14a6ac6105371b44ccb9"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%20%5B45.58809519%2C12.20375061%5D%7D%2C%22%24maxDistance%22%3A35000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%20%5B45.58809519%2C12.20375061%5D%7D%2C%22%24maxDistance%22%3A35000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}

LineString

LineString coordinates are an array of positions.

Example data:

{
  "type": "LineString",
  "coordinates": [
    [ 45.49864682, 13.50631714 ],
    [ 44.78963255, 13.91281128 ],
    [ 45.35793541, 14.33853149 ]
  ]
}

API request creating place document where attribute location contains LineString data:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "Coast of Istria",
      "location": {
        "type": "LineString",
        "coordinates": [
          [ 45.49864682, 13.50631714 ],
          [ 44.78963255, 13.91281128 ],
          [ 45.35793541, 14.33853149 ]
        ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59ee6625ac6105371b44ccc8",
    "attributes": {
      "name": "Coast of Istria",
      "location": {
        "type": "LineString",
        "coordinates": [
          [ 45.49864682, 13.50631714 ],
          [ 44.78963255, 13.91281128 ],
          [ 45.35793541, 14.33853149 ]
        ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59ee6625ac6105371b44ccc8"
    }
  }
}

To find out is coast within 10 km from the given location following query can be used:

{
  "location": {
    "$nearSphere": {
      "$geometry": {
        "type": "Point",
        "coordinates": [ 45.19558685, 14.10507202 ]
      },
      "$maxDistance": 10000
    }
  }
}

Complete API request with URL encoded search query:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B45.19558685%2C14.10507202%5D%7D%2C%22%24maxDistance%22%3A10000%7D%7D%7D

The response contains place document:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59ee6625ac6105371b44ccc8",
      "attributes": {
        "name": "Coast of Istra",
        "location": {
          "type": "LineString",
          "coordinates": [
            [ 45.49864682, 13.50631714 ],
            [ 44.78963255, 13.91281128 ],
            [ 45.35793541, 14.33853149 ]
          ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59ee6625ac6105371b44ccc8"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B45.19558685%2C14.10507202%5D%7D%2C%22%24maxDistance%22%3A10000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B45.19558685%2C14.10507202%5D%7D%2C%22%24maxDistance%22%3A10000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}

Polygon

Polygon coordinates are an array of closed LineString items. A closed LineString has at least 4 coordinates where first and last are the same. The first LineString in the array is an outer ring. The rest are inner rings, i.e. polygon holes.

Without hole

Example of a polygon with only one (outer) ring:

{
  "type": "Polygon",
  "coordinates": [
    [
      [ 35.99911854, 14.33887482 ],
      [ 35.87180326, 14.33544159 ],
      [ 35.79665238, 14.54692841 ],
      [ 35.86846473, 14.58469391 ],
      [ 35.99911854, 14.33887482 ]
    ]
  ]
}

API request creating place document with a polygon without a hole:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "Malta",
      "location": {
        "type": "Polygon",
          "coordinates": [
            [
              [ 35.99911854, 14.33887482 ],
              [ 35.87180326, 14.33544159 ],
              [ 35.79665238, 14.54692841 ],
              [ 35.86846473, 14.58469391 ],
              [ 35.99911854, 14.33887482 ]
            ]
          ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59ef1c8eac6105371b44ccd6",
    "attributes": {
      "name": "Malta",
      "location": {
        "type": "Polygon",
        "coordinates": [
          [
            [ 35.99911854, 14.33887482 ],
            [ 35.87180326, 14.33544159 ],
            [ 35.79665238, 14.54692841 ],
            [ 35.86846473, 14.58469391 ],
            [ 35.99911854, 14.33887482 ]
          ]
        ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59ef1c8eac6105371b44ccd6"
    }
  }
}

Testing GeoJSON polygon can be done using query:

{
  "location": {
    "$geoIntersects": {
      "$geometry": {
        "type":"Point",
        "coordinates": [ 35.89071893, 14.45491791 ]
      }
    }
  }
}

Complete query API request:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B35.89071893%2C14.45491791%5D%7D%7D%7D%7D

The response contains place document since given point is inside a polygon:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59ef1c8eac6105371b44ccd6",
      "attributes": {
        "name": "Malta",
        "location": {
          "type": "Polygon",
          "coordinates": [
            [
              [ 35.99911854, 14.33887482 ],
              [ 35.87180326, 14.33544159 ],
              [ 35.79665238, 14.54692841 ],
              [ 35.86846473, 14.58469391 ],
              [ 35.99911854, 14.33887482 ]
            ]
          ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59ef1c8eac6105371b44ccd6"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B35.89071893%2C14.45491791%5D%7D%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B35.89071893%2C14.45491791%5D%7D%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}

With hole

Example of a polygon with an outer and inner ring (hole):

{
  "type": "Polygon",
  "coordinates": [
    [
      [ 42.17561741, 57.82104492 ],
      [ 41.90227704, 57.01354981 ],
      [ 41.23651121, 57.09594727 ],
      [ 41.29018996, 56.42028809 ],
      [ 40.31723173, 57.06848145 ],
      [ 40.44276659, 58.04626465 ],
      [ 41.31082388, 58.30444336 ],
      [ 42.17561741, 57.82104492 ]
    ],
    [
      [ 42.09007007, 57.63427734 ],
      [ 41.86137916, 57.07397461 ],
      [ 41.57436131, 57.33764648 ],
      [ 41.74672584, 57.85400391 ],
      [ 42.09007007, 57.63427734 ]
    ]
  ]
}

API request creating place document with a polygon containing a hole:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
  "type": "place",
  "attributes": {
    "name": "Kaplankyr Reserve",
    "location": {
      "type": "Polygon",
      "coordinates": [
        [
          [ 42.17561741, 57.82104492 ],
          [ 41.90227704, 57.01354981 ],
          [ 41.23651121, 57.09594727 ],
          [ 41.29018996, 56.42028809 ],
          [ 40.31723173, 57.06848145 ],
          [ 40.44276659, 58.04626465 ],
          [ 41.31082388, 58.30444336 ],
          [ 42.17561741, 57.82104492 ]
        ],
        [
          [ 42.09007007, 57.63427734 ],
          [ 41.86137916, 57.07397461 ],
          [ 41.57436131, 57.33764648 ],
          [ 41.74672584, 57.85400391 ],
          [ 42.09007007, 57.63427734 ]
        ]
      ]
    }
  }
}
}' \
-X POST https://api.jazer.io/resources/place

Test query contains point within polygon hole:

{
  "location": {
    "$geoIntersects": {
      "$geometry": {
        "type": "Point",
        "coordinates": [ 41.76311745, 57.46948242 ]
      }
    }
  }
}

Complete test API request:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B41.76311745%2C57.46948242%5D%7D%7D%7D%7D

The response does not contain place document since the point is within a polygon hole:

{
  "meta": {
    "count": 0
  },
  "data": [],
  "links": {
    "first": null,
    "prev": null,
    "next": null,
    "last": null
  }
}

MultiPoint

MultiPoint coordinates are an array of positions.

Example data:

{
  "type": "MultiPoint",
  "coordinates": [
    [ 35.97967315, -5.60989381 ],
    [ 35.83562839, -5.73554993 ]
  ]
}

API request creating place document with attribute location containing a MultiPoint:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "Strait of Gibraltar",
      "location": {
        "type": "MultiPoint",
        "coordinates": [
          [ 35.97967315, -5.60989381 ],
          [ 35.83562839, -5.73554993 ]
        ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59fa2617ac610566217aa4bb",
    "attributes": {
      "name": "Strait of Gibraltar",
      "location": {
        "type": "MultiPoint",
        "coordinates": [
          [ 35.97967315, -5.6098938 ],
          [ 35.83562839, -5.73554993 ]
        ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59fa2617ac610566217aa4bb"
    }
  }
}

To find out is Strait of Gibraltar within 80 km from the given location following query can be used:

{
  "location": {
    "$nearSphere": {
      "$geometry": {
        "type": "Point",
        "coordinates": [ 35.6863024, -6.37756348 ]
      },
      "$maxDistance": 80000
    }
  }
}

The response contains Strait of Gibraltar since second point coordinates satisfies the query:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59fa2617ac610566217aa4bb",
      "attributes": {
        "name": "Strait of Gibraltar",
        "location": {
          "type": "MultiPoint",
          "coordinates": [
            [ 35.97967315, -5.6098938 ],
            [ 35.83562839, -5.73554993 ]
          ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59fa2617ac610566217aa4bb"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B35.6863024%2C-6.37756348%5D%7D%2C%20%22%24maxDistance%22%3A%2080000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B35.6863024%2C-6.37756348%5D%7D%2C%20%22%24maxDistance%22%3A%2080000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}

MultiLineString

MultiLineString coordinates are an array of LineString items.

Example data:

{
  "type": "MultiLineString",
  "coordinates": [
    [
      [ 14.91293837, -83.29833984 ],
      [ 14.33624297, -83.19396973 ],
      [ 13.14902697, -83.56750488 ],
      [ 12.38292834, -83.48510742 ],
      [ 11.96409729, -83.71582031 ],
      [ 11.58228816, -83.61694336 ],
      [ 11.29693444, -83.88610841 ],
      [ 10.93579843, -83.68835449 ]
    ],
    [
      [ 12.92426063, -87.33032227 ],
      [ 13.05272355, -87.57751465 ],
      [ 12.90819811, -87.68737793 ],
      [ 12.18433444, -86.76452637 ],
      [ 11.64147628, -86.39648437 ],
      [ 11.08138461, -85.70434572 ]
    ]
  ]
}

API request creating place document with attribute location containing a MultiLineString:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "Coast of Nicaragua",
      "location": {
        "type": "MultiLineString",
        "coordinates": [
          [
            [ 14.91293837, -83.29833984 ],
            [ 14.33624297, -83.19396973 ],
            [ 13.14902697, -83.56750488 ],
            [ 12.38292834, -83.48510742 ],
            [ 11.96409729, -83.71582031 ],
            [ 11.58228816, -83.61694336 ],
            [ 11.29693444, -83.88610841 ],
            [ 10.93579843, -83.68835449 ]
          ],
          [
            [ 12.92426063, -87.33032227 ],
            [ 13.05272355, -87.57751465 ],
            [ 12.90819811, -87.68737793 ],
            [ 12.18433444, -86.76452637 ],
            [ 11.64147628, -86.39648437 ],
            [ 11.08138461, -85.70434572 ]
          ]
        ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59fa56d5ac610566217aa4ca",
    "attributes": {
      "name": "Coast of Nicaragua",
      "location": {
        "type": "MultiLineString",
        "coordinates": [
          [
            [ 14.91293837, -83.29833984 ],
            [ 14.33624297, -83.19396973 ],
            [ 13.14902697, -83.56750488 ],
            [ 12.38292834, -83.48510742 ],
            [ 11.96409729, -83.71582031 ],
            [ 11.58228816, -83.61694336 ],
            [ 11.29693444, -83.88610841 ],
            [ 10.93579843, -83.68835449 ]
          ],
          [
            [ 12.92426063, -87.33032227 ],
            [ 13.05272355, -87.57751465 ],
            [ 12.90819811, -87.68737793 ],
            [ 12.18433444, -86.76452637 ],
            [ 11.64147628, -86.39648437 ],
            [ 11.08138461, -85.70434572 ]
          ]
        ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59fa56d5ac610566217aa4ca"
    }
  }
}

To find out is coast within 50 km from the given location following query can be used:

{
  "location": {
    "$nearSphere": {
      "$geometry": {
        "type": "Point",
        "coordinates": [ 13.15437606, -83.22143555 ]
      },
      "$maxDistance": 50000
    }
  }
}

Complete API request is:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B13.15437606%2C-83.22143555%5D%7D%2C%22%24maxDistance%22%3A50000%7D%7D%7D

The response contains Coast of Nicaragua since first LineString satisfies the query:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59fa56d5ac610566217aa4ca",
      "attributes": {
        "name": "Coast of Nicaragua",
        "location": {
          "type": "MultiLineString",
          "coordinates": [
            [
              [ 14.91293837, -83.29833984 ],
              [ 14.33624297, -83.19396973 ],
              [ 13.14902697, -83.56750488 ],
              [ 12.38292834, -83.48510742 ],
              [ 11.96409729, -83.71582031 ],
              [ 11.58228816, -83.61694336 ],
              [ 11.29693444, -83.88610841 ],
              [ 10.93579843, -83.68835449 ]
            ],
            [
              [ 12.92426063, -87.33032227 ],
              [ 13.05272355, -87.57751465 ],
              [ 12.90819811, -87.68737793 ],
              [ 12.18433444, -86.76452637 ],
              [ 11.64147628, -86.39648437 ],
              [ 11.08138461, -85.70434572 ]
            ]
          ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59fa56d5ac610566217aa4ca"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B13.15437606%2C-83.22143555%5D%7D%2C%22%24maxDistance%22%3A50000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24nearSphere%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B13.15437606%2C-83.22143555%5D%7D%2C%22%24maxDistance%22%3A50000%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}

MultiPolygon

MultiPolygon coordinates are an array of Polygon items.

Example data:

{ "type": "MultiPolygon", "coordinates": [
  [
    [
      [ 174.33105469, -41.73852847 ],
      [ 172.74902344, -43.46886761 ],
      [ 173.32031252, -43.73935208 ],
      [ 173.07861328, -44.07180047 ],
      [ 172.28759766, -43.89789239 ],
      [ 171.27685547, -44.52784281 ],
      [ 170.70556641, -45.95114969 ],
      [ 169.47509766, -46.75491662 ],
      [ 166.11328125, -45.89000816 ],
      [ 170.92529297, -42.66628071 ],
      [ 172.81494141, -40.49709237 ],
      [ 173.56201172, -41.04621681 ],
      [ 174.11132813, -40.66397288 ],
      [ 174.33105469, -41.73852847 ]
    ]
  ],
  [
    [
      [ 178.68164063, -37.66642921 ],
      [ 178.46191406, -38.58252616 ],
      [ 177.94555664, -39.25777815 ],
      [ 176.98974609, -39.34279441 ],
      [ 177.13256836, -39.66068502 ],
      [ 176.67663574, -40.50126946 ],
      [ 175.29235842, -41.66060124 ],
      [ 174.61669922, -41.24477234 ],
      [ 175.14404297, -40.14528932 ],
      [ 173.64990234, -39.31730037 ],
      [ 174.52880859, -38.80547022 ],
      [ 174.81445313, -37.73596921 ],
      [ 172.60620117, -34.43409789 ],
      [ 173.07861328, -34.34343607 ],
      [ 175.48461914, -36.09349937 ],
      [ 176.13281252, -37.51844024 ],
      [ 177.41821289, -37.95286092 ],
      [ 178.12133789, -37.48357655 ],
      [ 178.68164063, -37.66642921 ]
    ]
  ]
] }

API request will create New Zealand place document where each polygon represents one island:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "New Zealand",
      "location": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [ 174.33105469, -41.73852847 ],
              [ 172.74902344, -43.46886761 ],
              [ 173.32031252, -43.73935208 ],
              [ 173.07861328, -44.07180047 ],
              [ 172.28759766, -43.89789239 ],
              [ 171.27685547, -44.52784281 ],
              [ 170.70556641, -45.95114969 ],
              [ 169.47509766, -46.75491662 ],
              [ 166.11328125, -45.89000816 ],
              [ 170.92529297, -42.66628071 ],
              [ 172.81494141, -40.49709237 ],
              [ 173.56201172, -41.04621681 ],
              [ 174.11132813, -40.66397288 ],
              [ 174.33105469, -41.73852847 ]
            ]
          ],
          [
            [
              [ 178.68164063, -37.66642921 ],
              [ 178.46191406, -38.58252616 ],
              [ 177.94555664, -39.25777815 ],
              [ 176.98974609, -39.34279441 ],
              [ 177.13256836, -39.66068502 ],
              [ 176.67663574, -40.50126946 ],
              [ 175.29235842, -41.66060124 ],
              [ 174.61669922, -41.24477234 ],
              [ 175.14404297, -40.14528932 ],
              [ 173.64990234, -39.31730037 ],
              [ 174.52880859, -38.80547022 ],
              [ 174.81445313, -37.73596921 ],
              [ 172.60620117, -34.43409789 ],
              [ 173.07861328, -34.34343607 ],
              [ 175.48461914, -36.09349937 ],
              [ 176.13281252, -37.51844024 ],
              [ 177.41821289, -37.95286092 ],
              [ 178.12133789, -37.48357655 ],
              [ 178.68164063, -37.66642921 ]
            ]
          ]
        ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59fd00c2ac61052bff2f3ff8",
    "attributes": {
      "name": "New Zealand",
      "location": {
        "type": "MultiPolygon",
        "coordinates": [
          [
            [
              [ 174.33105469, -41.73852847 ],
              [ 172.74902344, -43.46886761 ],
              [ 173.32031252, -43.73935208 ],
              [ 173.07861328, -44.07180047 ],
              [ 172.28759766, -43.89789239 ],
              [ 171.27685547, -44.52784281 ],
              [ 170.70556641, -45.95114969 ],
              [ 169.47509766, -46.75491662 ],
              [ 166.11328125, -45.89000816 ],
              [ 170.92529297, -42.66628071 ],
              [ 172.81494141, -40.49709237 ],
              [ 173.56201172, -41.04621681 ],
              [ 174.11132813, -40.66397288 ],
              [ 174.33105469, -41.73852847 ]
            ]
          ],
          [
            [
              [ 178.68164063, -37.66642921 ],
              [ 178.46191406, -38.58252616 ],
              [ 177.94555664, -39.25777815 ],
              [ 176.98974609, -39.34279441 ],
              [ 177.13256836, -39.66068502 ],
              [ 176.67663574, -40.50126946 ],
              [ 175.29235842, -41.66060124 ],
              [ 174.61669922, -41.24477234 ],
              [ 175.14404297, -40.14528932 ],
              [ 173.64990234, -39.31730037 ],
              [ 174.52880859, -38.80547022 ],
              [ 174.81445313, -37.73596921 ],
              [ 172.60620117, -34.43409789 ],
              [ 173.07861328, -34.34343607 ],
              [ 175.48461914, -36.09349937 ],
              [ 176.13281252, -37.51844024 ],
              [ 177.41821289, -37.95286092 ],
              [ 178.12133789, -37.48357655 ],
              [ 178.68164063, -37.66642921 ]
            ]
          ]
        ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59fd00c2ac61052bff2f3ff8"
    }
  }
}

Following query tests is the given point on New Zealand:

{
  "location": {
    "$geoIntersects": {
      "$geometry": {
        "type":"Point",
        "coordinates": [ 175.56152344, -39.63953756 ]
      }
    }
  }
}

Complete API request with URL encoded query is:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B175.56152344%2C-39.63953756%5D%7D%7D%7D%7D

The response contains New Zealand place document since the point is inside the second polygon:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59fdf653ac61052bff2f3ffe",
      "attributes": {
        "name": "New Zealand",
        "location": {
          "type": "MultiPolygon",
          "coordinates": [
            [
              [
                [ 174.33105469, -41.73852847 ],
                [ 172.74902344, -43.46886761 ],
                [ 173.32031252, -43.73935208 ],
                [ 173.07861328, -44.07180047 ],
                [ 172.28759766, -43.89789239 ],
                [ 171.27685547, -44.52784281 ],
                [ 170.70556641, -45.95114969 ],
                [ 169.47509766, -46.75491662 ],
                [ 166.11328125, -45.89000816 ],
                [ 170.92529297, -42.66628071 ],
                [ 172.81494141, -40.49709237 ],
                [ 173.56201172, -41.04621681 ],
                [ 174.11132813, -40.66397288 ],
                [ 174.33105469, -41.73852847 ]
              ]
            ],
            [
              [
                [ 178.68164063, -37.66642921 ],
                [ 178.46191406, -38.58252616 ],
                [ 177.94555664, -39.25777815 ],
                [ 176.98974609, -39.34279441 ],
                [ 177.13256836, -39.66068502 ],
                [ 176.67663574, -40.50126946 ],
                [ 175.29235842, -41.66060124 ],
                [ 174.61669922, -41.24477234 ],
                [ 175.14404297, -40.14528932 ],
                [ 173.64990234, -39.31730037 ],
                [ 174.52880859, -38.80547022 ],
                [ 174.81445313, -37.73596921 ],
                [ 172.60620117, -34.43409789 ],
                [ 173.07861328, -34.34343607 ],
                [ 175.48461914, -36.09349937 ],
                [ 176.13281252, -37.51844024 ],
                [ 177.41821289, -37.95286092 ],
                [ 178.12133789, -37.48357655 ],
                [ 178.68164063, -37.66642921 ]
              ]
            ]
          ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59fdf653ac61052bff2f3ffe"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B175.56152344%2C-39.63953756%5D%7D%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24geoIntersects%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B175.56152344%2C-39.63953756%5D%7D%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}

GeometryCollection

GeometryCollection geometries are an array of geometry items.

Example data:

{
  "type": "GeometryCollection",
  "geometries": [
    {
      "type": "Point",
      "coordinates": [ -29.36096191, 39.79165484 ]
    },
    {
      "type": "LineString",
      "coordinates": [ [ -29.1192627, 39.41497702 ], [ -29.58618164, 39.52522954 ] ]
    }
  ]
}

API request creating place document with GeometryCollection:

curl -H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-d '
{
  "data": {
    "type": "place",
    "attributes": {
      "name": "Imagination",
      "location": {
        "type": "GeometryCollection",
        "geometries": [
          {
            "type": "Point",
            "coordinates": [ -29.36096191, 39.79165484 ]
          },
          {
            "type": "LineString",
            "coordinates": [ [ -29.1192627, 39.41497702 ], [ -29.58618164, 39.52522954 ] ]
          }
        ]
      }
    }
  }
}' \
-X POST https://api.jazer.io/resources/place

The response contains created place document:

{
  "data": {
    "type": "place",
    "id": "59fdfc52ac61052bff2f4002",
    "attributes": {
      "name": "Imagination",
      "location": {
        "type": "GeometryCollection",
        "geometries": [
          {
            "type": "Point",
            "coordinates": [ -29.36096191, 39.79165484 ]
          },
          {
            "type": "LineString",
            "coordinates": [ [ -29.1192627, 39.41497702 ], [ -29.58618164, 39.52522954 ] ]
          }
        ]
      }
    },
    "links": {
      "self": "https://api.jazer.io/resources/place/59fdfc52ac61052bff2f4002"
    }
  }
}

Query to test if the given polygon contains all geometry collection primitives:

{
  "location": {
    "$geoWithin": {
      "$geometry": {
        "type":"Polygon",
        "coordinates": [
          [
            [ -27.71850586, 40.45948692 ],
            [ -27.58666992, 39.17265867 ],
            [ -30.24536133, 39.23225314 ],
            [ -30.41015625, 41.27780647 ],
            [ -27.71850586, 40.45948693 ]
          ]
        ]
      }
    }
  }
}

API request with URL encoded query:

curl --globoff -H 'Accept: application/vnd.api+json' \
-H 'api-key: <YOUR_API_KEY_SECURE_ID>' \
-H 'application-id: <YOUR_APPLICATION_ID>' \
-X GET https://api.jazer.io/resources/place?filter[*]=%7B%22location%22%3A%7B%22%24geoWithin%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-27.71850586%2C40.4594869%5D%2C%5B-27.58666992%2C39.17265867%5D%2C%5B-30.24536133%2C39.23225314%5D%2C%5B-30.41015625%2C41.27780647%5D%2C%5B-27.71850586%2C40.4594869%5D%5D%5D%7D%7D%7D%7D

The response contains place document:

{
  "meta": {
    "count": 1
  },
  "data": [
    {
      "type": "place",
      "id": "59fdfc52ac61052bff2f4002",
      "attributes": {
        "name": "Imagination",
        "location": {
          "type": "GeometryCollection",
          "geometries": [
            {
              "type": "Point",
              "coordinates": [ -29.36096191, 39.79165484 ]
            },
            {
              "type": "LineString",
              "coordinates": [ [ -29.1192627, 39.41497702 ], [ -29.58618164, 39.52522954 ] ]
            }
          ]
        }
      },
      "links": {
        "self": "https://api.jazer.io/resources/place/59fdfc52ac61052bff2f4002"
      }
    }
  ],
  "links": {
    "first": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24geoWithin%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-27.71850586%2C40.4594869%5D%2C%5B-27.58666992%2C39.17265867%5D%2C%5B-30.24536133%2C39.23225314%5D%2C%5B-30.41015625%2C41.27780647%5D%2C%5B-27.71850586%2C40.4594869%5D%5D%5D%7D%7D%7D%7D&page[offset]=0&page[limit]=20",
    "last": "https://api.jazer.io/resources/place?filter%5B*%5D=%7B%22location%22%3A%7B%22%24geoWithin%22%3A%7B%22%24geometry%22%3A%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B-27.71850586%2C40.4594869%5D%2C%5B-27.58666992%2C39.17265867%5D%2C%5B-30.24536133%2C39.23225314%5D%2C%5B-30.41015625%2C41.27780647%5D%2C%5B-27.71850586%2C40.4594869%5D%5D%5D%7D%7D%7D%7D&page[offset]=0&page[limit]=20",
    "prev": null,
    "next": null
  }
}