71 lines
2.1 KiB
Dart
71 lines
2.1 KiB
Dart
import 'dart:convert';
|
|
|
|
import 'package:geojson/geojson.dart';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
class LocationService{
|
|
|
|
static Future<GeoJsonFeatureCollection?> loadLocations() async {
|
|
String url = 'http://localhost:8100/api/location/';
|
|
final response = await http.get(Uri.parse(url),
|
|
headers: <String, String>{
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
return featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
|
|
String url = "";
|
|
if(cat.isNotEmpty){
|
|
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
|
|
}
|
|
else{
|
|
url = 'http://localhost:8100/api/inperf/?perf=' + perfecture;
|
|
}
|
|
//String url = 'http://localhost:8100/api/inperf/?perf=' + perfecture + '&cat=' + cat;
|
|
final response = await http.get(Uri.parse(url),
|
|
headers: <String, String>{
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
//print(cc);
|
|
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
|
|
String url = "";
|
|
if(cat.isNotEmpty){
|
|
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture + '&cat=' + cat;
|
|
}
|
|
else{
|
|
url = 'http://localhost:8100/api/insubperf?subperf=' + subperfecture;
|
|
}
|
|
final response = await http.get(Uri.parse(url),
|
|
headers: <String, String>{
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
},
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
//print(cc);
|
|
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
|
}
|
|
return null;
|
|
}
|
|
|
|
|
|
|
|
} |