new change to use intaleq_map sdk 04-16-4
This commit is contained in:
@@ -107,4 +107,5 @@ class BoxName {
|
||||
static const String recentLocations = 'recentLocations';
|
||||
static const String tripData = 'tripData';
|
||||
static const String parentTripSelected = 'parentTripSelected';
|
||||
static const String styleVersion = 'styleVersion';
|
||||
}
|
||||
|
||||
@@ -91,17 +91,47 @@ class CountryPolygons {
|
||||
];
|
||||
|
||||
// دالة تُرجع رابط API بناءً على اسم الدولة
|
||||
static String getRoutingApiUrl(String countryName) {
|
||||
switch (countryName) {
|
||||
case 'Jordan':
|
||||
return 'https://routec.intaleq.xyz/route-jo';
|
||||
case 'Syria':
|
||||
return 'https://routec.intaleq.xyz/route';
|
||||
case 'Egypt':
|
||||
return 'https://routec.intaleq.xyz/route-eg';
|
||||
default:
|
||||
// الافتراضي في حالة لم يقع الموقع ضمن أي من المضلعات
|
||||
return 'https://routec.intaleq.xyz/route';
|
||||
// static String getRoutingApiUrl(String countryName) {
|
||||
// switch (countryName) {
|
||||
// case 'Jordan':
|
||||
// return 'https://routec.intaleq.xyz/route-jo';
|
||||
// case 'Syria':
|
||||
// return 'https://routec.intaleq.xyz/route';
|
||||
// case 'Egypt':
|
||||
// return 'https://routec.intaleq.xyz/route-eg';
|
||||
// default:
|
||||
// // الافتراضي في حالة لم يقع الموقع ضمن أي من المضلعات
|
||||
// return 'https://routec.intaleq.xyz/route';
|
||||
// }
|
||||
// }
|
||||
|
||||
/// دالة تحدد اسم الدولة (باللغة الإنجليزية للـ API) بناءً على الإحداثيات
|
||||
static String getCountryName(LatLng? point) {
|
||||
if (point == null) return "jordan";
|
||||
|
||||
if (_isPointInPolygon(point, jordanBoundary)) return "jordan";
|
||||
if (_isPointInPolygon(point, syriaBoundary)) return "syria";
|
||||
if (_isPointInPolygon(point, egyptBoundary)) return "egypt";
|
||||
|
||||
return "jordan"; // الافتراضي
|
||||
}
|
||||
|
||||
/// خوارزمية Ray Casting للتحقق من وقوع نقطة داخل مضلع
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user