polygon_checker 1.2.0
polygon_checker: ^1.2.0 copied to clipboard
A lightweight Dart utility to check whether a point lies inside polygon locations.
Polygon Checker #
A lightweight Dart utility to check whether a latitude/longitude coordinate lies inside or near specified polygon locations.
Features #
- Strict Inside Check: Determine if a point is mathematically inside a polygon.
- Proximity Check: Check if a point is within a specific distance (e.g., 50 meters) of a polygon boundary.
- Location Retrieval: Get the full
PolygonLocationobject (ID, Name, Points) for the matched area.
Usage #
1. Simple Boolean Check #
Check if a user is strictly inside any office:
import 'package:polygon_checker/polygon_checker.dart';
bool isInside = PolygonChecker.isInsideAnyOfficePolygon(
userLat,
userLng,
offices,
);
2. Proximity Check (with Radius) #
Check if a user is inside or within 50 meters of an office:
bool isNear = PolygonChecker.isInsideOrNearAnyOfficePolygon(
userLat,
userLng,
offices,
radiusInMeters: 50.0, // Optional, defaults to 50.0
);
3. Get Matched Location Details #
Retrieve the specific office details if a match is found:
PolygonLocation? location = PolygonChecker.getInsideOrNearOfficePolygon(
userLat,
userLng,
offices,
radiusInMeters: 50.0,
);
if (location != null) {
print('Matched: ${location.locationName} (${location.locationId})');
}
Installation #
Add this to your pubspec.yaml:
dependencies:
polygon_checker:
path: ../polygon_checker # or version from pub.dev