update to routing

This commit is contained in:
Mohamed Nouffer
2022-09-29 15:32:33 +05:30
parent 0ca322e278
commit 0470e1f27f
11 changed files with 120 additions and 70 deletions

View File

@ -46,7 +46,7 @@ class DestinationController extends GetxController {
void getRoutePoints() { void getRoutePoints() {
indexController.routePoints = []; indexController.routePoints = [];
indexController.routePointLenght.value = 0; indexController.routePointLenght.value = 0;
DestinationService.getDestinationLine(destinations)?.then((value){ DestinationService.getDestinationLine(destinations, matrix)?.then((value){
indexController.routePoints = value; indexController.routePoints = value;
indexController.routePointLenght.value = indexController.routePoints.length; indexController.routePointLenght.value = indexController.routePoints.length;
}); });
@ -272,8 +272,8 @@ class DestinationController extends GetxController {
print("--------- destination controller populsting destinations ----------- ::::::"); print("--------- destination controller populsting destinations ----------- ::::::");
DatabaseHelper db = DatabaseHelper.instance; DatabaseHelper db = DatabaseHelper.instance;
destinations.clear();
db.getDestinations().then((value){ db.getDestinations().then((value){
destinations.clear();
destinationCount.value = 0; destinationCount.value = 0;
for(Destination d in value){ for(Destination d in value){
for(Destination s in currentSelectedDestinations){ for(Destination s in currentSelectedDestinations){

View File

@ -105,17 +105,17 @@ class DestnationPage extends StatelessWidget {
Get.back(); Get.back();
}, },
), ),
ListTile( // ListTile(
selected: destinationController.travelMode == 2 ? true : false, // selected: destinationController.travelMode == 2 ? true : false,
selectedTileColor: Colors.amber.shade200, // selectedTileColor: Colors.amber.shade200,
leading: Image(image: AssetImage('assets/images/p4_10_train.png'),), // leading: Image(image: AssetImage('assets/images/p4_10_train.png'),),
title: Text("transit".tr), // title: Text("transit".tr),
onTap:(){ // onTap:(){
destinationController.travelMode.value = 2; // destinationController.travelMode.value = 2;
destinationController.PopulateDestinations(); // destinationController.PopulateDestinations();
Get.back(); // Get.back();
}, // },
), // ),
], ],
), ),

View File

@ -305,7 +305,7 @@ void login(String email, String password, BuildContext context){
void loadAreaFor(String perf){ void loadAreaFor(String perf){
areas.clear(); areas.clear();
dynamic initVal = {'id':'-1', 'adm2_ja':'----'}; dynamic initVal = {'id':'-1', 'area_nm':'----'};
PerfectureService.loadGifuAreas(perf).then((value){ PerfectureService.loadGifuAreas(perf).then((value){
value!.add(initVal); value!.add(initVal);
areas.add(value); areas.add(value);

View File

@ -67,7 +67,7 @@ class DestinationService{
return cats; return cats;
} }
static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations) async{ static Future<List<PointLatLng>>? getDestinationLine(List<Destination> destinations, Map<String, dynamic> mtx) async{
PolylinePoints polylinePoints = PolylinePoints(); PolylinePoints polylinePoints = PolylinePoints();
if(destinations.length <= 0){ if(destinations.length <= 0){
@ -88,28 +88,40 @@ class DestinationService{
} }
double la = d.lat; double la = d.lat;
double ln = d.lon; double ln = d.lon;
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: true);
int j = 0;
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: false);
//print("----- UUUUUU ${pwp}"); //print("----- UUUUUU ${pwp}");
//PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]); //PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]);
wayPoints.add(pwp); wayPoints.add(pwp);
i+=1; i+=1;
j += 4;
} }
final DestinationController destinationController = Get.find<DestinationController>(); final DestinationController destinationController = Get.find<DestinationController>();
int trav_mode = destinationController.travelMode.value; int trav_mode = destinationController.travelMode.value;
TravelMode _mode = TravelMode.walking; String _mode = "WALKING";
if(trav_mode == 1){ if(trav_mode == 1){
_mode = TravelMode.driving; //_mode = TravelMode.driving;
_mode = "DRIVING";
} }
else if(trav_mode == 2) { else if(trav_mode == 2) {
_mode = TravelMode.transit; //_mode = TravelMode.transit;
_mode = "TRANSIT";
} }
//PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186)); //PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186));
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: _mode, wayPoints: wayPoints); 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}"); //print("#####@@@@@ ${result.points}");
return result.points; return result;
} }

View File

@ -14,6 +14,7 @@ class MatrixService{
String locs = ""; String locs = "";
String origin = ""; String origin = "";
String destination = "";
int i = 0; int i = 0;
for(Destination d in destinations){ for(Destination d in destinations){
@ -21,6 +22,14 @@ class MatrixService{
if(i==0){ if(i==0){
origin = "${d.lat}, ${d.lon}"; origin = "${d.lat}, ${d.lon}";
i++;
continue;
}
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}");
@ -28,6 +37,8 @@ class MatrixService{
i++; i++;
} }
locs = "optimize:false|${locs}";
String _mode = "walking"; String _mode = "walking";
switch (destinationController.travelMode.value) { switch (destinationController.travelMode.value) {
case 1: case 1:
@ -42,7 +53,7 @@ class MatrixService{
} }
Map<String, dynamic> cats = {}; Map<String, dynamic> cats = {};
String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&mode=${_mode}&origins=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE"; String url = "https://maps.googleapis.com/maps/api/directions/json?destination=${destination}&mode=${_mode}&waypoints=${locs}&origin=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
print(url); print(url);
final http.Response response = await http.get( final http.Response response = await http.get(
Uri.parse(url), Uri.parse(url),

View File

@ -8,6 +8,6 @@ class ConstValues{
static const dev_home_ip_server = "http://172.20.10.9:8100"; static const dev_home_ip_server = "http://172.20.10.9:8100";
static String currentServer(){ static String currentServer(){
return dev_home_ip_server; return server_uri;
} }
} }

View File

@ -41,7 +41,8 @@ class StringValues extends Translations{
'confirm': 'Confirm', 'confirm': 'Confirm',
'cancel': 'Cancel', 'cancel': 'Cancel',
'all_destinations_are_deleted_successfully' : 'All destinations are deleted successfully', 'all_destinations_are_deleted_successfully' : 'All destinations are deleted successfully',
'deleted': "Deleted" 'deleted': 'Deleted',
'remarks' : 'Remarks'
}, },
'ja_JP': { 'ja_JP': {
'drawer_title':'ロゲイニング参加者はログイン するとチェックポイントが参照 できます', 'drawer_title':'ロゲイニング参加者はログイン するとチェックポイントが参照 できます',
@ -83,7 +84,8 @@ class StringValues extends Translations{
'confirm': '確認', 'confirm': '確認',
'cancel': 'キャンセル', 'cancel': 'キャンセル',
'all_destinations_are_deleted_successfully' : 'すべての宛先が正常に削除されました', 'all_destinations_are_deleted_successfully' : 'すべての宛先が正常に削除されました',
'deleted': "削除された" 'deleted': "削除された",
'remarks' : '備考'
}, },
}; };
} }

View File

@ -111,7 +111,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
children: [ children: [
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
destinationController.makePrevious(indexController.currentDestinationFeature[0]); Get.back();
//destinationController.makePrevious(indexController.currentDestinationFeature[0]);
}, },
color: Colors.blue, color: Colors.blue,
textColor: Colors.white, textColor: Colors.white,
@ -134,19 +135,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
), ),
), ),
), ),
MaterialButton( // MaterialButton(
onPressed: () { // onPressed: () {
destinationController.makeNext(indexController.currentDestinationFeature[0]); // destinationController.makeNext(indexController.currentDestinationFeature[0]);
}, // },
color: Colors.blue, // color: Colors.blue,
textColor: Colors.white, // textColor: Colors.white,
child: Icon( // child: Icon(
Icons.arrow_forward_ios, // Icons.arrow_forward_ios,
size: 14, // size: 14,
), // ),
padding: EdgeInsets.all(16), // padding: EdgeInsets.all(16),
shape: CircleBorder(), // shape: CircleBorder(),
), // ),
], ],
), ),
), ),
@ -223,7 +224,8 @@ class BottomSheetNew extends GetView<BottomSheetController> {
children: [ children: [
MaterialButton( MaterialButton(
onPressed: () { onPressed: () {
indexController.makePrevious(indexController.currentFeature[0]); Get.back();
//indexController.makePrevious(indexController.currentFeature[0]);
}, },
color: Colors.blue, color: Colors.blue,
textColor: Colors.white, textColor: Colors.white,
@ -246,20 +248,20 @@ class BottomSheetNew extends GetView<BottomSheetController> {
), ),
), ),
), ),
MaterialButton( // MaterialButton(
onPressed: () { // onPressed: () {
//print("----- next is ${indexController.currentFeature[0]} ------"); // //print("----- next is ${indexController.currentFeature[0]} ------");
indexController.makeNext(indexController.currentFeature[0]); // indexController.makeNext(indexController.currentFeature[0]);
}, // },
color: Colors.blue, // color: Colors.blue,
textColor: Colors.white, // textColor: Colors.white,
child: Icon( // child: Icon(
Icons.arrow_forward_ios, // Icons.arrow_forward_ios,
size: 14, // size: 14,
), // ),
padding: EdgeInsets.all(16), // padding: EdgeInsets.all(16),
shape: CircleBorder(), // shape: CircleBorder(),
), // ),
], ],
), ),
), ),
@ -365,7 +367,19 @@ class BottomSheetNew extends GetView<BottomSheetController> {
], ],
), ),
), ),
Text('id: ${indexController.currentFeature[0].properties!["location_id"].toString()}, cp : ${indexController.currentFeature[0].properties!["cp"].toString()}'), Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
SizedBox(width: 8.0,),
indexController.currentFeature[0].properties!["remark"] != null && (indexController.currentFeature[0].properties!["remark"] as String).isNotEmpty ?
getDetails(context, "remarks".tr, indexController.currentFeature[0].properties!["remark"] ?? '', isurl: false)
:
Container(width: 0.0, height: 0,),
],
),
),
Text('${indexController.currentFeature[0].properties!["cp"].toString()} - id: ${indexController.currentFeature[0].properties!["checkin_point"].toString()}'),
], ],
), ),
) )

