-
Notifications
You must be signed in to change notification settings - Fork 48
Add load_queryables function to pypgstac
#361
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
653767e
feat: add load_queryables function and support for collection IDs; up…
emmanuelmathot 59c4b32
refactor: update load_queryables to accept a list for collection IDs;…
emmanuelmathot fcc9a2c
feat: add delete_missing option to load_queryables; update examples a…
emmanuelmathot 84b4d5e
docs: update load_queryables documentation to reflect new syntax and …
emmanuelmathot 3b7b4e0
feat: add index_fields option to load queryables for customizable ind…
emmanuelmathot 5469f2d
docs: update pypgstac documentation to include index_fields option fo…
emmanuelmathot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,5 @@ src/pypgstac/target | |
| src/pypgstac/python/pypgstac/*.so | ||
| .vscode | ||
| .ipynb_checkpoints | ||
| .venv | ||
| .pytest_cache | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/usr/bin/env python | ||
| """ | ||
| Example script demonstrating how to load queryables into PgSTAC. | ||
|
|
||
| This script shows how to use the load_queryables function both from the command line | ||
| and programmatically. | ||
| """ | ||
|
|
||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| # Add the parent directory to the path so we can import pypgstac | ||
| sys.path.append(str(Path(__file__).parent.parent)) | ||
|
|
||
| from pypgstac.pypgstac import PgstacCLI | ||
|
|
||
|
|
||
| def load_for_specific_collections(cli, sample_file, collection_ids): | ||
| """Load queryables for specific collections.""" | ||
| cli.load_queryables(str(sample_file), collection_ids=collection_ids) | ||
|
|
||
|
|
||
| def main(): | ||
| """Demonstrate loading queryables into PgSTAC.""" | ||
| # Get the path to the sample queryables file | ||
| sample_file = Path(__file__).parent / "sample_queryables.json" | ||
|
|
||
| # Check if the file exists | ||
| if not sample_file.exists(): | ||
| return | ||
|
|
||
|
|
||
| # Create a PgstacCLI instance | ||
| # This will use the standard PostgreSQL environment variables for connection | ||
| cli = PgstacCLI() | ||
|
|
||
| # Load queryables for all collections | ||
| cli.load_queryables(str(sample_file)) | ||
|
|
||
| # Example of loading for specific collections | ||
| # Uncomment the following line to test with specific collections | ||
| load_for_specific_collections(cli, sample_file, "landsat-8,sentinel-2") | ||
|
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2019-09/schema", | ||
| "$id": "https://example.com/stac/queryables", | ||
| "type": "object", | ||
| "title": "Queryables for Example STAC API", | ||
| "description": "Queryable names for the Example STAC API", | ||
| "properties": { | ||
| "id": { | ||
| "description": "Item identifier", | ||
| "type": "string" | ||
| }, | ||
| "collection": { | ||
| "description": "Collection identifier", | ||
| "type": "string" | ||
| }, | ||
| "datetime": { | ||
| "description": "Datetime", | ||
| "type": "string", | ||
| "format": "date-time" | ||
| }, | ||
| "geometry": { | ||
| "description": "Geometry", | ||
| "type": "object" | ||
| }, | ||
| "eo:cloud_cover": { | ||
| "description": "Cloud cover percentage", | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "maximum": 100 | ||
| }, | ||
| "platform": { | ||
| "description": "Platform name", | ||
| "type": "string", | ||
| "enum": ["landsat-8", "sentinel-2"] | ||
| }, | ||
| "instrument": { | ||
| "description": "Instrument name", | ||
| "type": "string" | ||
| }, | ||
| "gsd": { | ||
| "description": "Ground sample distance in meters", | ||
| "type": "number" | ||
| }, | ||
| "view:off_nadir": { | ||
| "description": "Off-nadir angle in degrees", | ||
| "type": "number" | ||
| }, | ||
| "view:sun_azimuth": { | ||
| "description": "Sun azimuth angle in degrees", | ||
| "type": "number" | ||
| }, | ||
| "view:sun_elevation": { | ||
| "description": "Sun elevation angle in degrees", | ||
| "type": "number" | ||
| }, | ||
| "sci:doi": { | ||
| "description": "Digital Object Identifier", | ||
| "type": "string" | ||
| }, | ||
| "created": { | ||
| "description": "Date and time the item was created", | ||
| "type": "string", | ||
| "format": "date-time" | ||
| }, | ||
| "updated": { | ||
| "description": "Date and time the item was last updated", | ||
| "type": "string", | ||
| "format": "date-time" | ||
| }, | ||
| "landcover:classes": { | ||
| "description": "Land cover classes", | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": true | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/pypgstac/tests/data-files/queryables/test_queryables.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2019-09/schema", | ||
| "$id": "https://example.com/stac/queryables", | ||
| "type": "object", | ||
| "title": "Test Queryables for PgSTAC", | ||
| "description": "Test queryable names for PgSTAC", | ||
| "properties": { | ||
| "id": { | ||
| "description": "Item identifier", | ||
| "type": "string" | ||
| }, | ||
| "collection": { | ||
| "description": "Collection identifier", | ||
| "type": "string" | ||
| }, | ||
| "datetime": { | ||
| "description": "Datetime", | ||
| "type": "string", | ||
| "format": "date-time" | ||
| }, | ||
| "geometry": { | ||
| "description": "Geometry", | ||
| "type": "object" | ||
| }, | ||
| "test:string_prop": { | ||
| "description": "Test string property", | ||
| "type": "string" | ||
| }, | ||
| "test:number_prop": { | ||
| "description": "Test number property", | ||
| "type": "number", | ||
| "minimum": 0, | ||
| "maximum": 100 | ||
| }, | ||
| "test:integer_prop": { | ||
| "description": "Test integer property", | ||
| "type": "integer" | ||
| }, | ||
| "test:datetime_prop": { | ||
| "description": "Test datetime property", | ||
| "type": "string", | ||
| "format": "date-time" | ||
| }, | ||
| "test:array_prop": { | ||
| "description": "Test array property", | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| } | ||
| } | ||
| }, | ||
| "additionalProperties": true | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.