Osmdroid从WMS GeoServer获取功能信息

时间:2019-01-07 12:33:47

标签: android osmdroid

我想使用像openlayers这样的osmdroid从wms geoserver获取功能信息,这就是使用openlayers的方法

String selectQuery = "SELECT count(*) FROM people";
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null); // Exception happens here

1 个答案:

答案 0 :(得分:0)

要从GeoServer上存在的图层获取要素数据,您需要调用“ WMS服务” 然后添加图层详细信息,例如图层名称,版本,投影格式和缩放级别。

val layer = selectedCity.getBuildingLayerName()
val tile = projection.getTileFromMercator(projection.getMercatorXFromPixel(rtnPoint.x))
val tileY = projection.getTileFromMercator(projection.getMercatorYFromPixel(rtnPoint.y))
GlobalScope.launch {
         val buildingFeatureData =getBuildingFeatureData(layer, tile, tileY, projection.zoomLevel.toInt())
          activity!!.runOnUiThread {
             Toast.makeText(activity!!.applicationContext, "$buildingFeatureData", Toast.LENGTH_LONG).show()
             }
        }


suspend fun getBuildingFeatureData(layer: String,  x:Int, y:Int, zoom:Int):String {
        return WebMercatorWMSFeatureExtractor(layer,"1.3.0","EPSG:3857").getFeatureData(
            MapLayers.getMapsBaseUrl(ApiHelper.apiEndPoint),
            "application/json",
            x,y,
            zoom
        )
    }