Search code examples
geoserversandcastlecesiumjs

How to enable cross origin resource sharing (CORS) in Cesium Sandcastle for Geoserver WMS Get request


I am trying fist to test and practice in cesium sandcatle with my data on localhost:8080 geoserver.

This picture will explane everything

Also, i want to ask, "how to get a list of GeoServer layers loaded into the Cesium BaseLayerPicker" From example http://localhost:8080/geoserver/masterrad/wfs?request=GetCapabilities give XML file, with possible layers in workspaces 'masterrad'. How to extract names from that XML and put in BaseLayerPicker

Thanks


Solution

  • I think this may be two unrelated questions, but I'll try to answer both.

    You can enable CORS in Geoserver using the CORS Filter plugin: http://software.dzhuvinov.com/cors-filter-installation.html

    As for your second question, Cesium does not have built-in support for querying WFS GetCapabilities, but TerriaJS does: https://github.com/TerriaJS/terriajs

    TerriaJS is an open-source library built on top of Cesium that was originally developed for Australia's NationalMap and has since been used for a lot of other projects. TerriaJS also has a fallback to Leaflet for systems that can't run Cesium. Once you have CORS working on your server, visit nationalmap.gov.au (a site running TerriaJS), click Add Data, enter your WFS URL, and you should see all of the server's layers appear at the bottom of the Data Catalogue.