geofencePolygon method
Future<List<GeoJsonPoint> >
geofencePolygon({
- required GeoJsonPolygon polygon,
- required List<
GeoJsonPoint> points, - bool disableStream = false,
- bool verbose = false,
Find all the GeoJsonPoint located in a GeoJsonPolygon from a list of points
Implementation
Future<List<GeoJsonPoint>> geofencePolygon(
{required GeoJsonPolygon polygon,
required List<GeoJsonPoint> points,
bool disableStream = false,
bool verbose = false}) async {
final foundPoints = <GeoJsonPoint>[];
final finished = Completer<void>();
late Iso iso;
iso = Iso(_geofencePolygonRunner, onDataOut: (dynamic data) {
if (data is GeoJsonPoint) {
final point = data;
foundPoints.add(point);
if (!disableStream) {
_processedPointsController.sink.add(point);
}
} else {
iso.dispose();
finished.complete();
}
}, onError: (dynamic e) {
throw GeofencingException("Can not geofence polygon $e");
});
final dataToProcess =
_GeoFenceToProcess(points: points, polygon: polygon, verbose: verbose);
unawaited(iso.run(<dynamic>[dataToProcess]));
await finished.future;
return foundPoints;
}