koopjs / koop

Transform, query, and download geospatial data on the web.
http://koopjs.github.io
Other
669 stars 127 forks source link

Spatial Reference Question #355

Closed SergeyBarskiy closed 4 years ago

SergeyBarskiy commented 4 years ago

We created a koop service that always returns data in WGS 84 /4326 / Lat / Lon We know our service works, since I can observe the data manually. However, once the data is processed by koop, geometry is removed from resulting json if out SR is 2874, which is our specific map's SR. For example, this URL returns the geometry: http://localhost:4040/geoserver/xxx/rest/services/xxx/yyy/FeatureServer/0/query?f=json&resultOffset=0&resultRecordCount=2000&where=1%3D1&outFields=*&outSR=4326&spatialRel=esriSpatialRelIntersects, same with 102100 SR.

But this URL does not: http://localhost:4040/geoserver/xxx/rest/services/xxx/yyy/FeatureServer/0/query?f=json&resultOffset=0&resultRecordCount=2000&where=1%3D1&outFields=*&outSR=2874&spatialRel=esriSpatialRelIntersects

The only difference is spatial reference. Are we doing something wrong here?
Thank you!

rgwozdz commented 4 years ago

Hello @SergeyBarskiy and thanks for reaching out. The issue you are running into is that the Koop internals only support outSR transformation for a very limited set of WKIDs (4326, 3857, 102100, and few others). See the proj4 npm/repo for details.

We're trying to avoid having Koop be responsible for the storage of the required projection WKT for all existing spatial references - that would a very large amount of information and subject to frequent change. Most Koop implementation wouldn't need it.

There is an existing solution if you are authoring your own provider. When the request arrives in your getData, check if the outSR parameter is 2874, and if so replace that value with that SRs WKT, e.g.,

req.query.outSR = `PROJCS["NAD83(HARN) / California zone 5 (ftUS)",
    GEOGCS["NAD83(HARN)",
        DATUM["NAD83_High_Accuracy_Reference_Network",
            SPHEROID["GRS 1980",6378137,298.257222101,
                AUTHORITY["EPSG","7019"]],
            TOWGS84[0,0,0,0,0,0,0],
            AUTHORITY["EPSG","6152"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4152"]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",35.46666666666667],
    PARAMETER["standard_parallel_2",34.03333333333333],
    PARAMETER["latitude_of_origin",33.5],
    PARAMETER["central_meridian",-118],
    PARAMETER["false_easting",6561666.667],
    PARAMETER["false_northing",1640416.667],
    UNIT["US survey foot",0.3048006096012192,
        AUTHORITY["EPSG","9003"]],
    AXIS["X",EAST],
    AXIS["Y",NORTH],
    AUTHORITY["EPSG","2874"]]`

Give this a try. We're working on some documentation and a blog post for this specific issue - it comes up often.

SergeyBarskiy commented 4 years ago

Thank you very much for super quick response, @rgwozdz ! I guess I can just use this for various projections: https://spatialreference.org/ref/epsg/xxxx/ogcwkt/, aka https://spatialreference.org/ref/epsg/2874/ogcwkt/