koopjs / winnow

Deprecated
Apache License 2.0
90 stars 18 forks source link

The request from ArcGIS Pro with projection seems to be failing. #191

Closed njkim closed 2 years ago

njkim commented 3 years ago

I am testing koop.js to use some custom data (basically geojson source) in ArcGIS Pro through koop.js. So far it is working pretty great. Thanks.

I ran into one problem which is "When the spatial reference is other than 4326, it seems reprojection in koop.js seems to be failing."

The symptoms

It looks like ArcGIS Pro send the request to koop.js with the following info. (This is California State Plane III but the SR does not matter it seems to happen with all the SRs)

{"wkid":102643,"latestWkid":2227,"xyTolerance":0.003280833333333333,"zTolerance":0.001,"mTolerance":0.001,
"falseX":-115860600,"falseY":-93269500,"xyUnits":3048.0060960121928,"falseZ":-100000,"zUnits":10000,
"falseM":-100000,"mUnits":10000}

The with WARNINGS as follows.

WARNING: [object Object] is not a valid spatial reference; defaulting to none
WARNING: spatial reference "[object Object]" could not be normalized. Defaulting to EPSG:4326.

Possible cause and solution

Quick debug seems to indicate that only the validation seems to be failing. https://github.com/koopjs/winnow/blob/master/lib/normalize-query-options/spatial-reference.js#L19

It seems only the validation is failing. The projection works perfectly, if simply the validation is bypassed or the input is stringified.

const { error } = schema.validate(JSON.stringify(input))

Joi validation may have to updated or the input has to be serialized?

Thanks.

rgwozdz commented 2 years ago

Thanks for this and sorry for the delay. Will take a look shortly, but feel free to submit a PR.