setInsidePolygon method
InsidePolygon
Search inside a rectangular area (in geo coordinates).
A polygon
is an unlimited series of points, with a minimum of 3.
A point is a set of 2 floats: latitude, longitude.
The polygon therefore needs an even number of float values: p1Lat
, p1Lng
, p2Lat
, p2Lng
,
p3Lat
, p3Long
.
For example: insidePolygon=47.3165,4.9665,47.3424,5.0201,47.32,4.98
Usage notes:
- You can plot points that are 1 meter apart or 1000s of meters apart. This all depends on the oddness of the shape and its geographical size.
- multiple polygons
You may specify multiple polygons, in which case the search will use the union (OR) of the
polygons. To specify multiple polygons, pass an list of lists of floats (each inner array must
contain an even number of values, with a minimum of 6); example:
[[47.3165, 4.9665, 47.3424, 5.0201, 47.32, 4.9], [40.9234, 2.1185, 38.6430, 1.9916, 39.2587, 2.0104]]
. - Keep in mind the purpose of this setting. For example, if you are drawing a circle, you will use instead aroundRadius. If a rectangle, then insideBoundingBox. And so on.
- aroundLatLng and aroundLatLngViaIP will be ignored if used along with this parameter.
- Be careful when your coordinates cross over the
180th meridian
.
Source: Learn more
Implementation
AlgoliaQuery setInsidePolygon(List<BoundingPolygonBox> value) {
assert(value.isNotEmpty, 'value can not be empty');
assert(!_parameters.containsKey('insidePolygon'));
var list = value
.map((v) => [v.p1Lat, v.p1Lng, v.p2Lat, v.p2Lng, v.p3Lat, v.p3Lng])
.toList();
return _copyWithParameters(<String, dynamic>{'insidePolygon': list});
}