1

I am making a web application with OL3 and have integrated a 3d viewer with cesium. I have two data sets that are being loaded with GeoJSON as vector WFS. Both data sets have height information contained and are published as such in GeoServer (Elevation is set).

I am trying to give one WFS an extrusion (building locations) and the other a height (aircraft elevation). Everything I have found seems to be based off of cesium geometry. Is it possible to do this? Do I need to convert to primitives first?

** EDIT **
Here is the buildingSource script:

var geojsonFormat2 = new ol.format.GeoJSON();
var buildingSource = new ol.source.Vector({ 
    loader: function(extent, resolution, projection) {
    var url = 'http://local:58088/geoserver/wfs?service=WFS&' +
    'version=1.1.0&request=GetFeature&typename=Thunderbirds:Nevada&' +
    'outputFormat=text/javascript&format_options=callback:loadFeatures2' +
    '&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';

$.ajax({
    url: url,
    dataType: 'jsonp',
    jsonp: true
    }).done(function(response) {
        WFSformat = new ol.format.WFS(),
        sourceVector.addFeatures(WFSformat.readFeatures(response)) }); },
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
    maxZoom: 19 })) });
  • So do you want to make a spatial query on client. I mean using the geometry from one layer to select features from other layer? Or do you want to make a wfs request to your backend server for the selection? – pavlos Oct 27 '15 at 9:02
  • Neither, I am not trying to make a selection. I am just trying to display both point datasets at the same time in a 3D scene. – alex89 Oct 27 '15 at 19:25
  • Hi @alex89. I know this been a while since you posted this question, but i was wondering if you could upload the entire script and not only the buildingSource script? I am trying to setup my own WFS source for an OL3+cesium project. – aneh Jun 12 '17 at 8:04
1

Load the GeoJSON Sandcastle Demo and click the Custom styling button in the top of the 3D window. The code on the left shows how the GeoJSON is being assigned extrusion heights.

Once the dataSource has (asynchronously) loaded, a for-loop iterates over all the entities in the dataSource, and in this example assigns entity.polygon.extrudedHeight based on population. You can assign any property you like to be the extruded height value here.

You can also assign entity.polygon.height for the ones where you want altitude but not extrusion.

  • Thanks! This is helpful, but I have a question. Both of my data sets are points. How do I convert them to circle so that I can extrude (so far I haven't found anything for point extrusion/height) – alex89 Oct 27 '15 at 20:00
  • Also, I keep getting a 'buildingSource.entities is undefined' error. Can I not use a data source defined in ol3? – alex89 Oct 27 '15 at 20:08
  • I don't know much about OL3, can you post the code that creates buildingSource? Also there's no extrusion for a point, but you could create a polyline from the ground to the building height. – emackey Oct 27 '15 at 21:07
  • Edited in original question Right, but wouldn't using a circle geometry be easier? – alex89 Oct 27 '15 at 22:32
  • Sure, circle geometry works too. Looks like buildingSource is an OL3 object, I don't know OL3 well enough to know how to get the Cesium entities out of that object. I see there's an applyHeightOffsetToGeometry function, but I don't know if you can get finer-grained access to the underlying Cesium objects. – emackey Oct 28 '15 at 14:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.