mapbox / Hecate

Fast Geospatial Feature Storage API
MIT License
252 stars 36 forks source link

Allows invalid coordinates #142

Closed whilei closed 5 years ago

whilei commented 5 years ago

Context

cc/ @ingalls

Rel: https://github.com/ingalls/hecate-example/pull/2

Currently Hecate allows invalid/improbable geo coordinates like [ 938.832710598893414, -199.38005089759827 ]. I'm not sure if this is necessarily a bug, since it's within the scope of an ambitious imagination that someone might want Hecate to be able to eat strange GeoJSON points.

But it seems pretty extreme, and I'd reckon validating coords would save more headaches around "Oops, I mixed up my lat and long" than it would "Why won't Hecate allow me to plot a point off the edge of the earth?"

A next question would be if this kind of validation should happen "hard", like somewhere around https://github.com/mapbox/Hecate/blob/master/src/feature/mod.rs#L179, or if this job might be abstracted to another kind of configurable schema.

ingalls commented 5 years ago

Due to the tile generation math you're absolutely correct that Hecate should avoid ingesting coordinates outside of the normal lat/lng range.

I've implemented a hard rejection of out of range coordinates in #143 as well updating to the latest version of geojson. Since the GeoJSON spec says that coordinates should be wrapped around the meridian, this should be fine to push onto the user.

ingalls commented 5 years ago

Fixed as of v0.58.0