GeoJsonDataSource - message: "Unknown crs name: urn:ogc:def:crs:EPSG::4326"

856 views
Skip to first unread message

milu...@gmail.com

unread,
Dec 26, 2015, 7:36:19 AM12/26/15
to cesium-dev
Wehen i try to add json from my geoserver to Cesium viwer with code bellow:

var viewer = new Cesium.Viewer('cesiumContainer', {
sceneMode : Cesium.SceneMode.SCENE2D,
timeline : false,
animation : false
});

var dataSource = Cesium.GeoJsonDataSource.load('http://localhost:8200/geoserver/SrbijaAdmGranice/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=SrbijaAdmGranice:SRB_AdministrativneGranice_Level2_3909&srsName=EPSG:4326&outputFormat=json');
viewer.dataSources.add(dataSource);
viewer.zoomTo(dataSource);


I gate this error : Unknown crs name: urn:ogc:def:crs:EPSG::4326

What should i do?
Do I need some more property in .load function?

Thanks forward.

Mati O

unread,
Mar 3, 2016, 2:59:02 AM3/3/16
to cesium-dev, milu...@gmail.com
Hey, yesterday I've encountered the same issue but I was able to workaround it.

In GeoJsonDataSource.crsNames static property there are two default coordinate references systems defined, both for WGS84.

var crsNames = {
'urn:ogc:def:crs:OGC:1.3:CRS84' : defaultCrsFunction,
'EPSG:4326' : defaultCrsFunction
};

As far as I understand the issue, there's this another GML representation of EPSG:4326, which happens to be urn:ogc:def:crs:EPSG::4326 but isn't included in the default CRS names.
This is how geoserver returns GeoJson when making WFS requests, just like in your example.

There are multiple solution to this : 

  1. My first (and ugly) solution was to load your geojson and manipulate it's crs object to conform to the crs names that supported by Cesium before passing to GeoJsonDataSource, like this :
    // Get your geojson from geoserver or wherever it is stored 
    var geojson = loadYourGeoJson();
    // Change the projection to match the one supported by Cesium
    geojson.crs.properties.name = "EPSG:4326";
    // Load the geojson
    Cesium.GeoJsonDataSource.load(geojson);

  2. My second approach was to add the CRS name to the static property on the GeoJsonDataSource, since it's the same projection we can reuse the same function
    // Just add our CRS to the crs names and point it to the same function
    Cesium.GeoJsonDataSource.crsNames['urn:ogc:def:crs:EPSG::4326'] = Cesium.GeoJsonDataSource.crsNames["EPSG:4326"];

  3. My third solution would be to ask Cesium guys to simply add this CRS name to the defaults since it seems to be just another representation of those that are already there
    var crsNames = {
    'urn:ogc:def:crs:OGC:1.3:CRS84' : defaultCrsFunction,
    'EPSG:4326' : defaultCrsFunction,
            'urn:ogc:def:crs:EPSG::4326' : defaultCrsFunction
    };


Hannah Pinkos

unread,
Mar 3, 2016, 11:32:02 AM3/3/16
to cesium-dev, milu...@gmail.com
Hello,

That seems reasonable.  Thanks for the info!
Could you open a pull request with your third solution?  Here's some info in contributing: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/CONTRIBUTING.md

Thanks!

Hannah

Mati Ostrovsky

unread,
Mar 3, 2016, 5:30:23 PM3/3/16
to cesiu...@googlegroups.com
Actually that was my intention :)
I'll sign the CLA and read the contributions guide


--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/HDfqUXuR_Cg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages