This commit is contained in:
Mohamed Nouffer
2022-05-18 19:09:26 +05:30
parent 80a976baa0
commit ee0440e6b6
26 changed files with 411 additions and 59 deletions

View File

@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
String url = 'http://localhost:8100/api/location/';
String url = 'http://container.intranet.sumasen.net:8100/api/location/';
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
@ -23,11 +23,12 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
String url = "";
if(cat.isNotEmpty){
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
}
else{
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture;
}
//print("----- url ---- ${url} --- ${cat}");
//String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
final response = await http.get(Uri.parse(url),
headers: <String, String>{
@ -47,10 +48,11 @@ class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
String url = "";
if(cat.isNotEmpty){
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
}
else{
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture;
print("------ loading location in sub----");
url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture;
}
final response = await http.get(Uri.parse(url),
headers: <String, String>{
@ -67,5 +69,38 @@ class LocationService{
}
static Future<GeoJsonFeatureCollection?> loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async {
String url = "";
print("cat is ----- ${cat}");
if(cat.isNotEmpty){
url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}' + '&cat=' + cat;
}
else{
url = 'http://container.intranet.sumasen.net:8100/api/inbound?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
}
print("----url --- ${url}");
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 500) {
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
}
if (response.statusCode == 200) {
GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes));
if(cc.collection.isEmpty){
return null;
}
else{
return cc;
}
}
return null;
}
}