chiselstrike icon indicating copy to clipboard operation
chiselstrike copied to clipboard

How to run spatial/gis/geo queries against Chiselstrike data/models?

Open sixman9 opened this issue 3 years ago • 2 comments

Hi, Firstly, I REALLY like what ChiselStrike (CS) seems to offer as a developer experience, I'm looking at one-manning some development.

I'm looking to store location-based data, probably having coordinate fields within my CS-defined models. My real question is, how might I perform GIS/Spatial searches against those fields?

I'm thinking those queries should possibly go into a CS-coded lambda, e.g. const locations = await LocationObj.findMany(l => l.coord == SOME_COORD); or similar, but I fear I will have to, possibly, use an entirely different framework, such as Knex-postgis etc.

Thoughts?

sixman9 avatar Oct 28 '22 12:10 sixman9

There's no support for geospatial data in ChiselStrike right now, so you unfortunately cannot efficiently query them. You can, of course, do calculation in TypeScript with lambdas as you say. So, for example, that findMany() lambda could call into some distance() function.

That said, I think integrating with something like SpatiaLite or PostGIS would indeed make tons of sense with proper geometry types at TypeScript level in the modes and provide an abstraction layer over some common geospatial query functions that map to database functions.

penberg avatar Oct 28 '22 13:10 penberg

SQLite has support for geospatial data with geojson. It should not be too complex to integrate if we go forward with this solution 😊

MarinPostma avatar Oct 28 '22 18:10 MarinPostma