Skip to content

Commit

Permalink
Clarify use of "tile overlay", "tile source", and "offline map imager…
Browse files Browse the repository at this point in the history
…y" (#2032)

* Minor rename

* Clarify use of TileOverlay
  • Loading branch information
gino-m authored Nov 2, 2023
1 parent 0d5b8eb commit 0e8b4ba
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ abstract class AbstractMapContainerFragment : AbstractFragment() {
}

// Tile overlays.
if (config.showOfflineTileOverlays) {
if (config.showOfflineImagery) {
viewModel.offlineTileSources.observe(viewLifecycleOwner) {
map.clearTileOverlays()
it.forEach(map::addTileOverlay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,6 @@ constructor(
private val LOCATION_LOCK_ICON_ENABLED = R.drawable.ic_gps_lock
private val LOCATION_LOCK_ICON_DISABLED = R.drawable.ic_gps_lock_not_fixed

private val DEFAULT_MAP_CONFIG: MapConfig = MapConfig(showOfflineTileOverlays = true)
private val DEFAULT_MAP_CONFIG: MapConfig = MapConfig(showOfflineImagery = true)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import com.google.android.ground.ui.map.MapType

/** Configuration to apply on the rendered base map. */
data class MapConfig(
val showOfflineTileOverlays: Boolean,
val showOfflineImagery: Boolean,
val overrideMapType: MapType? = null,
val disableGestures: Boolean = false
)
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface MapFragment {
/** Update UI of rendered [LocationOfInterest]. */
fun setActiveLocationOfInterest(newLoiId: String?)

fun addTileOverlay(tileSource: TileSource)
fun addTileOverlay(source: TileSource)

/** Remove all tile overlays from the map. */
fun clearTileOverlays()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,20 @@ class GoogleMapsFragment : Hilt_GoogleMapsFragment(), MapFragment {
}
}

private fun addOfflineTileOverlay(url: String, bounds: List<Bounds>) {
private fun addLocalTileOverlay(url: String, bounds: List<Bounds>) {
addTileOverlay(
ClippingTileProvider(TemplateUrlTileProvider(url), bounds.map { it.toGoogleMapsObject() })
)
}

override fun addTileOverlay(tileSource: TileSource) =
when (tileSource.type) {
MOG_COLLECTION -> addMogCollectionTileOverlay(tileSource.url)
TILED_WEB_MAP -> addOfflineTileOverlay(tileSource.url, tileSource.clipBounds)
else -> error("Unsupported tile source type ${tileSource.type}")
override fun addTileOverlay(source: TileSource) =
when (source.type) {
MOG_COLLECTION -> addRemoteMogTileOverlay(source.url)
TILED_WEB_MAP -> addLocalTileOverlay(source.url, source.clipBounds)
else -> error("Unsupported tile source type ${source.type}")
}

private fun addMogCollectionTileOverlay(url: String) {
private fun addRemoteMogTileOverlay(url: String) {
// TODO(#1730): Make sub-paths configurable and stop hardcoding here.
val mogCollection = MogCollection(Config.getMogSources(url))
addTileOverlay(MogTileProvider(mogCollection))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ internal constructor(
val downloadButtonEnabled = MutableLiveData(false)

override val mapConfig: MapConfig
get() = super.mapConfig.copy(showOfflineTileOverlays = false, overrideMapType = MapType.TERRAIN)
get() = super.mapConfig.copy(showOfflineImagery = false, overrideMapType = MapType.TERRAIN)

init {
remoteTileSources = surveyRepository.activeSurvey!!.tileSources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ constructor(
override val mapConfig: MapConfig
get() =
super.mapConfig.copy(
showOfflineTileOverlays = true,
showOfflineImagery = true,
overrideMapType = MapType.TERRAIN,
disableGestures = true
)
Expand Down

0 comments on commit 0e8b4ba

Please sign in to comment.