update
This commit is contained in:
@ -6,7 +6,7 @@ class ActionService{
|
||||
|
||||
static Future<Map<String, dynamic>> makeAction(int user_id, int location_id, bool wanttogo, bool like, bool checkin) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = "http://localhost:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
|
||||
String url = "http://container.intranet.sumasen.net:8100/api/makeaction/?user_id=${user_id}&location_id=${location_id}&wanttogo=${wanttogo}&like=${like}&checkin=${checkin}";
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -23,7 +23,7 @@ class ActionService{
|
||||
|
||||
static Future<List<dynamic>?> userAction(int user_id, int location_id) async {
|
||||
List<dynamic> cats = [];
|
||||
String url = 'http://localhost:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/useraction/?user_id=${user_id}&location_id=${location_id}';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -6,7 +6,7 @@ class AuthService{
|
||||
|
||||
static Future<Map<String, dynamic>> login(String email, String password) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = 'http://localhost:8100/api/login/';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/login/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -27,7 +27,7 @@ class AuthService{
|
||||
|
||||
static Future<Map<String, dynamic>> register(String email, String password) async {
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = 'http://localhost:8100/api/register/';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/register/';
|
||||
final http.Response response = await http.post(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
@ -5,9 +5,12 @@ import 'package:http/http.dart' as http;
|
||||
|
||||
class CatService{
|
||||
|
||||
static Future<List<dynamic>?> loadCats() async {
|
||||
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 url = 'http://localhost:8100/api/cats/';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/cats/?ln1=${lon1}&la1=${lat1}&ln2=${lon2}&la2=${lat2}&ln3=${lon3}&la3=${lat3}&ln4=${lon4}&la4=${lat4}';
|
||||
|
||||
//String url = 'http://container.intranet.sumasen.net:8100/api/cats/';
|
||||
print("---- cat url is ${url}");
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -26,3 +29,7 @@ class CatService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@ class DestinationService{
|
||||
|
||||
static Future<List<dynamic>> getDestinations(int user_id) async {
|
||||
List<dynamic> cats = [];
|
||||
String url = "http://localhost:8100/api/destinations/?user_id=${user_id}";
|
||||
String url = "http://container.intranet.sumasen.net:8100/api/destinations/?user_id=${user_id}";
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -22,7 +22,7 @@ class DestinationService{
|
||||
|
||||
static Future<int> updateOrder(int action_id, int order, String dir) async {
|
||||
int cats = 0;
|
||||
String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
|
||||
String url = "http://container.intranet.sumasen.net:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
|
||||
@ -7,7 +7,7 @@ class LocationLineService{
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeature? fs;
|
||||
|
||||
String url = 'http://localhost:8100/api/location_line/';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/location_line/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -7,7 +7,7 @@ class LocationPolygonervice{
|
||||
final geo = GeoJson();
|
||||
GeoJsonFeature? fs;
|
||||
|
||||
String url = 'http://localhost:8100/api/location_polygon/';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/location_polygon/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
44
lib/services/maxtrix_service.dart
Normal file
44
lib/services/maxtrix_service.dart
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
||||
class MatrixService{
|
||||
|
||||
static Future<Map<String, dynamic>> getDestinations(List<dynamic> destinations) async {
|
||||
|
||||
String locs = "";
|
||||
String origin = "";
|
||||
int i = 0;
|
||||
for(Map<String, dynamic> loc in destinations){
|
||||
|
||||
if(i==0){
|
||||
origin = "${loc["location"]["geometry"]["coordinates"][0][1]}, ${loc["location"]["geometry"]["coordinates"][0][0]}";
|
||||
}
|
||||
|
||||
print("lat is ${loc["location"]["geometry"]["coordinates"][0][1]}, long is ${loc["location"]["geometry"]["coordinates"][0][0]}");
|
||||
locs += "${loc["location"]["geometry"]["coordinates"][0][1]}, ${loc["location"]["geometry"]["coordinates"][0][0]}|";
|
||||
i++;
|
||||
}
|
||||
|
||||
//print(locs);
|
||||
|
||||
Map<String, dynamic> cats = {};
|
||||
String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&origins=${origin}&key=AIzaSyBLgnwft3py6c4YkT-MxZ9y4zYGFgAEmRk";
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ class PerfectureService{
|
||||
|
||||
static Future<List<dynamic>?> loadPerfectures() async {
|
||||
List<dynamic> perfs = [];
|
||||
String url = 'http://localhost:8100/api/perf_main/';
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/perf_main/';
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -22,7 +22,7 @@ class PerfectureService{
|
||||
|
||||
static Future<List<dynamic>?> loadSubPerfectures(String sub) async {
|
||||
List<dynamic> perfs = [];
|
||||
String url = 'http://localhost:8100/api/subperfinmain/?perf=' + sub;
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/subperfinmain/?perf=' + sub;
|
||||
//String url = 'http://container.intranet.sumasen.net:8100/api/insubperf/?perf=' + sub;
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
@ -40,7 +40,7 @@ class PerfectureService{
|
||||
|
||||
static Future<List<dynamic>?> getMainPerfExt(String id) async {
|
||||
List<dynamic> perfs = [];
|
||||
String url = 'http://localhost:8100/api/mainperfext/?perf=' + id;
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/mainperfext/?perf=' + id;
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
@ -57,7 +57,7 @@ class PerfectureService{
|
||||
|
||||
static Future<List<dynamic>?> getSubExt(String id) async {
|
||||
List<dynamic> perfs = [];
|
||||
String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id;
|
||||
String url = 'http://container.intranet.sumasen.net:8100/api/perfext/?sub_perf=' + id;
|
||||
final response = await http.get(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
|
||||
Reference in New Issue
Block a user