diff --git a/templates/TOARDB_FASTAPI_Rest.html b/templates/TOARDB_FASTAPI_Rest.html index d682acb01549998f8ba80f4b242c0d0400e95ed3..5fb39de43569a7cf9370d79324f1680ed00e5986 100644 --- a/templates/TOARDB_FASTAPI_Rest.html +++ b/templates/TOARDB_FASTAPI_Rest.html @@ -55,7 +55,7 @@ <li><a class="reference internal" href="#search-combined-endpoint-of-stations-and-timeseries">2.6 Search (combined endpoint of stations and timeseries)</a></li> <li><a class="reference internal" href="#data">2.7 Data</a></li> <li><a class="reference internal" href="#contact-information">2.8 Contact information</a></li> -<li><a class="reference internal" href="#geolocation-urls">2.9 Geolocation URLs</a></li> +<li><a class="reference internal" href="#geopeas-urls">2.9 GeoPEAS URLs</a></li> <li><a class="reference internal" href="#database-statistics">2.10 Database statistics</a></li> </ul> </li> @@ -81,7 +81,7 @@ <li><p><strong>timeseries</strong>: query the data series id and specific metadata of a series from the database</p></li> <li><p><strong>search</strong>: query that combines the above services for stationmeta and timeseries</p></li> <li><p><strong>data</strong>: get data from one timeseries</p></li> -<li><p><strong>geolocation_urls</strong>: show how we use the geolocation services to enriche our stations metadata</p></li> +<li><p><strong>geopeas_urls</strong>: show how we use the geopeas services to enriche our stations metadata</p></li> <li><p><strong>database_statistics</strong>: show database statistics (number of users, stations, timeseries, data records</p></li> </ul> </div> @@ -335,7 +335,7 @@ <p>[{“id”:2,”codes”:[“CPT134S00”],”name”:”Cape Point”,”coordinates”:{“lat”:-34.35,”lng”:18.48,”alt”:230.0},”coordinate_validation_status”:”not checked”,”country”:”South Africa”,”state”:”Western Cape”,”type_of_environment”:”background”,”type_of_area”:”rural”,”timezone”:”Africa/Johannesburg”,”additional_metadata”:{},”roles”:[],”annotations”:[],”aux_images”:[],”aux_docs”:[],”aux_urls”:[],”globalmeta”:{“population_density_year2010”:-1.0,”max_population_density_25km_year2010”:-1.0,”climatic_zone_year2016”:”warm temperate dry”,”nightlight_1km_year2013”:-999.0,”nightlight_5km_year2013”:-999.0,”max_nightlight_25km_year2013”:-999.0,”wheat_production_year2000”:-999.0,”rice_production_year2000”:-999.0,”edgar_htap_v2_nox_emissions_year2010”:-999.0,”omi_no2_column_years2011to2015”:-999.0,”htap_region_tier1”:”-1 (undefined)”,”etopo_alt”:-999.0,”etopo_min_alt_5km”:-999.0,”etopo_relative_alt”:-999.0,”dominant_landcover_year2012”:”-1 (undefined)”,”toar1_category”:”unknown”,”station_id”:2},”changelog”:[]}]</p> <p><em><strong>Example:</strong></em> <a class="reference external" href="https://toar-data.fz-juelich.de/api/v2/stationmeta/?bounding_box=49.2,7.0,50.1,8.1&limit=None">https://toar-data.fz-juelich.de/api/v2/stationmeta/?bounding_box=49.2,7.0,50.1,8.1&limit=None</a></p> <p><em><strong>Result:</strong></em> (extremly shrinked: all metadata of stations that fall into the defined rectangle are returned!)</p> -<p>[{“id”:188,”codes”:[“DERP014”],”name”:”Hunsrück-Leisel”,<br />…<br />”changelog”:[{“datetime”:”2021-08-31T13:13:51.621321+00:00”,”description”:”station created”,”old_value”:””,”new_value”:””,”station_id”:3865,”author_id”:1,”type_of_change”:”created”},{“datetime”:”2022-02-04T22:07:40.557614+00:00”,”description”:”add climatic_zone_year2016 from geolocation service”,”old_value”:”{‘climatic_zone_year2016’: ‘Undefined’}”,”new_value”:”{‘climatic_zone_year2016’: ‘WarmTemperateDry’}”,”station_id”:3865,”author_id”:1,”type_of_change”:”single value correction in metadata”},{“datetime”:”2022-04-14T16:49:28.608142+00:00”,”description”:”add country from OSM nominatim (HIFIS instance)”,”old_value”:”{‘country’: ‘N/A’}”,”new_value”:”{‘country’: ‘DE’}”,”station_id”:3865,”author_id”:1,”type_of_change”:”single value correction in metadata”},{“datetime”:”2022-04-14T16:49:28.648002+00:00”,”description”:”add htap_tier1_region from GEO PEAS”,”old_value”:”{‘htap_region_tier1_year2010’: ‘HTAPTier1Undefined’}”,”new_value”:”{‘htap_region_tier1_year2010’: ‘HTAPTier1EUR’}”,”station_id”:3865,”author_id”:1,”type_of_change”:”single value correction in metadata”}]}]</p> +<p>[{“id”:188,”codes”:[“DERP014”],”name”:”Hunsrück-Leisel”,<br />…<br />”changelog”:[{“datetime”:”2021-08-31T13:13:51.621321+00:00”,”description”:”station created”,”old_value”:””,”new_value”:””,”station_id”:3865,”author_id”:1,”type_of_change”:”created”},{“datetime”:”2022-02-04T22:07:40.557614+00:00”,”description”:”add climatic_zone_year2016 from geopeas service”,”old_value”:”{‘climatic_zone_year2016’: ‘Undefined’}”,”new_value”:”{‘climatic_zone_year2016’: ‘WarmTemperateDry’}”,”station_id”:3865,”author_id”:1,”type_of_change”:”single value correction in metadata”},{“datetime”:”2022-04-14T16:49:28.608142+00:00”,”description”:”add country from OSM nominatim (HIFIS instance)”,”old_value”:”{‘country’: ‘N/A’}”,”new_value”:”{‘country’: ‘DE’}”,”station_id”:3865,”author_id”:1,”type_of_change”:”single value correction in metadata”},{“datetime”:”2022-04-14T16:49:28.648002+00:00”,”description”:”add htap_tier1_region from GEO PEAS”,”old_value”:”{‘htap_region_tier1_year2010’: ‘HTAPTier1Undefined’}”,”new_value”:”{‘htap_region_tier1_year2010’: ‘HTAPTier1EUR’}”,”station_id”:3865,”author_id”:1,”type_of_change”:”single value correction in metadata”}]}]</p> </div> <div class="section" id="timeseries"> <h2>2.5 Timeseries<a class="headerlink" href="#timeseries" title="Permalink to this headline"></a></h2> @@ -471,10 +471,10 @@ <p><a class="reference external" href="https://toar-data-dev.fz-juelich.de/api/v2/contacts/organisations/">https://toar-data-dev.fz-juelich.de/api/v2/contacts/organisations/[name]</a></p> <p><a class="reference external" href="https://toar-data-dev.fz-juelich.de/api/v2/contacts/organisations/">https://toar-data-dev.fz-juelich.de/api/v2/contacts/organisations/id/[id]</a></p> </div> -<div class="section" id="geolocation-urls"> -<h2>2.9 Geolocation URLs<a class="headerlink" href="#geolocation-urls" title="Permalink to this headline"></a></h2> -<p><a class="reference external" href="https://toar-data-dev.fz-juelich.de/api/v2/geolocation_urls/">https://toar-data-dev.fz-juelich.de/api/v2/geolocation_urls/</a></p> -<p>This shows how we use the geolocation services to enriche our stations metadata.</p> +<div class="section" id="geopeas-urls"> +<h2>2.9 GeoPEAS URLs<a class="headerlink" href="#geopeas-urls" title="Permalink to this headline"></a></h2> +<p><a class="reference external" href="https://toar-data-dev.fz-juelich.de/api/v2/geopeas_urls/">https://toar-data-dev.fz-juelich.de/api/v2/geopeas_urls/</a></p> +<p>This shows how we use the geopeas services to enriche our stations metadata.</p> </div> <div class="section" id="database-statistics"> <h2>2.10 Database statistics<a class="headerlink" href="#database-statistics" title="Permalink to this headline"></a></h2> diff --git a/templates/TOARDB_FASTAPI_Rest_body.md b/templates/TOARDB_FASTAPI_Rest_body.md index a113c39d1d4524b4eb5cb2b7bfa1c1c20c509ade..b50183d71b749ec8c5efa9cf50ab9ae94dcb4e8f 100644 --- a/templates/TOARDB_FASTAPI_Rest_body.md +++ b/templates/TOARDB_FASTAPI_Rest_body.md @@ -16,7 +16,7 @@ The following information services are available and described individually belo * **timeseries**: query the data series id and specific metadata of a series from the database * **search**: query that combines the above services for stationmeta and timeseries * **data**: get data from one timeseries -* **geolocation_urls**: show how we use the geolocation services to enriche our stations metadata +* **geopeas_urls**: show how we use the geopeas services to enriche our stations metadata * **database_statistics**: show database statistics (number of users, stations, timeseries, data records ## 1.3 Query arguments @@ -169,7 +169,7 @@ The second query format using a station id, works only with a given id. [{"id":188,"codes":["DERP014"],"name":"Hunsrück-Leisel", ... -"changelog":[{"datetime":"2021-08-31T13:13:51.621321+00:00","description":"station created","old_value":"","new_value":"","station_id":3865,"author_id":1,"type_of_change":"created"},{"datetime":"2022-02-04T22:07:40.557614+00:00","description":"add climatic_zone_year2016 from geolocation service","old_value":"{'climatic_zone_year2016': 'Undefined'}","new_value":"{'climatic_zone_year2016': 'WarmTemperateDry'}","station_id":3865,"author_id":1,"type_of_change":"single value correction in metadata"},{"datetime":"2022-04-14T16:49:28.608142+00:00","description":"add country from OSM nominatim (HIFIS instance)","old_value":"{'country': 'N/A'}","new_value":"{'country': 'DE'}","station_id":3865,"author_id":1,"type_of_change":"single value correction in metadata"},{"datetime":"2022-04-14T16:49:28.648002+00:00","description":"add htap_tier1_region from GEO PEAS","old_value":"{'htap_region_tier1_year2010': 'HTAPTier1Undefined'}","new_value":"{'htap_region_tier1_year2010': 'HTAPTier1EUR'}","station_id":3865,"author_id":1,"type_of_change":"single value correction in metadata"}]}] +"changelog":[{"datetime":"2021-08-31T13:13:51.621321+00:00","description":"station created","old_value":"","new_value":"","station_id":3865,"author_id":1,"type_of_change":"created"},{"datetime":"2022-02-04T22:07:40.557614+00:00","description":"add climatic_zone_year2016 from geopeas service","old_value":"{'climatic_zone_year2016': 'Undefined'}","new_value":"{'climatic_zone_year2016': 'WarmTemperateDry'}","station_id":3865,"author_id":1,"type_of_change":"single value correction in metadata"},{"datetime":"2022-04-14T16:49:28.608142+00:00","description":"add country from OSM nominatim (HIFIS instance)","old_value":"{'country': 'N/A'}","new_value":"{'country': 'DE'}","station_id":3865,"author_id":1,"type_of_change":"single value correction in metadata"},{"datetime":"2022-04-14T16:49:28.648002+00:00","description":"add htap_tier1_region from GEO PEAS","old_value":"{'htap_region_tier1_year2010': 'HTAPTier1Undefined'}","new_value":"{'htap_region_tier1_year2010': 'HTAPTier1EUR'}","station_id":3865,"author_id":1,"type_of_change":"single value correction in metadata"}]}] ## 2.5 Timeseries @@ -262,11 +262,11 @@ Result:A file containing the comma separated values of the requested time series [https://toar-data-dev.fz-juelich.de/api/v2/contacts/organisations/id/[id]](https://toar-data-dev.fz-juelich.de/api/v2/contacts/organisations/) -## 2.9 Geolocation URLs +## 2.9 GeoPEAS URLs -[https://toar-data-dev.fz-juelich.de/api/v2/geolocation_urls/](https://toar-data-dev.fz-juelich.de/api/v2/geolocation_urls/) +[https://toar-data-dev.fz-juelich.de/api/v2/geopeas_urls/](https://toar-data-dev.fz-juelich.de/api/v2/geopeas_urls/) -This shows how we use the geolocation services to enriche our stations metadata. +This shows how we use the geopeas services to enriche our stations metadata. ## 2.10 Database statistics diff --git a/templates/TOARDB_FASTAPI_Rest_content.html b/templates/TOARDB_FASTAPI_Rest_content.html index 764e7f41d96d32d4be2131cb49ae66926a735ffb..934a0d0c9f49fef66ad998fb15b1feaa3572b0d8 100644 --- a/templates/TOARDB_FASTAPI_Rest_content.html +++ b/templates/TOARDB_FASTAPI_Rest_content.html @@ -17,7 +17,7 @@ <li><a class="reference internal" href="#search-combined-endpoint-of-stations-and-timeseries">2.6 Search (combined endpoint of stations and timeseries)</a></li> <li><a class="reference internal" href="#data">2.7 Data</a></li> <li><a class="reference internal" href="#contact-information">2.8 Contact information</a></li> -<li><a class="reference internal" href="#geolocation-urls">2.9 Geolocation URLs</a></li> +<li><a class="reference internal" href="#geopeas-urls">2.9 GeoPEAS URLs</a></li> <li><a class="reference internal" href="#database-statistics">2.10 Database statistics</a></li> </ul> </li> diff --git a/toardb/stationmeta/crud.py b/toardb/stationmeta/crud.py index 6e53b404817f838580af9c0339a3b26bbec084e7..7b84e0ffd40042be747b6b98d04198dca9a0a1b1 100644 --- a/toardb/stationmeta/crud.py +++ b/toardb/stationmeta/crud.py @@ -28,7 +28,7 @@ from .models import StationmetaCore, StationmetaGlobal, StationmetaChangelog, \ from .schemas import get_coordinates_from_geom, get_geom_from_coordinates, get_abbreviation_from_code_description, get_code_description_from_abbreviation, \ Stationmeta, StationmetaCreate, StationmetaPatch, StationmetaGlobalFields, Coordinates, get_coordinates_from_string from toardb.utils.utils import get_value_from_str, get_str_from_value, get_hr_value, create_filter -from toardb.utils.settings import base_geodata_url +from toardb.utils.settings import base_geopeas_url import toardb @@ -246,7 +246,7 @@ def determine_stationmeta_global(db, tmp_coordinates, country): db_globalservices = db.query(models.StationmetaGlobalService).all() globalmeta_dict = {} for db_service in db_globalservices: - request=db_service.service_url.format(base_url=f'{base_geodata_url}',lat=tmp_coordinates["lat"],lon=tmp_coordinates["lng"], + request=db_service.service_url.format(base_url=f'{base_geopeas_url}',lat=tmp_coordinates["lat"],lon=tmp_coordinates["lng"], country=country) try: result = requests.get(request).json() diff --git a/toardb/toardb.py b/toardb/toardb.py index dc36e4febad696bf9c50d9746abc593a19b5bce9..20a440b41eeb4b91356069fdd236821bfe529b80 100644 --- a/toardb/toardb.py +++ b/toardb/toardb.py @@ -182,7 +182,7 @@ def stats_info(name: str): db_stats=json.load(f) return db_stats[name] -@app.get("/geolocation_urls/") +@app.get("/geopeas_urls/") def geo_info(db: Session = Depends(get_db)): res = db.query(models.StationmetaGlobalService).all() return res diff --git a/toardb/utils/settings.py b/toardb/utils/settings.py index 5fdcb57f48a41dc4366fc25caf66795d6bab86f7..3878c24a675d775025c63bedca9fdcd9f47c6610 100644 --- a/toardb/utils/settings.py +++ b/toardb/utils/settings.py @@ -2,5 +2,5 @@ # SPDX-License-Identifier: MIT base_url = 'https://toar-data-dev.fz-juelich.de' -base_geodata_url = 'http://zam10192.zam.kfa-juelich.de:7003' +base_geopeas_url = 'https://toar-data-dev.fz-juelich.de/geopeas/api/v1' userinfo_endpoint = 'https://login-dev.helmholtz.de/oauth2/userinfo' diff --git a/toardb/utils/utils.py b/toardb/utils/utils.py index a66e92ac31b97c6b2c0a32b48ad4bc5b04d5bbaa..9d338a2bf90681181535ed69ec5c6d5997bcdf06 100644 --- a/toardb/utils/utils.py +++ b/toardb/utils/utils.py @@ -15,7 +15,7 @@ from copy import copy import requests import datetime as dt -from toardb.utils.settings import base_geodata_url, userinfo_endpoint +from toardb.utils.settings import base_geopeas_url, userinfo_endpoint from toardb.utils.database import get_db from toardb.contacts.models import Contact, Organisation, Person from toardb.timeseries.models import Timeseries, TimeseriesRole, timeseries_timeseries_roles_table @@ -314,12 +314,12 @@ def create_filter(query_params, endpoint): # only activate the following lines if you want to update pages! ### # also get provenance information -geodata_services = [ 'topography_srtm', 'ecoregion', 'stable_nightlights', +geopeas_services = [ 'topography_srtm', 'ecoregion', 'stable_nightlights', 'climatic_zone', 'nox_emissions', 'landcover', 'major_road', 'population_density', 'htap_region_tier1' ] provenance = {} -#for service in geodata_services: -# result = requests.get(f"{base_geodata_url}/{service}/").json() +#for service in geopeas_services: +# result = requests.get(f"{base_geopeas_url}/{service}/").json() # provenance[service] = result['provenance'] # # major_road has different dict entries # tmp_provenance = copy(provenance[service]) @@ -333,6 +333,6 @@ provenance = {} # provenance[service] = tmp_provenance # except: # continue -for service in geodata_services: +for service in geopeas_services: provenance[service] = "dummy text"