> For the complete documentation index, see [llms.txt](https://protectedseas.gitbook.io/navigator-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://protectedseas.gitbook.io/navigator-api-docs/api-reference/search/spatial-queries.md).

# Spatial queries

The [Search](/navigator-api-docs/api-reference/search.md) endpoint supports spatial querying **only via POST** with a GeoJSON geometry in the request body.

```http
POST https://map.navigatormap.org/api/search/
```

Spatial requests must include a `geometry` field in the JSON body. If `geometry` is missing, invalid, or has an unsupported type, the API returns `400 Bad Request`.

## Supported GeoJSON inputs

The `geometry` field can be:

* A **bare geometry** object: `Point`, `MultiPoint`, `LineString`, `MultiLineString`, `Polygon`, `MultiPolygon`, or `GeometryCollection`.
* A **Feature** wrapping a geometry.
* A **FeatureCollection**. For FeatureCollection inputs, the API internally builds a `GeometryCollection` from all valid feature geometries and intersects against that.

## How the geometry is used

When a valid geometry is provided:

* **Regions** are filtered with `ST_Intersects(boundary_land_eez, <geometry>)`.
* **Sites** are filtered with `ST_Intersects(mpa_boundaries_v2.wkb_geometry, <geometry>)`.

You can combine this spatial filter with all other search parameters (`q`, `type`, `lfp`, `region_id`, `ogc_fid`/`ps_id`, `limit`, `page`, `sort`, `export_bounds`).

## Result structure

The spatial POST endpoint returns JSON with `regions`, `sites`, and a `summary` block:

```json
{
  "regions": [ ... ],
  "sites": [ ... ],
  "summary": {
    "site_count": 12,
    "page": 1,
    "total_areas": 120,
    "max_lfp": 5
  }
}
```

{% hint style="info" %}
The example request bodies below use small, illustrative coordinates. Replace them with your real geometry — you do not need a large coordinate set for the request to work.
{% endhint %}

## Sites by point

```json
{
  "geometry": {
    "type": "Feature",
    "geometry": { "type": "Point", "coordinates": [-119.4, 33.9] },
    "properties": { "name": "Test Point" }
  },
  "type": "sites",
  "lang": "en_EN",
  "export_bounds": false
}
```

Returns all sites that intersect the specified point.

## Sites by bounding box + category filter

```json
{
  "geometry": {
    "type": "Feature",
    "geometry": {
      "type": "Polygon",
      "coordinates": [[[-119.6,33.8],[-119.2,33.8],[-119.2,34.0],[-119.6,34.0],[-119.6,33.8]]]
    },
    "properties": { "name": "Viewport BBox" }
  },
  "type": "sites",
  "category_id": "6,7",
  "lang": "en_EN",
  "export_bounds": true
}
```

Returns sites that intersect the bounding box and belong to the listed categories — here Vessel Restricted Areas (`6`) and Vessel Reporting Areas (`7`). This is the typical pattern for a map viewport: send the current view as the geometry and narrow to the categories you display.

## Sites by polygon + text + LFP + paging

```json
{
  "geometry": {
    "type": "Feature",
    "geometry": {
      "type": "Polygon",
      "coordinates": [[[-119.6,33.8],[-119.2,33.8],[-119.2,34.0],[-119.6,34.0],[-119.6,33.8]]]
    },
    "properties": { "name": "Test Polygon" }
  },
  "type": "sites",
  "lang": "en_EN",
  "q": "Channel Islands",
  "lfp": "low",
  "limit": 25,
  "page": 1,
  "sort": "LFP_DESC",
  "export_bounds": true
}
```

Returns a paginated array of sites that intersect the polygon, match the text query, and meet the LFP filter.

## Sites by multipolygon + region filter

```json
{
  "geometry": {
    "type": "Feature",
    "geometry": {
      "type": "MultiPolygon",
      "coordinates": [
        [[[-80.2,25.4],[-79.8,25.4],[-79.8,25.9],[-80.2,25.9],[-80.2,25.4]]],
        [[[-81.0,24.5],[-80.5,24.5],[-80.5,25.0],[-81.0,25.0],[-81.0,24.5]]]
      ]
    },
    "properties": { "name": "Florida Keys MultiPolygon" }
  },
  "type": "sites",
  "lang": "en_EN",
  "region_id": 550,
  "v": 1,
  "export_bounds": false
}
```

Returns sites that intersect the multipolygon and belong to the specified region.

## Regions by polygon

```json
{
  "geometry": {
    "type": "Feature",
    "geometry": {
      "type": "Polygon",
      "coordinates": [[[-119.6,33.8],[-119.2,33.8],[-119.2,34.0],[-119.6,34.0],[-119.6,33.8]]]
    },
    "properties": { "name": "Region Test Polygon" }
  },
  "type": "regions",
  "lang": "en_EN",
  "export_bounds": false
}
```

Returns regions that intersect the specified polygon.

## Regions + sites by FeatureCollection

```json
{
  "geometry": {
    "type": "FeatureCollection",
    "features": [
      { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-119.4, 33.9] }, "properties": { "name": "Point A" } },
      { "type": "Feature", "geometry": { "type": "Point", "coordinates": [-119.5, 34.0] }, "properties": { "name": "Point B" } }
    ]
  },
  "lang": "en_EN",
  "export_bounds": false
}
```

Returns regions and sites that intersect any feature in the provided FeatureCollection.
