map updated to 6
This commit is contained in:
@ -1,32 +1,32 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
// import 'package:geojson/geojson.dart';
|
||||
// import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
// import '../utils/const.dart';
|
||||
|
||||
class LocationLineService {
|
||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeature? fs;
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/location_line/';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
// class LocationLineService {
|
||||
// static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
// final geo = GeoJson();
|
||||
// GeoJsonFeature? fs;
|
||||
// String serverUrl = ConstValues.currentServer();
|
||||
// String url = '$serverUrl/api/location_line/';
|
||||
// //print('++++++++$url');
|
||||
// final response = await http.get(
|
||||
// Uri.parse(url),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// );
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
geo.processedFeatures.listen((fst) {
|
||||
fs = fst;
|
||||
});
|
||||
// if (response.statusCode == 200) {
|
||||
// geo.processedFeatures.listen((fst) {
|
||||
// fs = fst;
|
||||
// });
|
||||
|
||||
await geo.parse(response.body, verbose: true);
|
||||
// await geo.parse(response.body, verbose: true);
|
||||
|
||||
return fs;
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
}
|
||||
// return fs;
|
||||
// } else {
|
||||
// throw Exception('Failed to create album.');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
// import 'package:geojson/geojson.dart';
|
||||
// import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
// import '../utils/const.dart';
|
||||
|
||||
class LocationPolygonervice {
|
||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeature? fs;
|
||||
// class LocationPolygonervice {
|
||||
// static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
// final geo = GeoJson();
|
||||
// GeoJsonFeature? fs;
|
||||
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/location_polygon/';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
// String serverUrl = ConstValues.currentServer();
|
||||
// String url = '$serverUrl/api/location_polygon/';
|
||||
// //print('++++++++$url');
|
||||
// final response = await http.get(
|
||||
// Uri.parse(url),
|
||||
// headers: <String, String>{
|
||||
// 'Content-Type': 'application/json; charset=UTF-8',
|
||||
// },
|
||||
// );
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
geo.processedFeatures.listen((fst) {
|
||||
fs = fst;
|
||||
});
|
||||
// if (response.statusCode == 200) {
|
||||
// geo.processedFeatures.listen((fst) {
|
||||
// fs = fst;
|
||||
// });
|
||||
|
||||
await geo.parse(response.body, verbose: true);
|
||||
// await geo.parse(response.body, verbose: true);
|
||||
|
||||
return fs;
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
}
|
||||
// return fs;
|
||||
// } else {
|
||||
// throw Exception('Failed to create album.');
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@ -1,39 +1,13 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:geojson/geojson.dart';
|
||||
import 'package:geojson_vi/geojson_vi.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
|
||||
class LocationService {
|
||||
// static Future<GeoJsonFeatureCollection?> loadLocations() async {
|
||||
|
||||
// final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
// String server_url = ConstValues.currentServer();
|
||||
// String url = "";
|
||||
// if(indexController.currentUser.length > 0){
|
||||
// url = '${server_url}/api/location/?is_rog=True';
|
||||
// }
|
||||
// else {
|
||||
// url = '${server_url}/api/location/';
|
||||
// }
|
||||
// //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(
|
||||
static Future<GeoJSONFeatureCollection?> loadLocationsFor(
|
||||
String perfecture, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
@ -67,8 +41,8 @@ class LocationService {
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
GeoJSONFeatureCollection cc =
|
||||
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||
//print(cc);
|
||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
@ -95,48 +69,7 @@ class LocationService {
|
||||
return ext;
|
||||
}
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(
|
||||
String subperfecture, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
if (cat.isNotEmpty) {
|
||||
if (indexController.currentUser.isNotEmpty) {
|
||||
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
|
||||
String r = rog == true ? 'True' : 'False';
|
||||
var grp = indexController.currentUser[0]['user']['event_code'];
|
||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture&cat=$cat';
|
||||
} else {
|
||||
url = '$serverUrl/api/insubperf?subperf=$subperfecture&cat=$cat';
|
||||
}
|
||||
} else {
|
||||
if (indexController.currentUser.isNotEmpty) {
|
||||
bool rog = indexController.currentUser[0]['user']['is_rogaining'];
|
||||
String r = rog == true ? 'True' : 'False';
|
||||
var grp = indexController.currentUser[0]['user']['event_code'];
|
||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture';
|
||||
} else {
|
||||
url = '$serverUrl/api/insubperf?subperf=$subperfecture';
|
||||
}
|
||||
}
|
||||
//print('++++++++$url');
|
||||
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?> loadLocationsBound(
|
||||
static Future<GeoJSONFeatureCollection?> loadLocationsBound(
|
||||
double lat1,
|
||||
double lon1,
|
||||
double lat2,
|
||||
@ -183,13 +116,15 @@ class LocationService {
|
||||
);
|
||||
|
||||
if (response.statusCode == 500) {
|
||||
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
return null; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if (cc.collection.isEmpty) {
|
||||
DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
GeoJSONFeatureCollection cc =
|
||||
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||
if (cc.features.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
//print("---- feature got from server is ${cc.collection[0].properties} ------");
|
||||
@ -199,7 +134,7 @@ class LocationService {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadCustomLocations(
|
||||
static Future<GeoJSONFeatureCollection?> loadCustomLocations(
|
||||
String name, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
@ -236,13 +171,13 @@ class LocationService {
|
||||
);
|
||||
|
||||
if (response.statusCode == 500) {
|
||||
return GeoJsonFeatureCollection(); //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
return null; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if (cc.collection.isEmpty) {
|
||||
GeoJSONFeatureCollection cc =
|
||||
GeoJSONFeatureCollection.fromJSON(utf8.decode(response.bodyBytes));
|
||||
if (cc.features.isEmpty) {
|
||||
return null;
|
||||
} else {
|
||||
return cc;
|
||||
|
||||
Reference in New Issue
Block a user