koopjs / koop

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

Expose parsed where clause #362

Closed efbenson closed 4 years ago

efbenson commented 4 years ago

If we are creating a provider and it is hitting serveral sources/feature services and merging them into one dataset it would be nice to be able to intuit the where clause and pass those filters to the appropriate sources. Winnow is already doing this I believe and it would be nice to have access to the query tree.

Example:

Say I have 2 layers I am merging together and doing some other fancy calculations and whatnot.

My sources are Apple layer with types and count per county Grapes database table with types and count per county

Where appleType=GrannySmith or grapeCount>6

would be something like: { or: [ { appleType: "GrannySmith"}, {grapeCount: {$gt: 6}} ]} I could scan that object and pull apple records from a layer with appleType=GrannySmith and pull records from the db where grapeCount > 6

Currently there is no good way unless you roll your own where parser, or pull all the features for the layer and all the records for the DB which can be very limiting.

rgwozdz commented 4 years ago

Hey @efbenson. So the where is not parsed by Winnow until Koop receives the translated geojson from the callback of your provider's getData. Even then, Winnow doesn't persist a parsed where; rather it translates the parsed where to the WHERE needed for alasql.

Since Winnow doesn't do this until after your provider, perhaps it makes more sense to just use 'flora-sql-parser' in your provider and do the parsing independently of Winnow? Otherwise, you would have to modify Winnow to expose its own result of 'flora-sql-parser' and pull Winnow into your provider.

rgwozdz commented 4 years ago

Closing due to inactivity.