Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Optimized searches for tiled requets. #39

Merged
merged 34 commits into from Aug 24, 2021
Merged

Allow Optimized searches for tiled requets. #39

merged 34 commits into from Aug 24, 2021

Conversation

bitner
Copy link
Collaborator

@bitner bitner commented Aug 10, 2021

Three SQL functions are provided that all return a FeatureCollection of items that are within the geometry that has been requested. The number of records returned is based on scanning through the data until the geometry passed in has been filled with tiles using the geometry included with the item record.

geoemtrysearch(geom, queryhash, fields, _scanlimit, _limit, _timelimit, skipcovered);
geojsonsearch(geojson, queryhash, fields, _scanlimit, _limit, _timelimit, skipcovered);
xyzsearch(x,y,z, queryhash, fields, _scanlimit, _limit, _timelimit, skipcovered)

queryhash => a hash of the CQL query that is created and passed to allow get requests with larger queries
fields => Json definition {"fields":{"include":[],"exclude":[]}} to filter what is included in the results
_scanlimit (default 10000) total number of rows to scan through before returning
_limit (default 10) max number of rows to return
_timelimit (default 5 seconds) scan through the data for up to 5 seconds and then return what has been accumulated to that point
exitwhenfull => exit as soon as the geometry passed in is completely covered by records
skipcovered => If the geom of a record is entirely covered by the previous (by order) records, don't include it in the output (when this is set is when _scanlimit and _limit can be different)

Adds create_items and upsert_items that will take a jsonb array of json stac items and bulk load.

Fixes #31
Fixes #16

@vincentsarago
Copy link
Member

FYI an integration of the geojsonsearch function can be found over stac-utils/titiler-pgstac#5

Copy link
Member

@vincentsarago vincentsarago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@vincentsarago

This comment has been minimized.

@vincentsarago

This comment has been minimized.

@vincentsarago
Copy link
Member

vincentsarago commented Aug 18, 2021

@bitner @lossyrob I've merge this with the latest from master and remove any version number (this was previously set to 0.3.2 but we made a 0.3.2 release yesterday to fix the collections search.

Next

  • add tests
  • update version to 0.3.4 (scripts/stageversion 0.3.4)

@bitner bitner marked this pull request as ready for review August 23, 2021 20:40
@@ -31,7 +31,7 @@ services:
- PGHOST=localhost
- PGDATABASE=postgis
ports:
- "5432:5432"
- "5439:5432"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope this is ok, Basically using 5432 was in conflict with my local pg instance

@@ -104,17 +104,17 @@ BEGIN

prev_area := unionedgeom_area;

RAISE NOTICE '% % % %', st_area(unionedgeom)/tilearea, counter, scancounter, ftime();
RAISE NOTICE '% % % %', unionedgeom_area/tilearea, counter, scancounter, ftime();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid unnecessary st_area computation

IF fields IS NOT NULL THEN
out_records := out_records || filter_jsonb(iter_record.content, includes, excludes);
ELSE
out_records := out_records || iter_record.content;
END IF;

IF counter > _limit
IF counter >= _limit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because we set counter to 1 by default, if we set limit to 1, we will get 2 items

OR scancounter > _scanlimit
OR ftime() > _timelimit
OR unionedgeom_area >= tilearea
OR (skipcovered AND unionedgeom_area >= tilearea)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should only check for tile coverage if skipcovered==True

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this call should not include the skipcovered. This is the statement that returns as soon as we have covered the entire area of the geometry passed in. The skipcovered parameter is there to allow us to not include an individual item where that item would be "buried" by the other items that have already been included. I'll change this back.

Copy link
Member

@vincentsarago vincentsarago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀 🚀 🚀

@bitner bitner merged commit 0a1a655 into main Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add bulk insert function Add support for tiled search.
2 participants