GeoPolygonService class

Service for polygon-based geofence operations.

Uses the Ray Casting algorithm to determine if points lie within polygonal geofences.

Example:

final polygon = GeoPolygon(points: [
  GeoPoint(latitude: 37.7749, longitude: -122.4194),
  GeoPoint(latitude: 37.7849, longitude: -122.4094),
  GeoPoint(latitude: 37.7649, longitude: -122.4094),
]);

final point = GeoPoint(latitude: 37.7750, longitude: -122.4180);

final inside = GeoPolygonService.isInsidePolygon(
  point: point,
  polygon: polygon,
);

Constructors

GeoPolygonService()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

calculateArea(GeoPolygon polygon) double
Calculates the approximate area of the polygon.
calculatePerimeter(GeoPolygon polygon) double
Calculates the perimeter of the polygon.
countInside({required List<GeoPoint> points, required GeoPolygon polygon}) int
Counts how many points are inside the polygon.
countOutside({required List<GeoPoint> points, required GeoPolygon polygon}) int
Counts how many points are outside the polygon.
filterInside({required List<GeoPoint> points, required GeoPolygon polygon}) List<GeoPoint>
Filters points that are inside the polygon.
filterOutside({required List<GeoPoint> points, required GeoPolygon polygon}) List<GeoPoint>
Filters points that are outside the polygon.
getBoundingBox(GeoPolygon polygon) Map<String, double>
Calculates the bounding box of the polygon.
isConvex(GeoPolygon polygon) bool
Checks if a polygon is convex.
isInBoundingBox({required GeoPoint point, required GeoPolygon polygon}) bool
Performs a quick bounding box check before full polygon test.
isInsidePolygon({required GeoPoint point, required GeoPolygon polygon, bool includeBoundary = true}) bool
Checks if a point is inside a polygon using Ray Casting algorithm.
isInsidePolygonOptimized({required GeoPoint point, required GeoPolygon polygon}) bool
Optimized point-in-polygon check with bounding box pre-check.
isOnBoundary({required GeoPoint point, required GeoPolygon polygon, double tolerance = 0.00001}) bool
Checks if a point lies on any edge of the polygon.
isValidPolygon(GeoPolygon polygon) bool
Validates if a polygon is well-formed.