View File

@ -26,12 +26,24 @@ class DestinationWidget extends StatelessWidget {
} }
else{ else{
print("------- image is ${destinationController.destinations[index].photos!}------"); print("------- image is ${destinationController.destinations[index].photos!}------");
return Image(image: NetworkImage( String _photo = destinationController.destinations[index].photos!;
destinationController.destinations[index].photos!), if(_photo.contains('http')){
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) { return Image(image: NetworkImage(
return Image.asset("assets/images/empty_image.png"); destinationController.destinations[index].photos!),
}, errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
); return Image.asset("assets/images/empty_image.png");
},
);
}
else {
return Image(image: NetworkImage(
'http://container.intranet.sumasen.net:8100/media/' + destinationController.destinations[index].photos!),
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Image.asset("assets/images/empty_image.png");
},
);
}
} }
} }
@ -221,12 +233,12 @@ class DestinationWidget extends StatelessWidget {
), ),
), ),
startChild: startChild:
destinationController.matrix["rows"][0]["elements"] != null ? index > 0 && destinationController.matrix["routes"][0]["legs"] != null ?
Column( Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly, mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [ children: [
Text(destinationController.matrix["rows"][0]["elements"][index]["distance"] != null ? destinationController.matrix["rows"][0]["elements"][index]["distance"]["text"].toString(): ''), Text(destinationController.matrix["routes"][0]["legs"][index -1]["distance"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["distance"]["text"].toString(): ''),
Text(destinationController.matrix["rows"][0]["elements"][index]["distance"] != null ? destinationController.matrix["rows"][0]["elements"][index]["duration"]["text"].toString() : '') Text(destinationController.matrix["routes"][0]["legs"][index -1]["duration"] != null ? destinationController.matrix["routes"][0]["legs"][index-1]["duration"]["text"].toString() : '')
], ],
): ):
Container() Container()

