From 689cac7dc8217ea74aafa9b7b7f7923143bd2ac8 Mon Sep 17 00:00:00 2001 From: Benjamin Webb <40066515+webb-ben@users.noreply.github.com> Date: Wed, 29 Jan 2025 17:53:25 -0700 Subject: [PATCH] Add WQP stations --- sta.config.yml | 26 ++---- templates/wqp-location-oriented.j2 | 143 +++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 templates/wqp-location-oriented.j2 diff --git a/sta.config.yml b/sta.config.yml index e8bfd88..d9b2dcb 100644 --- a/sta.config.yml +++ b/sta.config.yml @@ -41,7 +41,9 @@ server: - fr-CA # cors: true pretty_print: true - limit: 100 + limits: + default_items: 100 + max_items: 50000 map: url: https://tile.openstreetmap.org/{z}/{x}/{y}.png attribution: '© OpenStreetMap contributors' @@ -427,34 +429,26 @@ resources: # name: SensorThings # data: https://nmenv.newmexicowaterdata.org/FROST-Server/v1.1/Observations - WQIE/Things: + WQP/Things: type: collection - title: WQIE Things - description: WQP Water Quality Interoperability Experiment SensorThings API Things + title: WQP Things + description: Water Quality Portal SensorThings API Things keywords: *things-keywords linked-data: - context: - - sosa: "http://www.w3.org/ns/sosa/" - ssn: "http://www.w3.org/ns/ssn/" - Datastreams: schema:subjectOf - name: schema:name + item_template: wqp-location-oriented.j2 links: - type: application/html rel: canonical title: data source - href: https://dww.water.net.env.nm.gov/NMDWW/ - hreflang: en-US - - type: application/html - rel: canonical - title: data source - href: https://catalog.newmexicowaterdata.org/dataset/sdwis + href: https://www.waterqualitydata.us hreflang: en-US extents: *us-extents providers: - type: feature name: SensorThings - data: https://wqp.wqie.internetofwater.app/FROST-Server/v1.1/Things + data: https://wqp.internetofwater.app/FROST-Server/v1.1/Things name_field: name + expand: Locations,Datastreams/ObservedProperty # WQIE-WQP/Datastreams: # type: collection diff --git a/templates/wqp-location-oriented.j2 b/templates/wqp-location-oriented.j2 new file mode 100644 index 0000000..ea8c1d9 --- /dev/null +++ b/templates/wqp-location-oriented.j2 @@ -0,0 +1,143 @@ +{ + "@context": { + "@vocab": "https://schema.org/", + "xsd": "https://www.w3.org/TR/xmlschema-2/#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "dc": "http://purl.org/dc/terms/", + "dcat": "https://www.w3.org/ns/dcat#", + "freq": "http://purl.org/cld/freq/", + "qudt": "http://qudt.org/schema/qudt/", + "qudt-units": "http://qudt.org/vocab/unit/", + "qudt-quantkinds": "http://qudt.org/vocab/quantitykind/", + "gsp": "http://www.opengis.net/ont/geosparql#", + "locType": "http://vocabulary.odm2.org/sitetype", + "odm2var":"http://vocabulary.odm2.org/variablename/", + "odm2varType": "http://vocabulary.odm2.org/variabletype/", + "hyf": "https://www.opengis.net/def/schema/hy_features/hyf/", + "skos": "https://www.opengis.net/def/schema/hy_features/hyf/HY_HydroLocationType", + "ssn": "http://www.w3.org/ns/ssn/", + "ssn-system": "http://www.w3.org/ns/ssn/systems/" + }, + "@id": "{{ data['@id'] }}", + "@type": [ + "hyf:HY_HydrometricFeature", + "hyf:HY_HydroLocation", + {% if data['monitoringLocationType'] %} + "locType:{{ data['monitoringLocationType'] }}" + {% endif %} + ], + + + {%- if data['monitoringLocationType'] %} + "hyf:HydroLocationType": "{{ data['monitoringLocationType'] }}", + {% endif -%} + + {% set id = data['id'] | trim("'") %} + "identifier": { + "@type": "PropertyValue", + "propertyID": "WQP Site identifier", + "value": "{{ id }}" + }, + {%- if data['name'] %} + "name": "{{ data['name'] }}", + {% endif -%} + + {%- if data['locations'] and data['locations'][0]['description'] %} + "description": "{{ data['locations'][0]['description'] }}", + {% endif -%} + "provider": { + "url": "https://www.waterqualitydata.us", + "@type": "GovernmentOrganization", + "name": "{{ data['OrganizationFormalName'] }}" + }, + {%- if data['schema:geo'] %} + "geo": {{ data['schema:geo'] | to_json }}, + {% endif -%} + {%- if data['gsp:hasGeometry'] %} + "gsp:hasGeometry": { + "@type": "{{ data['gsp:hasGeometry']['@type'] }}", + "gsp:asWKT": {{ data['gsp:hasGeometry']['gsp:asWKT'] | to_json }}, + "gsp:crs": { + "@id": "http://www.opengis.net/def/crs/OGC/1.3/CRS84" + } + }, + {% endif -%} + + {%- if data["mainstem"] %} + "hyf:referencedPosition": { + "hyf:HY_IndirectPosition": { + "hyf:linearElement": { + {# Assumes we can hard code 0 since this template is location-oriented and thus all date is related to one location#} + "@id": "{{ data['mainstem'] }}" + } + } + }, + {% endif -%} + + {%- if data["hu08"] -%} + "hyf:containingCatchment": [ + { + "@id": "{{ data['hu08'] }}" + } + ], + {% endif -%} + + "subjectOf": [ + {%- for stream in data['Datastreams'] %} + { + "@type": "Dataset", + "name": "{{ id }}", + + {%- if stream['description'] %} + "description": "{{ stream["description"]}}", + {% endif -%} + + "provider": { + "url": "https://www.waterqualitydata.us", + "@type": "GovernmentOrganization", + "name": "{{ data['OrganizationFormalName'] }}" + }, + {%- if data['station_url'] %} + "url": "{{ data['station_url'] }}", + {% endif -%} + + "variableMeasured": { + "@type": "PropertyValue", + "name": "{{ stream['ObservedProperty']['name'] }}", + + {%- if stream['unitOfMeasurement']['name'] %} + "description": "{{ stream['ObservedProperty']['name'] }} in {{ stream['unitOfMeasurement']['name'] }}", + {% endif -%} + + "propertyID": "{{ stream['ObservedProperty']['definition'].split('/')[-1] }}", + "url": "{{ stream['ObservedProperty']['definition'] }}", + + {%- if stream['unitOfMeasurement']['name'] %} + "unitText": "{{ stream['unitOfMeasurement']['name'] }}", + {% endif -%} + + "measurementTechnique": "observation", + "measurementMethod": { + "name": "{{ stream['ObservedProperty']['name'] }} Measurements", + "publisher": "{{ data['OrganizationFormalName'] }}" + } + }, + {%- if stream['phenomenonTime'] %} + "temporalCoverage": "{{ stream['phenomenonTime'] }}", + {% endif -%} + "distribution": [ + { + "@type": "DataDownload", + "name": "Water Quality Portal", + "contentUrl": "https://www.waterqualitydata.us/data/Result/search?siteid={{ id }}&CharacteristicName={{ stream['ObservedProperty']['name'] }}&mimeType=csv", + "encodingFormat": [ + "text/comma-separated-values" + ], + "dc:conformsTo": "https://www.waterqualitydata.us/webservices_documentation/" + } + ] + } + {%- if not loop.last %},{% endif -%} + {% endfor -%} + ] +}