optimized
This commit is contained in:
@ -2,23 +2,21 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
|
||||
|
||||
class ActionService{
|
||||
|
||||
static Future<Map<String, dynamic>> makeAction(int userId, int locationId, bool wanttogo, bool like, bool checkin) async {
|
||||
print("----- action is ---- $like-- $wanttogo-- $checkin");
|
||||
class ActionService {
|
||||
static Future<Map<String, dynamic>> makeAction(int userId, int locationId,
|
||||
bool wanttogo, bool like, bool checkin) async {
|
||||
//print("----- action is ---- $like-- $wanttogo-- $checkin");
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = "$serverUrl/api/makeaction/?user_id=$userId&location_id=$locationId&wanttogo=$wanttogo&like=$like&checkin=$checkin";
|
||||
String url =
|
||||
"$serverUrl/api/makeaction/?user_id=$userId&location_id=$locationId&wanttogo=$wanttogo&like=$like&checkin=$checkin";
|
||||
//String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
|
||||
print('++++++++$url');
|
||||
print("url is ------ $url");
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
);
|
||||
//print('++++++++$url');
|
||||
//print("url is ------ $url");
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
@ -26,27 +24,23 @@ class ActionService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
static Future<List<dynamic>?> userAction(int userId, int locationId) async {
|
||||
static Future<List<dynamic>?> userAction(int userId, int locationId) async {
|
||||
List<dynamic> cats = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/useraction/?user_id=$userId&location_id=$locationId';
|
||||
print('++++++++$url');
|
||||
String url =
|
||||
'$serverUrl/api/useraction/?user_id=$userId&location_id=$locationId';
|
||||
//print('++++++++$url');
|
||||
//String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,69 @@
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/model/auth_user.dart';
|
||||
|
||||
import '../utils/const.dart';
|
||||
|
||||
class AuthService {
|
||||
Future<AuthUser?> userLogin(String email, String password) async {
|
||||
final serverUrl = ConstValues.currentServer();
|
||||
final url = '$serverUrl/api/login/';
|
||||
|
||||
class AuthService{
|
||||
try {
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body:
|
||||
jsonEncode(<String, String>{'email': email, 'password': password}),
|
||||
);
|
||||
switch (response.statusCode) {
|
||||
case 200:
|
||||
final data = json.decode(utf8.decode(response.bodyBytes));
|
||||
AuthUser user = AuthUser.fromMap(data["user"]);
|
||||
final String token = data["token"];
|
||||
user.auth_token = token;
|
||||
return user;
|
||||
default:
|
||||
return null;
|
||||
//throw Exception(response.reasonPhrase);
|
||||
}
|
||||
} on Exception catch (_) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> changePassword(String oldpassword, String newpassword, String token) async {
|
||||
Future<AuthUser?> userFromToken(String token) async {
|
||||
final serverUrl = ConstValues.currentServer();
|
||||
final url = '$serverUrl/api/user/';
|
||||
try {
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
});
|
||||
switch (response.statusCode) {
|
||||
case 200:
|
||||
final data = json.decode(utf8.decode(response.bodyBytes));
|
||||
AuthUser user = AuthUser.fromMap(data);
|
||||
user.auth_token = token;
|
||||
return user;
|
||||
default:
|
||||
return null;
|
||||
//throw Exception(response.reasonPhrase);
|
||||
}
|
||||
} on Exception catch (_) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> changePassword(
|
||||
String oldpassword, String newpassword, String token) async {
|
||||
Map<String, dynamic> changePassword = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/change-password/';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
final http.Response response = await http.put(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -24,28 +77,25 @@ class AuthService{
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
changePassword = json.decode(utf8.decode(response.bodyBytes));
|
||||
changePassword = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return changePassword;
|
||||
}
|
||||
|
||||
|
||||
static Future<Map<String, dynamic>> login(String email, String password) async {
|
||||
print("------- in logged email $email pwd $password ###### --------");
|
||||
static Future<Map<String, dynamic>> login(
|
||||
String email, String password) async {
|
||||
//print("------- in logged email $email pwd $password ###### --------");
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/login/';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
//String url = 'http://localhost:8100/api/login/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'email': email,
|
||||
'password': password
|
||||
}),
|
||||
body: jsonEncode(<String, String>{'email': email, 'password': password}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@ -54,41 +104,36 @@ class AuthService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
static Future<Map<String, dynamic>> register(String email, String password) async {
|
||||
static Future<Map<String, dynamic>> register(
|
||||
String email, String password) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/register/';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'email': email,
|
||||
'password': password
|
||||
}),
|
||||
body: jsonEncode(<String, String>{'email': email, 'password': password}),
|
||||
);
|
||||
print(response.body);
|
||||
//print(response.body);
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> deleteUser(String token) async {
|
||||
static Future<Map<String, dynamic>> deleteUser(String token) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/delete-account/';
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
}
|
||||
);
|
||||
//print('++++++++$url');
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
@ -96,50 +141,45 @@ class AuthService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
static Future<List<dynamic>?> UserDetails(int userid) async {
|
||||
static Future<List<dynamic>?> userDetails(int userid) async {
|
||||
List<dynamic> cats = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/userdetials?user_id=$userid';
|
||||
print('++++++++$url');
|
||||
print("---- UserDetails url is $url");
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
//print("---- UserDetails url is $url");
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Future<List<dynamic>?> userForToken(String token) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/user/';
|
||||
print('++++++++$url');
|
||||
print("---- UserDetails url is $url");
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
//print("---- UserDetails url is $url");
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
print("--- eeeeee $cats ----");
|
||||
//print("--- eeeeee $cats ----");
|
||||
}
|
||||
return [{"user":cats, "token":token}];
|
||||
return [
|
||||
{"user": cats, "token": token}
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -3,50 +3,42 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
|
||||
|
||||
class CatService{
|
||||
|
||||
static Future<List<dynamic>?> loadCats(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4) async {
|
||||
class CatService {
|
||||
static Future<List<dynamic>?> loadCats(double lat1, double lon1, double lat2,
|
||||
double lon2, double lat3, double lon3, double lat4, double lon4) async {
|
||||
List<dynamic> cats = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/cats/?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
String url =
|
||||
'$serverUrl/api/cats/?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
static Future<List<dynamic>?> loadCatByCity(String cityname)async {
|
||||
static Future<List<dynamic>?> loadCatByCity(String cityname) async {
|
||||
List<dynamic> cats = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/catbycity/?$cityname';
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -8,20 +8,16 @@ import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
|
||||
import '../utils/const.dart';
|
||||
|
||||
|
||||
class DestinationService{
|
||||
|
||||
static Future<List<dynamic>> getDestinations(int userId) async {
|
||||
class DestinationService {
|
||||
static Future<List<dynamic>> getDestinations(int userId) async {
|
||||
List<dynamic> cats = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = "$serverUrl/api/destinations/?user_id=$userId";
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
);
|
||||
//print('++++++++$url');
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
@ -29,36 +25,33 @@ class DestinationService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> deleteDestination(int destId) async {
|
||||
static Future<Map<String, dynamic>> deleteDestination(int destId) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = "$serverUrl/api/delete_destination/?dest_id=$destId";
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
);
|
||||
//print('++++++++$url');
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
print("####### ---- $cats");
|
||||
//print("####### ---- $cats");
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<int> updateOrder(int actionId, int order, String dir) async {
|
||||
static Future<int> updateOrder(int actionId, int order, String dir) async {
|
||||
int cats = 0;
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = "$serverUrl/api/updateorder/?user_action_id=$actionId&order=$order&dir=$dir";
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
);
|
||||
String url =
|
||||
"$serverUrl/api/updateorder/?user_action_id=$actionId&order=$order&dir=$dir";
|
||||
//print('++++++++$url');
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
@ -66,23 +59,25 @@ class DestinationService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations, Map<String, dynamic> mtx) async{
|
||||
static Future<List<PointLatLng>>? getDestinationLine(
|
||||
List<Destination> destinations, Map<String, dynamic> mtx) async {
|
||||
PolylinePoints polylinePoints = PolylinePoints();
|
||||
|
||||
if(destinations.isEmpty){
|
||||
if (destinations.isEmpty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
//print("##### @@@@@ ${destinations[0].lat}");
|
||||
PointLatLng origin = PointLatLng(destinations[0].lat!, destinations[0].lon!);
|
||||
PointLatLng dest = PointLatLng(destinations[destinations.length -1].lat!, destinations[destinations.length -1].lon!);
|
||||
|
||||
PointLatLng origin =
|
||||
PointLatLng(destinations[0].lat!, destinations[0].lon!);
|
||||
PointLatLng dest = PointLatLng(destinations[destinations.length - 1].lat!,
|
||||
destinations[destinations.length - 1].lon!);
|
||||
|
||||
List<PolylineWayPoint> wayPoints = [];
|
||||
int i=0;
|
||||
for(dynamic d in destinations){
|
||||
if(i == 0 || i == (destinations.length -1)){
|
||||
i+=1;
|
||||
int i = 0;
|
||||
for (dynamic d in destinations) {
|
||||
if (i == 0 || i == (destinations.length - 1)) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
double la = d.lat;
|
||||
@ -90,39 +85,36 @@ class DestinationService{
|
||||
|
||||
int j = 0;
|
||||
|
||||
PolylineWayPoint pwp = PolylineWayPoint(location: "$la,$ln", stopOver: false);
|
||||
|
||||
PolylineWayPoint pwp =
|
||||
PolylineWayPoint(location: "$la,$ln", stopOver: false);
|
||||
|
||||
//print("----- UUUUUU ${pwp}");
|
||||
//PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]);
|
||||
wayPoints.add(pwp);
|
||||
i+=1;
|
||||
i += 1;
|
||||
j += 4;
|
||||
}
|
||||
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
int travMode = destinationController.travelMode.value;
|
||||
String _mode = "WALKING";
|
||||
if(travMode == 1){
|
||||
//_mode = TravelMode.driving;
|
||||
_mode = "DRIVING";
|
||||
}
|
||||
else if(travMode == 2) {
|
||||
//_mode = TravelMode.transit;
|
||||
_mode = "TRANSIT";
|
||||
}
|
||||
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
// int travMode = destinationController.travelMode.value;
|
||||
// String mode = "WALKING";
|
||||
// if (travMode == 1) {
|
||||
// //_mode = TravelMode.driving;
|
||||
// mode = "DRIVING";
|
||||
// } else if (travMode == 2) {
|
||||
// //_mode = TravelMode.transit;
|
||||
// mode = "TRANSIT";
|
||||
// }
|
||||
|
||||
//PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186));
|
||||
Map<String, dynamic> pl = destinationController.matrix["routes"][0]["overview_polyline"];
|
||||
Map<String, dynamic> pl =
|
||||
destinationController.matrix["routes"][0]["overview_polyline"];
|
||||
List<PointLatLng> result = polylinePoints.decodePolyline(pl["points"]);
|
||||
//List<PointLatLng> result = polylinePoints.decodePolyline("qkyvEq`z`Yp@DBMr@XL@Td@Eb@PREd@IFe@rKIzCY|GEvCBzCHvS@xC?HnBHtBHlBFnBFhGRtDVW~BE`@ICHLk@dE_ClPgAtHu@bFsAhPg@~Ge@bFaEtg@kEpi@oCd\\w@nIw@hGe@fBy@nBqAjC{@zBgBtFOd@M@Wv@i@`BQf@ITKCuE`@yDZqBRCHa@DKG_AHwBRiBR_Fp@y@LYBY]M@KJo@v@M@cAGoGN_Cx@}Cf@}@@mM~@qF`@gCLwBj@sBrAeAhAsAtCoF|MmAbD{@fBwAdBw@p@_Ax@BFOHAl@?`@MAQCEAOIQSaBx@{Ah@eATsAHSB?d@A`D?f@IdWy@AS??V?|BCJ}@?cA?k@Au@wBqDuKQaACg@z@gELg@GK~@uEp@{A@q@y@CHwFHcG?KDqCDK^ABABEH{AE{B{@_Ho@uFIaBFQhBaC@SQSg@k@g@q@Yw@qA{De@}B]uDCsAMEWDqAFu@@^A@TDjA@vDA`CETK|AEtAIFY@o@ALpBZ~HBlCBn@EDGPu@pASJO`@Qf@?ROr@K?qDLHnEUTsDNkENYB{Ab@I^?zA}CrCkBfBw@t@@LwA`Bo@r@eGvD}BrAGGuAj@[?i@rBVi@P}@T?F?^MxDuBhDsBzAcAn@s@zCgDAI~A{A|CsC?{A?UHItA_@DCXC~J_@TUIoEvDKTm@?Y^iALIb@k@f@aAE}AA_BC{@\\Cv@CxAEj@ExCwDDc@CYFANCh@WHEIIRQhB}B|C_E\\w@Hq@JE?a@O}CGkAIwEGmDEmDAKLA^?A}@C{@?e@E_DFQNi@LcB\\eBPsADGKOEWBOH[GCPs@Pq@\\cANs@^q@jAu@fCqAf@]HCXoCV_BVmAZmBVcDBeCCgDAaB?s@RE?aCCaEAyHAoDd@EJiD@_@AaAj@A\\A?Gp@@r@oBXm@LQ?IEy@Fy@tA[n@Gj@Tz@[~ACdAAx@Lp@Kr@]hAa@HAQoCMwCSwGSiGK_CCCKaBCgCOoCOgECwGB_OB{JHkBEmC?yCDyFF{QFue@BsYByE?oAEgAByLBiL?gLBuGXsEd@cCNA?OHa@jAuCn@eAtCyDh@k@v@EvBKr@EEkACUKaC?G~@gAlCeDFBT[jFeGZAfBEh@UpBM`AEMaFjFYIhE?hEPpCJzAPt@Fj@GNUFu@N[FyBbAuB`@_@LEIOB}@HUBQFk@FcAACGQA}@Bi@F@F[Dc@D[FQHELGhBMtDGR?D");
|
||||
//PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: _mode, wayPoints: wayPoints);
|
||||
|
||||
|
||||
//print("#####@@@@@ ${result.points}");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -10,308 +10,312 @@ import 'dart:convert';
|
||||
|
||||
import '../utils/const.dart';
|
||||
|
||||
//
|
||||
//
|
||||
// Rog type 0- start 1- checkin 2- goal
|
||||
//
|
||||
//
|
||||
|
||||
class ExternalService {
|
||||
static final ExternalService _instance = ExternalService._internal();
|
||||
|
||||
factory ExternalService(){
|
||||
factory ExternalService() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
ExternalService._internal();
|
||||
|
||||
String getFormatedTime(DateTime datetime){
|
||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
||||
String getFormatedTime(DateTime datetime) {
|
||||
return DateFormat('yyyy-MM-dd HH:mm:ss').format(datetime);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> StartRogaining() async {
|
||||
|
||||
Future<Map<String, dynamic>> startRogaining() async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
Map<String, dynamic> _res = {};
|
||||
Map<String, dynamic> res = {};
|
||||
|
||||
int userId = indexController.currentUser[0]["user"]["id"];
|
||||
//print("--- Pressed -----");
|
||||
String _team = indexController.currentUser[0]["user"]['team_name'];
|
||||
String team = indexController.currentUser[0]["user"]['team_name'];
|
||||
//print("--- _team : ${_team}-----");
|
||||
String _event_code = indexController.currentUser[0]["user"]["event_code"];
|
||||
String eventCode = indexController.currentUser[0]["user"]["event_code"];
|
||||
|
||||
if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
||||
if (indexController.connectionStatusName.value != "wifi" &&
|
||||
indexController.connectionStatusName.value != "mobile") {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog _rog = Rog(
|
||||
id:1,
|
||||
team_name: _team,
|
||||
event_code : _event_code,
|
||||
user_id: userId,
|
||||
cp_number: -1,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: null,
|
||||
rog_action_type: 0
|
||||
);
|
||||
db.insertRogaining(_rog);
|
||||
}
|
||||
else {
|
||||
Rog rog = Rog(
|
||||
id: 1,
|
||||
team_name: team,
|
||||
event_code: eventCode,
|
||||
user_id: userId,
|
||||
cp_number: -1,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: null,
|
||||
rog_action_type: 0);
|
||||
db.insertRogaining(rog);
|
||||
} else {
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/start_from_rogapp';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': _team,
|
||||
'event_code': _event_code
|
||||
}),
|
||||
body: jsonEncode(
|
||||
<String, String>{'team_name': team, 'event_code': eventCode}),
|
||||
);
|
||||
|
||||
print("---- start rogianing api status ---- ${response.statusCode}");
|
||||
//print("---- start rogianing api status ---- ${response.statusCode}");
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response.bodyBytes));
|
||||
print('----_res : $_res ----');
|
||||
res = json.decode(utf8.decode(response.bodyBytes));
|
||||
//print('----_res : $res ----');
|
||||
}
|
||||
}
|
||||
return _res;
|
||||
return res;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> makeCheckpoint(int userId, String token, String checkinTime, String teamname, int cp, String eventcode, String imageurl) async {
|
||||
print("~~~~ in API call function ~~~~");
|
||||
print("~~~~ cp is ${cp} ~~~~");
|
||||
Future<Map<String, dynamic>> makeCheckpoint(
|
||||
int userId,
|
||||
String token,
|
||||
String checkinTime,
|
||||
String teamname,
|
||||
int cp,
|
||||
String eventcode,
|
||||
String imageurl) async {
|
||||
// print("~~~~ in API call function ~~~~");
|
||||
// print("~~~~ cp is $cp ~~~~");
|
||||
//print("--cpcp-- ${cp}");
|
||||
Map<String, dynamic> _res = {};
|
||||
Map<String, dynamic> res = {};
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/checkin_from_rogapp';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
|
||||
if(imageurl != null){
|
||||
if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
||||
if (imageurl != null) {
|
||||
if (indexController.connectionStatusName.value != "wifi" &&
|
||||
indexController.connectionStatusName.value != "mobile") {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog _rog = Rog(
|
||||
id:1,
|
||||
Rog rog = Rog(
|
||||
id: 1,
|
||||
team_name: teamname,
|
||||
event_code : eventcode,
|
||||
event_code: eventcode,
|
||||
user_id: userId,
|
||||
cp_number: cp,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: imageurl,
|
||||
rog_action_type: 1,
|
||||
);
|
||||
db.insertRogaining(_rog);
|
||||
}
|
||||
else {
|
||||
db.insertRogaining(rog);
|
||||
} else {
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url1 = "$serverUrl/api/checkinimage/";
|
||||
final im1Bytes = File(imageurl).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
print("~~~~ before calling api 1 ~~~~");
|
||||
//print("~~~~ before calling api 1 ~~~~");
|
||||
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
|
||||
body: jsonEncode(<String, String>{
|
||||
'user' : userId.toString(),
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'checkinimage' : im1_64,
|
||||
'checkintime' : checkinTime,
|
||||
'cp_number' : cp.toString()
|
||||
}),
|
||||
);
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
|
||||
body: jsonEncode(<String, String>{
|
||||
'user': userId.toString(),
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'checkinimage': im1_64,
|
||||
'checkintime': checkinTime,
|
||||
'cp_number': cp.toString()
|
||||
}),
|
||||
);
|
||||
|
||||
_res = json.decode(utf8.decode(response.bodyBytes));
|
||||
print("~~~~ api1 result ${_res} ~~~~");
|
||||
//print("-----@@@@@ checkin $_res -----");
|
||||
res = json.decode(utf8.decode(response.bodyBytes));
|
||||
//print("~~~~ api1 result $res ~~~~");
|
||||
//print("-----@@@@@ checkin $_res -----");
|
||||
|
||||
if(response.statusCode == 201){
|
||||
print("~~~~ image from api1 ${_res["checkinimage"].toString()} ~~~~");
|
||||
//print('---- toekn is ${token} -----');
|
||||
print("~~~~ token is ${token} ~~~~");
|
||||
print("~~~~ before callling api2 ~~~~");
|
||||
final http.Response response2 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}),
|
||||
);
|
||||
var vv = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
print("~~~~ api 2 values ${vv} ~~~~");
|
||||
//print("--json-- $vv");
|
||||
//print("--- checnin response ${response2.statusCode}----");
|
||||
if (response2.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response2.bodyBytes));
|
||||
print('----checkin res _res : $_res ----');
|
||||
if(_res["status"] == "ERROR"){
|
||||
Get.snackbar("エラーがおきました", _res["detail"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
Get.snackbar("エラーがおきました", "サーバーに更新できませんでした");
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(indexController.connectionStatusName != "wifi" || indexController.connectionStatusName != "mobile"){
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog _rog = Rog(
|
||||
id:1,
|
||||
team_name: teamname,
|
||||
event_code : eventcode,
|
||||
user_id: userId,
|
||||
cp_number: cp,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: null,
|
||||
rog_action_type: 1,
|
||||
);
|
||||
db.insertRogaining(_rog);
|
||||
}
|
||||
else {
|
||||
final http.Response response3 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': ""
|
||||
}),
|
||||
);
|
||||
var vvv = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': _res["checkinimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
print("--json-- $vvv");
|
||||
print("--- checnin response ${response3.statusCode}----");
|
||||
if (response3.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response3.bodyBytes));
|
||||
print('----checkin res _res : $_res ----');
|
||||
}
|
||||
}
|
||||
}
|
||||
print("~~~~ done checkin ~~~~");
|
||||
return _res;
|
||||
}
|
||||
|
||||
|
||||
Future<Map<String, dynamic>> makeGoal(int userId, String token, String teamname, String image, String goalTime, String eventcode) async {
|
||||
Map<String, dynamic> _res2 = {};
|
||||
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
|
||||
//if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog _rog = Rog(
|
||||
id:1,
|
||||
team_name: teamname,
|
||||
event_code : eventcode,
|
||||
user_id: userId,
|
||||
cp_number: -1,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: image,
|
||||
rog_action_type: 1,
|
||||
);
|
||||
db.insertRogaining(_rog);
|
||||
// }
|
||||
// else{
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url1 = "$serverUrl/api/goalimage/";
|
||||
final im1Bytes = File(image).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
|
||||
body: jsonEncode(<String, String>{
|
||||
'user' : userId.toString(),
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goaltime' : goalTime,
|
||||
'goalimage' : im1_64,
|
||||
'cp_number' : "-1"
|
||||
}),
|
||||
);
|
||||
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/goal_from_rogapp';
|
||||
print('++++++++$url');
|
||||
if (response.statusCode == 201) {
|
||||
Map<String, dynamic> _res = json.decode(utf8.decode(response.bodyBytes));
|
||||
print('----_res : $_res ----');
|
||||
print('---- image url ${_res["goalimage"]} ----');
|
||||
if (response.statusCode == 201) {
|
||||
//print("~~~~ image from api1 ${res["checkinimage"].toString()} ~~~~");
|
||||
//print('---- toekn is ${token} -----');
|
||||
//print("~~~~ token is $token ~~~~");
|
||||
//print("~~~~ before callling api2 ~~~~");
|
||||
final http.Response response2 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goal_time' : goalTime,
|
||||
'image' : _res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}
|
||||
),
|
||||
);
|
||||
String rec = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goal_time' : goalTime,
|
||||
'image' : _res["goalimage"].toString().replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}
|
||||
);
|
||||
print("-- json -- $rec");
|
||||
print('----- response2 is $response2 --------');
|
||||
if (response2.statusCode == 200) {
|
||||
_res2 = json.decode(utf8.decode(response2.bodyBytes));
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': res["checkinimage"].toString().replaceAll(
|
||||
'http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}),
|
||||
);
|
||||
var vv = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': res["checkinimage"].toString().replaceAll(
|
||||
'http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
//print("~~~~ api 2 values $vv ~~~~");
|
||||
//print("--json-- $vv");
|
||||
//print("--- checnin response ${response2.statusCode}----");
|
||||
if (response2.statusCode == 200) {
|
||||
res = json.decode(utf8.decode(response2.bodyBytes));
|
||||
//print('----checkin res _res : $res ----');
|
||||
if (res["status"] == "ERROR") {
|
||||
Get.snackbar("エラーがおきました", res["detail"]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Get.snackbar("エラーがおきました", "サーバーに更新できませんでした");
|
||||
}
|
||||
}
|
||||
//}
|
||||
destinationController.resetRogaining();
|
||||
return _res2;
|
||||
}
|
||||
} else {
|
||||
if (indexController.connectionStatusName.value != "wifi" ||
|
||||
indexController.connectionStatusName.value != "mobile") {
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog rog = Rog(
|
||||
id: 1,
|
||||
team_name: teamname,
|
||||
event_code: eventcode,
|
||||
user_id: userId,
|
||||
cp_number: cp,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: null,
|
||||
rog_action_type: 1,
|
||||
);
|
||||
db.insertRogaining(rog);
|
||||
} else {
|
||||
final http.Response response3 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': ""
|
||||
}),
|
||||
);
|
||||
var vvv = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'cp_number': cp.toString(),
|
||||
'event_code': eventcode,
|
||||
'image': res["checkinimage"].toString().replaceAll(
|
||||
'http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
// print("--json-- $vvv");
|
||||
// print("--- checnin response ${response3.statusCode}----");
|
||||
if (response3.statusCode == 200) {
|
||||
res = json.decode(utf8.decode(response3.bodyBytes));
|
||||
//print('----checkin res _res : $res ----');
|
||||
}
|
||||
}
|
||||
}
|
||||
//print("~~~~ done checkin ~~~~");
|
||||
return res;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> makeGoal(int userId, String token,
|
||||
String teamname, String image, String goalTime, String eventcode) async {
|
||||
Map<String, dynamic> res2 = {};
|
||||
|
||||
static Future<Map<String, dynamic>> usersEventCode(String teamcode, String password) async {
|
||||
Map<String, dynamic> _res = {};
|
||||
String url = "https://rogaining.sumasen.net/gifuroge/check_event_code?zekken_number=$teamcode&password=$password";
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
//if(indexController.connectionStatusName != "wifi" && indexController.connectionStatusName != "mobile"){
|
||||
DatabaseHelper db = DatabaseHelper.instance;
|
||||
Rog rog = Rog(
|
||||
id: 1,
|
||||
team_name: teamname,
|
||||
event_code: eventcode,
|
||||
user_id: userId,
|
||||
cp_number: -1,
|
||||
checkintime: DateTime.now().toUtc().microsecondsSinceEpoch,
|
||||
image: image,
|
||||
rog_action_type: 1,
|
||||
);
|
||||
db.insertRogaining(rog);
|
||||
// }
|
||||
// else{
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url1 = "$serverUrl/api/goalimage/";
|
||||
final im1Bytes = File(image).readAsBytesSync();
|
||||
String im1_64 = base64Encode(im1Bytes);
|
||||
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url1),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
// 'id', 'user', 'goalimage', 'goaltime', 'team_name', 'event_code','cp_number'
|
||||
body: jsonEncode(<String, String>{
|
||||
'user': userId.toString(),
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goaltime': goalTime,
|
||||
'goalimage': im1_64,
|
||||
'cp_number': "-1"
|
||||
}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
_res = json.decode(utf8.decode(response.bodyBytes));
|
||||
String url = 'https://rogaining.sumasen.net/gifuroge/goal_from_rogapp';
|
||||
//print('++++++++$url');
|
||||
if (response.statusCode == 201) {
|
||||
Map<String, dynamic> res = json.decode(utf8.decode(response.bodyBytes));
|
||||
// print('----_res : $res ----');
|
||||
// print('---- image url ${res["goalimage"]} ----');
|
||||
final http.Response response2 = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goal_time': goalTime,
|
||||
'image': res["goalimage"].toString().replaceAll(
|
||||
'http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
}),
|
||||
);
|
||||
String rec = jsonEncode(<String, String>{
|
||||
'team_name': teamname,
|
||||
'event_code': eventcode,
|
||||
'goal_time': goalTime,
|
||||
'image': res["goalimage"]
|
||||
.toString()
|
||||
.replaceAll('http://localhost:8100', 'http://rogaining.sumasen.net')
|
||||
});
|
||||
// print("-- json -- $rec");
|
||||
// print('----- response2 is $response2 --------');
|
||||
if (response2.statusCode == 200) {
|
||||
res2 = json.decode(utf8.decode(response2.bodyBytes));
|
||||
}
|
||||
}
|
||||
return _res;
|
||||
}
|
||||
//}
|
||||
destinationController.resetRogaining();
|
||||
return res2;
|
||||
}
|
||||
|
||||
}
|
||||
static Future<Map<String, dynamic>> usersEventCode(
|
||||
String teamcode, String password) async {
|
||||
Map<String, dynamic> res = {};
|
||||
String url =
|
||||
"https://rogaining.sumasen.net/gifuroge/check_event_code?zekken_number=$teamcode&password=$password";
|
||||
//print('++++++++$url');
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
res = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,33 +3,30 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
|
||||
class LocationLineService{
|
||||
|
||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
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),
|
||||
//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;
|
||||
});
|
||||
|
||||
await geo.parse(response.body, verbose:true);
|
||||
await geo.parse(response.body, verbose: true);
|
||||
|
||||
return fs;
|
||||
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,34 +3,31 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
import '../utils/const.dart';
|
||||
|
||||
class LocationPolygonervice{
|
||||
|
||||
static Future<GeoJsonFeature?> loadLocationLines() async {
|
||||
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),
|
||||
//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;
|
||||
});
|
||||
|
||||
await geo.parse(response.body, verbose:true);
|
||||
await geo.parse(response.body, verbose: true);
|
||||
|
||||
return fs;
|
||||
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,8 +6,7 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/pages/index/index_controller.dart';
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
|
||||
class LocationService{
|
||||
|
||||
class LocationService {
|
||||
// static Future<GeoJsonFeatureCollection?> loadLocations() async {
|
||||
|
||||
// final IndexController indexController = Get.find<IndexController>();
|
||||
@ -34,42 +33,42 @@ class LocationService{
|
||||
// return null;
|
||||
// }
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsFor(String perfecture, String cat) async {
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsFor(
|
||||
String perfecture, 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';
|
||||
|
||||
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/inperf/?rog=$r&perf=' + perfecture + '&cat=' + cat;
|
||||
url = '$serverUrl/api/inperf/?rog=$r&perf=$perfecture&cat=$cat';
|
||||
} else {
|
||||
url = '$serverUrl/api/inperf/?perf=$perfecture&cat=$cat';
|
||||
}
|
||||
else {
|
||||
url = '$serverUrl/api/inperf/?perf=' + perfecture + '&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/inperf/?rog=$r&perf=$perfecture';
|
||||
} else {
|
||||
url = '$serverUrl/api/inperf/?perf=$perfecture';
|
||||
}
|
||||
}
|
||||
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/inperf/?rog=$r&perf=' + perfecture;
|
||||
}
|
||||
else {
|
||||
url = '$serverUrl/api/inperf/?perf=' + perfecture;
|
||||
}
|
||||
}
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//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));
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
//print(cc);
|
||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
@ -80,97 +79,104 @@ class LocationService{
|
||||
List<dynamic> ext = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/locsext/';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
final response = await http.post(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'token': token,
|
||||
})
|
||||
);
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
'Authorization': 'Token $token'
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'token': token,
|
||||
}));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
ext = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsSubFor(String subperfecture, String cat) async {
|
||||
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';
|
||||
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;
|
||||
url = '$serverUrl/api/insubperf?rog=$r&subperf=$subperfecture&cat=$cat';
|
||||
} else {
|
||||
url = '$serverUrl/api/insubperf?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';
|
||||
}
|
||||
}
|
||||
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),
|
||||
//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));
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
//print(cc);
|
||||
return cc; //featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsBound(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4, String cat) async {
|
||||
print("-------- in location for bound -------------");
|
||||
static Future<GeoJsonFeatureCollection?> loadLocationsBound(
|
||||
double lat1,
|
||||
double lon1,
|
||||
double lat2,
|
||||
double lon2,
|
||||
double lat3,
|
||||
double lon3,
|
||||
double lat4,
|
||||
double lon4,
|
||||
String cat) async {
|
||||
//print("-------- in location for bound -------------");
|
||||
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';
|
||||
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/inbound?rog=$r&grp=$grp&ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4' '&cat=' + cat;
|
||||
url =
|
||||
'$serverUrl/api/inbound?rog=$r&grp=$grp&ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4&cat=$cat';
|
||||
} else {
|
||||
url =
|
||||
'$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4&cat=$cat';
|
||||
}
|
||||
else{
|
||||
url = '$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4' '&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'];
|
||||
//print("-------- requested user group $grp -------------");
|
||||
url =
|
||||
'$serverUrl/api/inbound?rog=$r&grp=$grp&ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||
} else {
|
||||
url =
|
||||
'$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||
}
|
||||
}
|
||||
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'];
|
||||
print("-------- requested user group $grp -------------");
|
||||
url = '$serverUrl/api/inbound?rog=$r&grp=$grp&ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||
}
|
||||
else{
|
||||
url = '$serverUrl/api/inbound?ln1=$lon1&la1=$lat1&ln2=$lon2&la2=$lat2&ln3=$lon3&la3=$lat3&ln4=$lon4&la4=$lat4';
|
||||
}
|
||||
}
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
@ -181,51 +187,49 @@ class LocationService{
|
||||
}
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if(cc.collection.isEmpty){
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if (cc.collection.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
//print("---- feature got from server is ${cc.collection[0].properties} ------");
|
||||
return cc;
|
||||
return cc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
static Future<GeoJsonFeatureCollection?> loadCustomLocations(String name, String cat) async {
|
||||
static Future<GeoJsonFeatureCollection?> loadCustomLocations(
|
||||
String name, String cat) async {
|
||||
final IndexController indexController = Get.find<IndexController>();
|
||||
String url = "";
|
||||
if(cat == "-all-"){
|
||||
if (cat == "-all-") {
|
||||
cat = "";
|
||||
}
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
print("loadCustomLocations url is ----- $cat");
|
||||
if(cat.isNotEmpty){
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
|
||||
String r = _rog == true ? 'True': 'False';
|
||||
//print("loadCustomLocations url is ----- $cat");
|
||||
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/custom_area/?rog=$r&&cat=' + cat;
|
||||
url = '$serverUrl/api/custom_area/?rog=$r&&cat=$cat';
|
||||
} else {
|
||||
url = '$serverUrl/api/custom_area/?&cat=$cat';
|
||||
}
|
||||
else{
|
||||
url = '$serverUrl/api/custom_area/?&cat=' + cat;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(indexController.currentUser.isNotEmpty){
|
||||
bool _rog = indexController.currentUser[0]['user']['is_rogaining'];
|
||||
String r = _rog == true ? 'True': 'False';
|
||||
} 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/customarea?rog=$r&name=$name';
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
url = '$serverUrl/api/customarea?name=$name';
|
||||
}
|
||||
}
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
@ -236,18 +240,14 @@ class LocationService{
|
||||
}
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
GeoJsonFeatureCollection cc = await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if(cc.collection.isEmpty){
|
||||
GeoJsonFeatureCollection cc =
|
||||
await featuresFromGeoJson(utf8.decode(response.bodyBytes));
|
||||
if (cc.collection.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
else{
|
||||
return cc;
|
||||
} else {
|
||||
return cc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,73 +1,66 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/model/destination.dart';
|
||||
import 'package:rogapp/pages/destination/destination_controller.dart';
|
||||
|
||||
|
||||
class MatrixService{
|
||||
|
||||
static Future<Map<String, dynamic>> getDestinations(List<Destination> destinations) async {
|
||||
|
||||
final DestinationController destinationController = Get.find<DestinationController>();
|
||||
class MatrixService {
|
||||
static Future<Map<String, dynamic>> getDestinations(
|
||||
List<Destination> destinations) async {
|
||||
final DestinationController destinationController =
|
||||
Get.find<DestinationController>();
|
||||
|
||||
String locs = "";
|
||||
String origin = "";
|
||||
String destination = "";
|
||||
int i = 0;
|
||||
for(Destination d in destinations){
|
||||
for (Destination d in destinations) {
|
||||
//print("---- getting matrix for $d ------------");
|
||||
|
||||
print("---- getting matrix for $d ------------");
|
||||
|
||||
if(i==0){
|
||||
if (i == 0) {
|
||||
origin = "${d.lat}, ${d.lon}";
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i == (destinations.length - 1)){
|
||||
if (i == (destinations.length - 1)) {
|
||||
destination = "${d.lat}, ${d.lon}";
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
print("lat is ${d.lat}, long is ${d.lon}");
|
||||
//print("lat is ${d.lat}, long is ${d.lon}");
|
||||
locs += "${d.lat}, ${d.lon}|";
|
||||
i++;
|
||||
}
|
||||
|
||||
locs = "optimize:false|$locs";
|
||||
|
||||
String _mode = "walking";
|
||||
String mode = "walking";
|
||||
switch (destinationController.travelMode.value) {
|
||||
case 1:
|
||||
_mode = "driving";
|
||||
mode = "driving";
|
||||
break;
|
||||
case 2:
|
||||
_mode = "transit";
|
||||
break;
|
||||
mode = "transit";
|
||||
break;
|
||||
default:
|
||||
_mode = "walking";
|
||||
mode = "walking";
|
||||
break;
|
||||
}
|
||||
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = "https://maps.googleapis.com/maps/api/directions/json?destination=$destination&mode=$_mode&waypoints=$locs&origin=$origin&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
|
||||
print('++++++++$url');
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
}
|
||||
);
|
||||
String url =
|
||||
"https://maps.googleapis.com/maps/api/directions/json?destination=$destination&mode=$mode&waypoints=$locs&origin=$origin&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
|
||||
//print('++++++++$url');
|
||||
final http.Response response =
|
||||
await http.get(Uri.parse(url), headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
});
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
cats = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -2,22 +2,20 @@ import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
|
||||
|
||||
class PerfectureService{
|
||||
|
||||
class PerfectureService {
|
||||
static Future<List<dynamic>?> loadPerfectures() async {
|
||||
List<dynamic> perfs = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/perf_main/';
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return perfs;
|
||||
@ -26,35 +24,34 @@ class PerfectureService{
|
||||
static Future<List<dynamic>?> loadSubPerfectures(String area) async {
|
||||
List<dynamic> perfs = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/subperfinmain/?area=' + area;
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
String url = '$serverUrl/api/subperfinmain/?area=$area';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return perfs;
|
||||
}
|
||||
|
||||
|
||||
static Future<List<dynamic>?> getMainPerfExt(String id) async {
|
||||
List<dynamic> perfs = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/mainperfext/?perf=' + id;
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
String url = '$serverUrl/api/mainperfext/?perf=$id';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return perfs;
|
||||
@ -63,16 +60,16 @@ class PerfectureService{
|
||||
static Future<List<dynamic>?> loadGifuAreas(String perf) async {
|
||||
List<dynamic> perfs = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/allgifuareas/?perf=' + perf;
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
String url = '$serverUrl/api/allgifuareas/?perf=$perf';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return perfs;
|
||||
@ -82,40 +79,35 @@ class PerfectureService{
|
||||
List<dynamic> perfs = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/customareanames';
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return perfs;
|
||||
}
|
||||
|
||||
|
||||
static Future<List<dynamic>?> getSubExt(String id) async {
|
||||
List<dynamic> perfs = [];
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/perfext/?sub_perf=' + id;
|
||||
print('++++++++$url');
|
||||
final response = await http.get(Uri.parse(url),
|
||||
String url = '$serverUrl/api/perfext/?sub_perf=$id';
|
||||
//print('++++++++$url');
|
||||
final response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
perfs = json.decode(utf8.decode(response.bodyBytes));
|
||||
}
|
||||
return perfs;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,27 +1,22 @@
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:rogapp/utils/const.dart';
|
||||
|
||||
|
||||
class TrackingService {
|
||||
|
||||
static Future<Map<String, dynamic>> addTrack(String userId, double lat, double lon) async {
|
||||
static Future<Map<String, dynamic>> addTrack(
|
||||
String userId, double lat, double lon) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String serverUrl = ConstValues.currentServer();
|
||||
String url = '$serverUrl/api/track/';
|
||||
print('++++++++$url');
|
||||
//print('++++++++$url');
|
||||
final geom = '{"type": "MULTIPOINT", "coordinates": [[$lon, $lat]]}';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(<String, String>{
|
||||
'user_id': userId,
|
||||
'geom': geom
|
||||
}),
|
||||
body: jsonEncode(<String, String>{'user_id': userId, 'geom': geom}),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
@ -29,5 +24,4 @@ class TrackingService {
|
||||
}
|
||||
return cats;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user