terraformer-js / terraformer

A geographic toolkit for dealing with geometry, geography, formats, and building geodatabases
MIT License
182 stars 28 forks source link

Allow for a possibility to override standard SRS warning #99

Closed sjaakd closed 1 year ago

sjaakd commented 1 year ago

According to rfc7946

In general, GeoJSON processing software is not expected to have access to coordinate reference system databases or to have network access to coordinate reference system transformation parameters. However, where all involved parties have a prior arrangement, alternative coordinate reference systems can be used without risk of data being misinterpreted.

Therefore I think the warning is perhaps correct, but it should at least be possible to suppress it. Now I need to fake WGS84 and later restore the original crs on the ESRI geometry like this

        // Both sides agree on RD.
        // Note, geojson allows another crs when both parties agree by prior arrangement. See also https://datatracker.ietf.org/doc/html/rfc7946
        // Temporarily change geometry and set srs to wgs84 to suppress warning in argisToGeoJSON (not supported by geojson)
        const wkid = graphic.geometry.spatialReference.get( "wkid" );
        graphic.geometry.spatialReference.set( "wkid", 4326);
        orderItem.geometry = arcgisToGeoJSON( graphic.geometry.toJSON() );
        // Change spatial reference back to the original
        graphic.geometry.spatialReference.set( "wkid", wkid );
jgravois commented 1 year ago

thanks for taking the time to explain your use case but i'm not too keen on the idea of introducing an additional argument for configuration options to the arcgisToGeoJSON() method.

sjaakd commented 1 year ago

Is it an option not to do this check at all and instead just document it?

jgravois commented 1 year ago

sorry, but no. based on the language of the spec, i think the warning is appropriate.

sjaakd commented 1 year ago

Ok.. fair enough. I've now solved it by saving - calling the method - restoring the CRS. That works for me. Thanks for maintaining this library.