-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic WMSElevationCoverage class.
- Loading branch information
1 parent
50eb9c4
commit ae2bfa4
Showing
5 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 4 additions & 31 deletions
35
.../src/commonMain/kotlin/earth/worldwind/globe/elevation/coverage/BasicElevationCoverage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,12 @@ | ||
package earth.worldwind.globe.elevation.coverage | ||
|
||
import earth.worldwind.geom.Sector | ||
import earth.worldwind.geom.TileMatrix | ||
import earth.worldwind.geom.TileMatrixSet | ||
import earth.worldwind.globe.elevation.ElevationSource | ||
import earth.worldwind.globe.elevation.ElevationTileFactory | ||
import earth.worldwind.ogc.WmsLayerConfig | ||
import earth.worldwind.ogc.WmsTileFactory | ||
import earth.worldwind.ogc.WmsElevationCoverage | ||
|
||
/** | ||
* Displays NASA's global elevation coverage at 30m resolution and 900m resolution on the ocean floor, | ||
* all from an OGC Web Map Service (WMS). By default, BasicElevationCoverage is configured to | ||
* retrieve elevation coverage from the WMS at [&https://wms.worldwind.earth/elev](https://wms.worldwind.earth/elev?SERVICE=WMS&REQUEST=GetCapabilities). | ||
*/ | ||
open class BasicElevationCoverage: TiledElevationCoverage(tileMatrixSet, tileFactory) { | ||
companion object { | ||
/** | ||
* 4x2 top level matrix equivalent to 90 degree top level tiles | ||
*/ | ||
private val tileMatrixSet get() = TileMatrixSet.fromTilePyramid( | ||
Sector().setFullSphere(), 4, 2, 256, 256, 13 | ||
) | ||
|
||
private val tileFactory: ElevationTileFactory get() { | ||
val layerConfig = WmsLayerConfig( | ||
"https://wms.worldwind.earth/elev", "SRTM-CGIAR,GEBCO" | ||
).apply { imageFormat = "application/bil16" } | ||
val wmsTileFactory = WmsTileFactory(layerConfig) | ||
return object : ElevationTileFactory { | ||
override fun createElevationSource(tileMatrix: TileMatrix, row: Int, column: Int): ElevationSource { | ||
val tileSector = tileMatrix.tileSector(row, column) | ||
val urlString = wmsTileFactory.urlForTile(tileSector, tileMatrix.tileWidth, tileMatrix.tileHeight) | ||
return ElevationSource.fromUrlString(urlString) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
class BasicElevationCoverage : WmsElevationCoverage( | ||
"https://wms.worldwind.earth/elev", "SRTM-CGIAR,GEBCO", "application/bil16" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
worldwind/src/commonMain/kotlin/earth/worldwind/ogc/WmsElevationCoverage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package earth.worldwind.ogc | ||
|
||
import earth.worldwind.geom.Sector | ||
import earth.worldwind.geom.TileMatrix | ||
import earth.worldwind.geom.TileMatrixSet | ||
import earth.worldwind.globe.elevation.ElevationSource | ||
import earth.worldwind.globe.elevation.ElevationTileFactory | ||
import earth.worldwind.globe.elevation.coverage.TiledElevationCoverage | ||
|
||
/** | ||
* Generates elevations from OGC Web Map Service (WMS) version 1.3.0. | ||
*/ | ||
open class WmsElevationCoverage( | ||
serviceAddress: String, coverage: String, imageFormat: String, sector: Sector = Sector().setFullSphere(), numLevels: Int = 13 | ||
): TiledElevationCoverage( | ||
buildTileMatrixSet(sector, numLevels), | ||
buildTileFactory(serviceAddress, coverage, imageFormat) | ||
) { | ||
companion object { | ||
/** | ||
* 4x2 top level matrix equivalent to 90 degree top level tiles | ||
*/ | ||
private fun buildTileMatrixSet(sector: Sector, numLevels: Int) = TileMatrixSet.fromTilePyramid( | ||
sector, 4, 2, 256, 256, numLevels | ||
) | ||
|
||
private fun buildTileFactory(serviceAddress: String, coverage: String, imageFormat: String): ElevationTileFactory { | ||
val layerConfig = WmsLayerConfig(serviceAddress, coverage).apply { this.imageFormat = imageFormat } | ||
val wmsTileFactory = WmsTileFactory(layerConfig) | ||
return object : ElevationTileFactory { | ||
override fun createElevationSource(tileMatrix: TileMatrix, row: Int, column: Int): ElevationSource { | ||
val tileSector = tileMatrix.tileSector(row, column) | ||
val urlString = wmsTileFactory.urlForTile(tileSector, tileMatrix.tileWidth, tileMatrix.tileHeight) | ||
return ElevationSource.fromUrlString(urlString) | ||
} | ||
} | ||
} | ||
} | ||
} |