new change to use intaleq_map sdk 04-16-4
This commit is contained in:
43
scratch/verify_geo.dart
Normal file
43
scratch/verify_geo.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:maplibre_gl/maplibre_gl.dart';
|
||||
|
||||
class CountryPolygons {
|
||||
static final List<LatLng> jordanBoundary = [
|
||||
const LatLng(32.65, 35.80),
|
||||
const LatLng(32.35, 37.00),
|
||||
const LatLng(31.85, 36.80),
|
||||
const LatLng(31.00, 36.50),
|
||||
const LatLng(30.30, 35.75),
|
||||
const LatLng(29.50, 35.00),
|
||||
const LatLng(29.50, 34.85),
|
||||
const LatLng(30.80, 35.25),
|
||||
const LatLng(32.00, 35.50),
|
||||
const LatLng(32.45, 35.60),
|
||||
const LatLng(32.65, 35.80),
|
||||
];
|
||||
|
||||
static bool isPointInPolygon(LatLng p, List<LatLng> polygon) {
|
||||
bool isInside = false;
|
||||
int j = polygon.length - 1;
|
||||
for (int i = 0; i < polygon.length; i++) {
|
||||
if (((polygon[i].latitude > p.latitude) != (polygon[j].latitude > p.latitude)) &&
|
||||
(p.longitude < (polygon[j].longitude - polygon[i].longitude) * (p.latitude - polygon[i].latitude) / (polygon[j].latitude - polygon[i].latitude) + polygon[i].longitude)) {
|
||||
isInside = !isInside;
|
||||
}
|
||||
j = i;
|
||||
}
|
||||
return isInside;
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Amman coordinates from log: 32.1117, 36.0671
|
||||
final amman = LatLng(32.1117, 36.0671);
|
||||
final isAmmanInJordan = CountryPolygons.isPointInPolygon(amman, CountryPolygons.jordanBoundary);
|
||||
|
||||
print('Amman (32.11, 36.06) in Jordan: $isAmmanInJordan');
|
||||
|
||||
// Damascus coordinates (example): 33.5138, 36.2765
|
||||
final damascus = LatLng(33.5138, 36.2765);
|
||||
final isDamascusInJordan = CountryPolygons.isPointInPolygon(damascus, CountryPolygons.jordanBoundary);
|
||||
print('Damascus (33.51, 36.27) in Jordan: $isDamascusInJordan');
|
||||
}
|
||||
Reference in New Issue
Block a user