-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,356 additions
and
572 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -50,6 +50,7 @@ coverage.xml | |
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
*/pytest-coverage* | ||
cover/ | ||
|
||
# Translations | ||
|
This file contains 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 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 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,43 @@ | ||
from fastapi import HTTPException | ||
from geojson_pydantic import Feature | ||
from geojson_pydantic import FeatureCollection | ||
from geojson_pydantic import Point | ||
|
||
|
||
def _make_properties(ts): | ||
ts_metadata = {key.name: value for key, value in ts.ts_mdata.ListFields() if value} | ||
|
||
ts_metadata["platform_vocabulary"] = ( | ||
"https://oscar.wmo.int/surface/#/search/station/stationReportDetails/" + ts.ts_mdata.platform | ||
if not ts.ts_mdata.platform_vocabulary | ||
else ts.ts_mdata.platform_vocabulary | ||
) | ||
# This should also be compatible with future when name is added to datastore | ||
if "name" not in ts_metadata: | ||
ts_metadata["name"] = ts.ts_mdata.platform # TODO: grab proper name when implemented in proto | ||
|
||
return ts_metadata | ||
|
||
|
||
def convert_to_geojson(response): | ||
""" | ||
Will only generate geoJSON for stationary timeseries | ||
""" | ||
features = [ | ||
Feature( | ||
type="Feature", | ||
id=ts.ts_mdata.timeseries_id, | ||
properties=_make_properties(ts=ts), | ||
geometry=Point( | ||
type="Point", | ||
coordinates=[ | ||
ts.obs_mdata[0].geo_point.lon, | ||
ts.obs_mdata[0].geo_point.lat, | ||
], | ||
), | ||
) | ||
for ts in sorted(response.observations, key=lambda ts: ts.ts_mdata.timeseries_id) | ||
] | ||
if not features: | ||
raise HTTPException(404, detail="Query did not return any time series.") | ||
return FeatureCollection(features=features, type="FeatureCollection") if len(features) > 1 else features[0] |
This file contains 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 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 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 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 |
---|---|---|
|
@@ -12,3 +12,5 @@ covjson-pydantic~=0.2.0 | |
edr-pydantic~=0.2.0 | ||
shapely~=2.0 | ||
geojson-pydantic~=1.0 | ||
aiocached~=0.3.0 | ||
jinja2~=3.1 |
This file contains 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
Oops, something went wrong.
6b8018a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API Unit Test Coverage Report
API Unit Test Coverage Summary