koopjs / winnow

Deprecated
Apache License 2.0
90 stars 18 forks source link

Winnow does not support point coordinates for geometry param #203

Closed jahndis closed 2 years ago

jahndis commented 2 years ago

While using koop, I ran into an issue where a url like: https://featureserver.com/provider/id/FeatureServer/0/query?f=json&geometryType=esriGeometryPoint&geometry=7652714.335571289%2C-1985856.184782909&geometryType=esriGeometryPoint&inSR=102100&outSR=102100 would cause koop to respond with a 500 internal server error.

It appears that winnow currently doesn't support the geometry=x,y query param format for the esriGeometryPoint geometryType as specified here: https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer-.htm It currently tries to construct a bbox from the two x,y coordinates, resulting in an invalid bbox with NaN values, which causes koop to respond with 500's (at least as of koop version 4.1.1).

We are able to work around it in our provider by overwriting the geometry with a "bounding box" consisting of x/y min/max that are the same values (i.e. "-10,10" => "-10,10,-10,10") doing the following:

  if (!!query.geometry && query.geometry.split(',').length === 2) {
    query.geometry = `${query.geometry},${query.geometry}`;
  }

But obviously, this is less than ideal.

I have a PR that fixes this issue for our use case, although I'd appreciate someone else taking a look to see if there are any other implications of introducing this support. https://github.com/koopjs/winnow/pull/202