From d794176c08f740fa89ee5d834ab11d6442a27878 Mon Sep 17 00:00:00 2001 From: seunggil1 <38664481+seunggil1@users.noreply.github.com> Date: Fri, 4 Sep 2020 00:23:04 +0900 Subject: [PATCH] updateBadPoint optimization --- .../safeway_direction/lib/models/route.dart | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/flutter/safeway_direction/lib/models/route.dart b/flutter/safeway_direction/lib/models/route.dart index 66c0c11..942b696 100644 --- a/flutter/safeway_direction/lib/models/route.dart +++ b/flutter/safeway_direction/lib/models/route.dart @@ -188,15 +188,14 @@ class BadPoint { } static Future updateBadPointbyStore(Set result, List dangerList) async { + List latlngList = []; + String roadName; + Pair pairLatLng; for(Store danger in dangerList){ - List latlngList = await TmapServices.getNearRoadInformation(danger.location); + latlngList = await TmapServices.getNearRoadInformation(danger.location); for(LatLng iter in latlngList){ - String roadName = await TmapServices.reverseGeocoding(iter); - //only test - if(danger.rdnm != roadName) - print("roadName different : " + danger.rdnm + " != " + roadName); - // - Pair pairLatLng = Pair.geometryFloor(iter); + roadName = await TmapServices.reverseGeocoding(iter); + pairLatLng = Pair.geometryFloor(iter); result.firstWhere( (BadPoint iter) => iter.roadName == roadName && iter.badLocation == pairLatLng, orElse: () {result.add(BadPoint(Pair.geometryFloor(iter), roadName));return result.last;} @@ -206,13 +205,15 @@ class BadPoint { } static Future updateBadPointbyAccident(Set result, List dangerList) async{ + List latlngList = []; + String roadName; + Pair pairLatLng; for(AccidentArea danger in dangerList){ - List latlngList = await TmapServices.getNearRoadInformation(danger.location); + latlngList = await TmapServices.getNearRoadInformation(danger.location); for(LatLng iter in latlngList){ - String roadName = await TmapServices.reverseGeocoding(iter); - Pair pairLatLng = Pair.geometryFloor(iter); - result.firstWhere( - (BadPoint iter) => iter.roadName == roadName && iter.badLocation == pairLatLng, + roadName = await TmapServices.reverseGeocoding(iter); + pairLatLng = Pair.geometryFloor(iter); + result.firstWhere((BadPoint iter) => iter.roadName == roadName && iter.badLocation == pairLatLng, orElse: () {result.add(BadPoint(Pair.geometryFloor(iter), roadName)); return result.last;}).danger += danger.occrrncCnt; } }