Skip to content

Commit

Permalink
Apply constructor method pattern to TileSource creation
Browse files Browse the repository at this point in the history
  • Loading branch information
gino-m committed Sep 9, 2023
1 parent f10dc51 commit 9e82aad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class TileSource(val url: String, val type: Type) {
}

companion object {
fun fromFileExtension(url: String) =
if (url.endsWith(".png")) Type.TILED_WEB_MAP else Type.MOG_COLLECTION
fun fromUrl(url: String) =
TileSource(url, if (url.endsWith(".png")) Type.TILED_WEB_MAP else Type.MOG_COLLECTION)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ internal object SurveyConverter {
}

private fun convertTileSources(pd: SurveyDocument, builder: MutableList<TileSource>) {
pd.tileSources
?.mapNotNull { it.url }
?.forEach { url -> builder.add(TileSource(url, TileSource.fromFileExtension(url))) }
pd.tileSources?.mapNotNull { it.url }?.forEach { url -> builder.add(TileSource.fromUrl(url)) }
}
}

0 comments on commit 9e82aad

Please sign in to comment.