0

OSMBuilding has a function which allows 3D json file be added to Leaflet as stated here. The question is how I can get the same format from GeoServer.

I have tried this

 http://localhost:9090/geoserver/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=localhost%3A3D_sample&outputFormat=json&dataType=jsonp

as stated here and here, I could get a Json output like this:

   {"type":"FeatureCollection","totalFeatures":1,"features":[{"type":"Feature","id":"3D_sample.fid--57e9f8c8_15eeea74f64_-11f9","geometry":{"type":"MultiLineString","coordinates":[[[174.88757026,-36.90768287,24.4688],[174.88754738,-36.90774106,22.4855]],[[174.88754738,-36.90774106,22.4855],......]]},"geometry_name":"geom","properties":{"objectid":1,"recordstatus":"Current","heightminlidar":0.855906,"heightmaxlidar":6.61621999,"heightmeanlidar":4.5......,174.88764272,-36.90753397]}}],"crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:EPSG::4167"}},"bbox":[174.88743904,-36.90774106,174.88764272,-36.90753397]}

While I need sth like this as stated here

  {
    "type": "FeatureCollection",
    "features": [{
    "type": "Feature",
    "geometry": {
    "type": "Polygon",
    "coordinates": [
    [

    [174.749268, -36.853149],
    [174.751368, -36.854249],
    [174.752468 ,-36.855349],
    [174.753568 ,-36.856449 ],
    [174.749268, -36.853149]

    ]
    ]
    },
    "properties": {
    "color": "rgb(255,200,150)",
    "height": 220
    }
    }]}

this means I do not need this

 {"type":"FeatureCollection","totalFeatures":1,"features":[{"type":"Feature","id":"3D_sample.fid--57e9f8c8_15eeea74f64_-1205","geometry":

from Geoserver, but I do not know how I could get the right format.

4
  • 1
    The extra elements like "totalFeatures":1 should not make any trouble. What probably makes is that your feature type in GeoServer has linestrings while OSMBuilding wants polygons. Also your data has X,Y,Z coordinates while OSMBuilding wants only X,Y and height as an attribute. You must start by processing your source data.
    – user30184
    Oct 6 '17 at 6:16
  • Thank you @user30184, So you meant I need to write a piece of code to convert the Json output from geoserver to an appropriate format for Leaflet, right? Does not this processing create some extra delay and slow down the visualization? Is there any more efficient way, plugin, Oct 6 '17 at 9:11
  • I mean that if you need 2D polygons with height and color as attributes you'd better to save them as such into your database. Then GeoServer should create suitable GeoJSON for you out-of-the-box.
    – user30184
    Oct 6 '17 at 12:43
  • That is a good point, I will try that on Monday and keep you posted. thank you Oct 6 '17 at 22:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.