Skip to content

Commit

Permalink
Merge pull request #185 from mapzen/97-update-path-on-reroute
Browse files Browse the repository at this point in the history
Redraw route line on reroute
  • Loading branch information
ecgreb committed Dec 9, 2015
2 parents 437feae + 6aba134 commit bb29d9e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public open class MainPresenterImpl(val mapzenLocation: MapzenLocation, val bus:
mainViewController?.hideProgress()
routeManager.route = route
generateRoutingMode()
mainViewController?.drawRouteLine(route)
}

private fun generateRoutePreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ public class MainActivity : AppCompatActivity(), MainViewController, RouteCallba
hideProgress()
}

private fun drawRouteLine(route: Route) {
override fun drawRouteLine(route: Route) {
val properties = com.mapzen.tangram.Properties()
properties.add("type", "line");
val geometry: ArrayList<Location>? = route.getGeometry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mapzen.erasermap.view

import android.location.Location
import com.mapzen.pelias.gson.Feature
import com.mapzen.valhalla.Route

public interface MainViewController {
public fun showSearchResults(features: List<Feature>)
Expand All @@ -28,6 +29,7 @@ public interface MainViewController {
public fun showCurrentLocation(location: Location)
public fun setMapTilt(radians: Float)
public fun setMapRotation(radians: Float)
public fun drawRouteLine(route: Route)
public fun clearRouteLine()
public fun rotateCompass()
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import com.mapzen.erasermap.view.TestMainController
import com.mapzen.erasermap.view.TestRouteController
import com.mapzen.pelias.gson.Feature
import com.mapzen.pelias.gson.Result
import com.mapzen.tangram.LngLat
import com.mapzen.valhalla.Route
import com.squareup.otto.Bus
import com.squareup.otto.Subscribe
Expand Down Expand Up @@ -168,7 +167,7 @@ public class MainPresenterTest {

@Test fun onBackPressed_shouldClearRouteLine() {
presenter.onRoutePreviewEvent(RoutePreviewEvent(getTestFeature()))
mainController.routeLine = ArrayList<LngLat>()
mainController.routeLine = Route(JSONObject())
presenter.onBackPressed()
assertThat(mainController.routeLine).isNull()
}
Expand All @@ -186,7 +185,7 @@ public class MainPresenterTest {

@Test fun onClickStartNavigation_shouldPublishRouteEvent() {
val subscriber = RouteEventSubscriber()
presenter.bus?.register(subscriber)
presenter.bus.register(subscriber)
presenter.onClickStartNavigation()
assertThat(subscriber.event).isNotNull()
}
Expand Down Expand Up @@ -324,6 +323,14 @@ public class MainPresenterTest {
presenter.success(Route(JSONObject()))
}

@Test fun onRerouteSuccess_shouldDrawRouteLine() {
val route = Route(JSONObject())
mainController.routeLine = null
presenter.onRoutePreviewEvent(RoutePreviewEvent(getTestFeature()))
presenter.success(route)
assertThat(mainController.routeLine).isEqualTo(route)
}

@Test fun onCompassClick_shouldResetMapRotation() {
mainController.rotation = 180f
presenter.onCompassClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package com.mapzen.erasermap.view

import android.location.Location
import com.mapzen.pelias.gson.Feature
import com.mapzen.tangram.LngLat
import com.mapzen.valhalla.Route

public class TestMainController : MainViewController {
public var searchResults: List<Feature>? = null
public var location: Location? = null
public var zoom: Float = 0f
public var tilt: Float = 0f
public var rotation: Float = 0f
public var routeLine: List<LngLat>? = null
public var routeLine: Route? = null
public var queryText: String = ""

public var isProgressVisible: Boolean = false
Expand Down Expand Up @@ -117,6 +117,10 @@ public class TestMainController : MainViewController {
isReverseGeocodeVisible = true
}

override fun drawRouteLine(route: Route) {
routeLine = route
}

override fun clearRouteLine() {
routeLine = null
}
Expand Down

0 comments on commit bb29d9e

Please sign in to comment.