Skip to content

Commit

Permalink
Updates to the sparql provider to match the mainstem query (#22)
Browse files Browse the repository at this point in the history
* Query Mainstems and Gages with SPARQL provider (7261757324)

* Update SPARQL provider

* Use pygeoapi root image

* updates to the sparql provider to match the mainstem query

* updated docker compose

* update readme

* Update pygeoapi.config.yml

Co-authored-by: Benjamin Webb <[email protected]>

* Update docker-compose.yml

Co-authored-by: Benjamin Webb <[email protected]>

* reversions

* indent

* indent again for diff

* update sparql config

* change back to error

* add indent

* Update pygeoapi.config.yml

---------

Co-authored-by: Benjamin Webb <[email protected]>
  • Loading branch information
C-Loftus and webb-ben committed Sep 17, 2024
1 parent 57dd55f commit ec6fb38
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 47 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


*.sql.gz
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
FROM geopython/pygeoapi:latest
#pygeoapi last updated 2023-07-31

#add requirements and mods
COPY ./pygeoapi.config.yml /pygeoapi/local.config.yml

# COPY ./schemas.opengis.net /opt/schemas.opengis.net
COPY ./pygeoapi-skin-dashboard /skin-dashboard

COPY ./pygeoapi.config.yml /pygeoapi/local.config.yml

RUN pip3 install https://github.com/cgs-earth/pygeoapi-plugins/archive/refs/heads/master.zip

COPY ./sitemap /sitemap
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,23 @@ These reference features are intended to be ["community reference locations"](ht

## Install

Generate a SQL Dump of the Hydroshare resource using [Hydrodump Action](https://github.com/cgs-earth/hydrodump-action).

Then use docker compose to bring up the containers:
Use docker compose to bring up the containers:

```
docker compose up -d database
docker compose up -d pygeoapi
```

Then generate a SQL Dump of the Hydroshare resource using [Hydrodump Action](https://github.com/cgs-earth/hydrodump-action).

```
docker compose up -d hydrodump
```

If you have a local hydrodump `reference.sql.gz` file, you can use that instead of regenerating the dump using

```
docker compose up -d local
```


30 changes: 28 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# dont need this anymore, but useful for test deployment
# requires separate service providing postgres database
services:
pygeoapi:
build: .
container_name: reference-geoconnex-us
ports:
- 5000:80
volumes:
- ./pygeoapi.config.yml:/pygeoapi/local.config.yml
env_file:
- .env

Expand All @@ -14,10 +14,36 @@ services:
image: postgis/postgis:14-3.2-alpine
env_file:
- .env
volumes:
- db_data:/var/lib/postgresql/data

hydrodump:
container_name: hydrodump
image: ghcr.io/cgs-earth/hydrodump-action:latest
command: ["hydrodump", "run"]
env_file:
- .env

local:
# Instead of using a remote hydrodump, you can source a local database dump, reference.sql.gz
container_name: local
image: postgis/postgis:14-3.2-alpine
depends_on:
- database
volumes:
- ./reference.sql.gz:/docker-entrypoint-initdb.d/reference.sql.gz
entrypoint: >
sh -c "
export PGPASSWORD=${POSTGRES_PASSWORD} && \
echo 'Waiting for database to be ready...' && \
while ! pg_isready -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d ${POSTGRES_DB}; do
sleep 1
done && \
echo 'Database is ready. Starting migration...' && \
gunzip -c /docker-entrypoint-initdb.d/reference.sql.gz | psql -h ${POSTGRES_HOST} -U ${POSTGRES_USER} -d ${POSTGRES_DB}
"
env_file:
- .env

volumes:
db_data:
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ <h2 class="mx-auto">Datasets</h2>
map.addLayer(items);
map.fitBounds(items.getBounds(), {maxZoom: 10});
</script>
{% endblock %}
{% endblock %}
2 changes: 1 addition & 1 deletion pygeoapi-skin-dashboard/templates/jsonld/hu06.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
],
"gsp:hasGeometry": {{ data['gsp:hasGeometry'] | to_json }},
"geo": {{ data['schema:geo'] | to_json | safe }}
}
}
69 changes: 32 additions & 37 deletions pygeoapi.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -404,62 +404,57 @@ resources:
bind:
name: uri
variable: '?mainstem'
select: '?mainstem ?monitoringLocation ?siteName ?datasetDescription ?type ?url ?variableMeasured ?variableUnit ?measurementTechnique ?temporalCoverage ?wkt'
select: '?mainstem ?monitoringLocation ?siteName ?datasetDescription ?type ?url ?variableMeasured ?variableUnit ?measurementTechnique ?temporalCoverage ?distributionName ?distributionURL ?distributionFormat ?wkt'
where:
- subject: '?monitoringLocation'
predicate: hyf:referencedPosition/hyf:HY_IndirectPosition/hyf:linearElement
object: '?mainstem'
predicate: 'hyf:HydroLocationType'
object: '?type'
- subject: '?monitoringLocation'
predicate: schema:name
object: '?siteName'
predicate: 'hyf:referencedPosition/hyf:HY_IndirectPosition/hyf:linearElement'
object: '?mainstem'
- subject: '?monitoringLocation'
predicate: schema:subjectOf
predicate: 'schema:subjectOf'
object: '?dataset'
- subject: '?monitoringLocation'
predicate: 'gsp:hasGeometry/gsp:asWKT'
object: '?wkt'
- subject: '?dataset'
predicate: schema:url
predicate: 'schema:variableMeasured'
object: '?var'
- subject: '?dataset'
predicate: 'schema:url'
object: '?url'
- subject: '?dataset'
predicate: schema:distribution
predicate: 'schema:distribution'
object: '?distribution'
- subject: '?distribution'
predicate: schema:name
object: '?distributionName'
- subject: '?distribution'
predicate: schema:contentUrl
object: '?distributionURL'
- subject: '?distribution'
predicate: schema:encodingFormat
object: '?distributionFormat'
- subject: '?dataset'
predicate: schema:description
predicate: 'schema:description'
object: '?datasetDescription'
- subject: '?monitoringLocation'
predicate: hyf:HydroLocationType
object: '?type'
- subject: '?dataset'
predicate: 'schema:variableMeasured'
object: '?variableMeasured_'
- subject: '?variableMeasured_'
predicate: 'schema:temporalCoverage'
object: '?temporalCoverage'
- subject: '?dataset'
predicate: 'schema:name'
object: '?siteName'
- subject: '?var'
predicate: 'schema:name'
object: '?variableMeasured'
- subject: '?variableMeasured_'
- subject: '?var'
predicate: 'schema:unitText'
object: '?variableUnit'
- subject: '?variableMeasured_'
- subject: '?var'
predicate: 'schema:measurementTechnique'
object: '?measurementTechnique'
- subject: '?variableMeasured_'
predicate: 'schema:name'
object: '?variableMeasured'
- subject: '?dataset'
predicate: 'schema:temporalCoverage'
object: '?temporalCoverage'
- subject: '?dataset'
predicate: 'schema:provider'
object: '?provider'
- subject: '?provider'
- subject: '?distribution'
predicate: 'schema:name'
object: '?datasetProvider'
object: '?distributionName'
- subject: '?distribution'
predicate: 'schema:contentUrl'
object: '?distributionURL'
- subject: '?distribution'
predicate: 'schema:encodingFormat'
object: '?distributionFormat'

dams: # updated 2024-04-23
type: collection
title: Reference Dams
Expand Down

0 comments on commit ec6fb38

Please sign in to comment.