Files
rog_app/lib/services/location_service.dart

58 lines
1.7 KiB
Dart
Raw Normal View History

2022-03-14 13:14:15 +05:30
import 'dart:convert';
2022-03-14 12:28:57 +05:30
import 'package:geojson/geojson.dart';
import 'package:http/http.dart' as http;
class LocationService{
static Future<GeoJsonFeatureCollection?> loadLocations() async {
2022-04-18 11:16:23 +05:30
String url = 'http://container.intranet.sumasen.net:8100/api/location/';
2022-03-14 12:28:57 +05:30
final response = await http.get(Uri.parse(url),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
2022-03-14 13:14:15 +05:30
return featuresFromGeoJson(utf8.decode(response.bodyBytes));
2022-03-14 12:28:57 +05:30
}
2022-04-17 11:45:21 +05:30
return null;
2022-03-14 12:28:57 +05:30
}
2022-03-30 16:19:18 +05:30
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture) async {
2022-04-18 11:16:23 +05:30
String url = 'http://container.intranet.sumasen.net:8100/api/inperf/?perf=' + perfecture;
2022-03-30 16:19:18 +05:30
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));
2022-04-17 11:45:21 +05:30
//print(cc);
2022-03-30 16:19:18 +05:30
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
}
2022-04-17 11:45:21 +05:30
return null;
}
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture) async {
2022-04-18 11:16:23 +05:30
String url = 'http://container.intranet.sumasen.net:8100/api/insubperf?subperf=' + subperfecture;
2022-04-17 11:45:21 +05:30
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;
2022-03-30 16:19:18 +05:30
}
2022-03-14 12:28:57 +05:30
}