View File

@ -43,10 +43,10 @@ class MapWidget extends StatelessWidget {
Icon(Icons.circle,size: 6.0,), Icon(Icons.circle,size: 6.0,),
i.properties!['cp'] == -1 ? i.properties!['cp'] == -1 ?
Transform.rotate( Transform.rotate(
alignment: Alignment.center, alignment: Alignment.centerLeft,
origin: Offset.fromDirection(0, 6), origin: Offset.fromDirection(1, 26),
angle: 90 * pi / 180, angle: 270 * pi / 180,
child: Icon(Icons.play_arrow_outlined, color: Colors.red, size: 40,)): child: Icon(Icons.play_arrow_outlined, color: Colors.red, size: 70,)):
Container(color: Colors.transparent,), Container(color: Colors.transparent,),
], ],
) )

View File

@ -60,7 +60,6 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
child: Text(currency["adm2_ja"].toString()), child: Text(currency["adm2_ja"].toString()),
value: currency["id"].toString(), value: currency["id"].toString(),
); );
dropDownItems.add(newDropdown); dropDownItems.add(newDropdown);
} }
} }
@ -76,8 +75,8 @@ class _PerfectureWidgetState extends State<PerfectureWidget> {
child: Text(currency["area_nm"].toString()), child: Text(currency["area_nm"].toString()),
value: currency["id"].toString(), value: currency["id"].toString(),
); );
dropDownItems.add(newDropdown); dropDownItems.add(newDropdown);
} }
} }