Polygon including points or polygons

Hi !
Is there any way to search which polygons include a point or another polygon ?
Thanks !

Hi there,

My apologies but I am not sure what you are referring to when you say “Polygon,” can you clarify?

Hi Kevin,
I mean a geographic area defined by a polygon [ [ lat, lng] … ]
so querying something like: return all documents where p1 encloses point P [x,y]
or
retrieve all documents where polygon p1 encloses polygon p2

Hey,

Algolia indeed lets you search records wich geo coordinates (the _geoloc reserved attribute) are contained within a polygon with the insidePolygon query parameter.

Geo coordinates always describe one or several points, with the following expected format:

{
  "_geoloc":{
    "lat": 40.639751,
    "lng": -73.778925
  }
}
{
  "_geoloc":[
    {
      "lat": 47.279430,
      "lng": 5.106450
    },
    {
      "lat": 47.293228,
      "lng": 5.004570
    },
    {
      "lat": 47.316669,
      "lng": 5.016670
    }
  ]
}

This means you can only describe exact locations, not whole areas. This may be confusing, because a list of coordinates sets like this one could, in theory, represent an area. However, if you search with insidePolygon and it matches only one of the coordinates sets, you’ll get the record back, even though the “polygon” described in your record isn’t fully “covered” by the one in insidePolygon.