Skip to content

Commit

Permalink
Update OWDP UI to color code based on org (#42)
Browse files Browse the repository at this point in the history
- Implements https://github.com/cgs-earth/hub2box-ui/tree/owdp
- Uses common field name for organization in odwr
- Serve unquoted FROST entities that require single quotes around
`@iot.id`

Note: Requires clearing existing STA database to implement

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
webb-ben and pre-commit-ci[bot] authored Jan 21, 2025
1 parent 76c9f34 commit b64809f
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ services:
- SCRIPT_NAME=/oapi

owdp-ui:
image: internetofwater/hub2box-ui:iow
image: internetofwater/hub2box-ui:owdp
container_name: owdp-ui
depends_on:
- owdp-pygeoapi
Expand Down
1 change: 1 addition & 0 deletions docker/frost/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ENV persistence_idGenerationMode=ServerAndClientGenerated
ENV plugins_coreModel_idType_thing=STRING
ENV plugins_coreModel_idType_location=STRING
ENV plugins_coreModel_idType_datastream=STRING
ENV plugins_coreModel_idType_feature=STRING
ENV mqtt_Enabled=false
# log after 1000ms or 1 second queries
ENV persistence.slowQueryThreshold=1000
6 changes: 6 additions & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ http {
location /FROST-Server {
proxy_hide_header Access-Control-Allow-Origin;
proxy_pass http://owdp-frost:8080;
error_page 404 = @retry_with_quotes;
}
location @retry_with_quotes {
proxy_hide_header Access-Control-Allow-Origin;
rewrite ^(/FROST-Server/.+\()(.+)(\)) $1'$2'$3 break;
proxy_pass http://owdp-frost:8080;
}
location / {
proxy_pass http://owdp-ui:80;
Expand Down
22 changes: 9 additions & 13 deletions docker/pygeoapi/pygeoapi.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,19 @@ logging:
metadata:
identification:
title:
en: "HubKit in a box"
en: "Oregon Water Data Portal OGC API Server"
description:
en: |
HubKit provides a platform for organizations to integrate their
data holdings and publish them according to Internet of Water
principles and Spatial Data on the Web Best Practices with
plug-and-play capability supporting data access through OGC
API standards and data discovery through geoconnex.us.
It leverages several open source projects, including
pygeoapi, FROST-Server, and the WMO wis2box.
The Oregon Water Data Portal (OWDP) is a pilot project aiming to
create a comprehensive, user-friendly platform for accessing and
analyzing water-related data specific to Oregon. The initial phase
focuses on integrating key data sources, with an emphasis on water
temperature data, to demonstrate the value of a centralized water
data hub in supporting research, policymaking, and public awareness.
keywords:
en:
- "hubkit"
- "hub2box"
- "wis2box"
- "owdp"
- "oregon"
keywords_type: "theme"
terms_of_service: "https://creativecommons.org/licenses/by/4.0/"
url: "https://github.com/internetofwater/"
Expand Down Expand Up @@ -116,7 +114,6 @@ resources:
title_field: "name"
intralink: true
expand: Thing/Locations,Observations([email protected];$orderby=phenomenonTime desc;$top=1),Observations/FeatureOfInterest($select=feature),Sensor,ObservedProperty
storage_crs: http://www.opengis.net/def/crs/EPSG/0/3857
links:
- type: "text/html"
rel: "canonical"
Expand Down Expand Up @@ -151,7 +148,6 @@ resources:
id_field: "@iot.id"
time_field: "resultTime"
intralink: true
storage_crs: http://www.opengis.net/def/crs/EPSG/0/3857
links:
- type: "text/html"
rel: "canonical"
Expand Down
7 changes: 7 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# =================================================================
#
# Copyright (c) 2025 Lincoln Institute of Land Policy
#
# Licensed under the MIT License.
#
# =================================================================
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/odwr/test_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
from userCode.ontology import ONTOLOGY_MAPPING
from userCode.env import API_BACKEND_URL
from userCode.odwr.dag import all_metadata, post_station, sta_station
from userCode.odwr.helper_classes import get_datastream_time_range, MockValues
from userCode.helper_classes import get_datastream_time_range, MockValues
from userCode.odwr.lib import assert_no_observations_with_same_iotid_in_first_page
from userCode.odwr.types import StationData
from userCode.util import to_oregon_datetime


from .lib import (
from ..lib import (
assert_no_duplicate_at_given_time,
assert_observations_and_datastreams_empty,
dates_are_within_X_days,
Expand Down
4 changes: 2 additions & 2 deletions tests/odwr/test_frost.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import requests

from userCode.env import API_BACKEND_URL
from userCode.odwr.helper_classes import (
from userCode.helper_classes import (
TimeRange,
get_datastream_time_range,
)
from .lib import (
from ..lib import (
wipe_datastreams,
wipe_locations,
wipe_observed_properties,
Expand Down
2 changes: 1 addition & 1 deletion tests/odwr/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from hypothesis import given, strategies as st
import pytest

from .lib import wipe_datastreams, wipe_locations, wipe_things
from ..lib import wipe_datastreams, wipe_locations, wipe_things
from userCode.odwr.lib import (
assert_valid_oregon_date,
download_oregon_tsv,
Expand Down
File renamed without changes.
6 changes: 1 addition & 5 deletions userCode/odwr/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@
from typing import List, Optional, Tuple

from userCode.env import API_BACKEND_URL, RUNNING_AS_A_TEST_NOT_IN_PROD
from userCode.odwr.helper_classes import (
BatchHelper,
get_datastream_time_range,
)
from userCode.helper_classes import BatchHelper, get_datastream_time_range, MockValues
from userCode.odwr.lib import (
fetch_station_metadata,
generate_oregon_tsv_url,
Expand All @@ -43,7 +40,6 @@
to_sensorthings_observation,
to_sensorthings_station,
)
from userCode.odwr.helper_classes import MockValues
from userCode.odwr.types import (
ALL_RELEVANT_STATIONS,
POTENTIAL_DATASTREAMS,
Expand Down
1 change: 1 addition & 0 deletions userCode/odwr/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def fetch_station_metadata(station_numbers: list[int]) -> OregonHttpResponse:
"where": format_where_param(station_numbers),
"outFields": "*",
"f": "json",
"outSR": "4326",
}
url = BASE_OREGON_URL + urlencode(params)
get_dagster_logger().info(f"Fetching {url} to get all station metadata")
Expand Down
2 changes: 1 addition & 1 deletion userCode/odwr/sta_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def to_sensorthings_station(station: StationData) -> dict:
},
}
],
"properties": attr.model_dump(by_alias=True),
"properties": attr.model_dump(),
}
if attr.elevation is not None:
representation["Locations"][0]["location"]["coordinates"].append(attr.elevation)
Expand Down
4 changes: 2 additions & 2 deletions userCode/odwr/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# =================================================================

from typing import Literal, Optional, TypedDict
from pydantic import BaseModel
from pydantic import BaseModel, Field
from dataclasses import dataclass

BASE_OREGON_URL: str = "https://gis.wrd.state.or.us/server/rest/services/dynamic/Gaging_Stations_WGS84/FeatureServer/2/query?"
Expand Down Expand Up @@ -199,7 +199,7 @@ class Attributes(BaseModel):
elevation: Optional[int]
elevation_datum: Optional[float]
current_operation_mode: Optional[str]
most_recent_operator: str
organization: str = Field(alias="most_recent_operator")
cooperators: Optional[str]
published_area: Optional[float]
owrd_area: Optional[float]
Expand Down

0 comments on commit b64809f

Please sign in to comment.