a- add all gschliefgraben-Glasfaser sensors
This commit is contained in:
parent
8621510230
commit
fb010174b7
99
db/insert_initial_values.txt
Normal file
99
db/insert_initial_values.txt
Normal file
|
@ -0,0 +1,99 @@
|
|||
|
||||
|
||||
INSERT INTO gba.category(
|
||||
category_id, identifier, name, description)
|
||||
VALUES (1, 'SOS', 'SOS', 'Default SOS category');
|
||||
|
||||
|
||||
INSERT INTO gba.codespace(
|
||||
codespace_id, name)
|
||||
VALUES (1, 'http://www.opengis.net/def/nil/OGC/0/unknown');
|
||||
|
||||
INSERT INTO gba.format(
|
||||
format_id, definition) VALUES
|
||||
(1, 'http://www.opengis.net/sensorml/2.0'),
|
||||
(2, 'http://inspire.ec.europa.eu/featureconcept/PointObservation'),
|
||||
(3, 'http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement'),
|
||||
(4, 'http://inspire.ec.europa.eu/featureconcept/PointTimeSeriesObservation'),
|
||||
(5, 'http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint'),
|
||||
(6, 'http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_TextObservation'),
|
||||
(7, 'application/vnd.geo+json'),
|
||||
(8, 'http://www.opengis.net/def/nil/OGC/0/unknown'),
|
||||
(9, 'http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_CategoryObservation');
|
||||
|
||||
INSERT INTO gba.phenomenon(
|
||||
phenomenon_id, identifier, sta_identifier, name) VALUES
|
||||
(1, 'RainfallAccumulated', 'RainfallAccumulated', 'RainfallAccumulated'),
|
||||
(2, 'WindDirection', 'WindDirection', 'WindDirection'),
|
||||
(3, 'Humidity', 'Humidity', 'Humidity'),
|
||||
(4, 'Windchill', 'Windchill', 'Windchill'),
|
||||
(5, 'AirTemperature', 'AirTemperature', 'AirTemperature'),
|
||||
(6, 'Dewpoint', 'Dewpoint', 'Dewpoint'),
|
||||
(7, 'Luminance', 'Luminance', 'Luminance'),
|
||||
(8, 'AthmosphericPressure', 'AthmosphericPressure', 'AthmosphericPressure'),
|
||||
(9, 'WindSpeed', 'WindSpeed', 'WindSpeed'),
|
||||
(10, 'Sunshine', 'Sunshine', 'Sunshine'),
|
||||
(11, 'HailAccumulated', 'HailAccumulated', 'HailAccumulated'),
|
||||
(12, 'WindSpeedMinimum', 'WindSpeedMinimum', 'WindSpeedMinimum'),
|
||||
(13, 'WindSpeedAverage', 'WindSpeedAverage', 'WindSpeedAverage'),
|
||||
(14, 'HailIntensity', 'HailIntensity', 'HailIntensity'),
|
||||
(15, 'RainfallPeakIntensity', 'RainfallPeakIntensity', 'RainfallPeakIntensity'),
|
||||
(16, 'WindSpeedMaximum', 'WindSpeedMaximum', 'WindSpeedMaximum'),
|
||||
(17, 'WindDirectionMaximum', 'WindDirectionMaximum', 'WindDirectionMaximum'),
|
||||
(18, 'RainfallIntensity', 'RainfallIntensity', 'RainfallIntensity'),
|
||||
(19, 'WindDirectionMinimum', 'WindDirectionMinimum', 'WindDirectionMinimum'),
|
||||
(20, 'HailDuration', 'HailDuration', 'HailDuration'),
|
||||
(21, 'RainfallDuration', 'RainfallDuration', 'RainfallDuration'),
|
||||
(22, 'InSystemTemperature', 'InSystemTemperature', 'InSystemTemperature'),
|
||||
(23, 'HailPeakIntensity', 'HailPeakIntensity', 'HailPeakIntensity'),
|
||||
(24, 'WindDirectionAverage', 'WindDirectionAverage', 'WindDirectionAverage'),
|
||||
(25, 'WindMaxGust', 'WindMaxGust', 'WindMaxGust'),
|
||||
(26, 'Visibility', 'Visibility', 'Visibility'),
|
||||
(27, 'WindSpeedKmh', 'WindSpeedKmh', 'WindSpeedKmh'),
|
||||
(28, 'WindSpeedBft', 'WindSpeedBft', 'WindSpeedBft'),
|
||||
(29, 'WindSpeedMperSec', 'WindSpeedMperSec', 'WindSpeedMperSec'),
|
||||
(30, 'ShortwaveRadiation', 'ShortwaveRadiation', 'ShortwaveRadiation'),
|
||||
(31, 'WeatherCode', 'WeatherCode', 'WeatherCode'),
|
||||
(32, 'WeatherCodeText', 'WeatherCodeText', 'WeatherCodeText'),
|
||||
(33, 'WindDirectionText', 'WindDirectionText', 'WindDirectionText'),
|
||||
(34, 'Roll', 'Roll', 'Roll'),
|
||||
(35, 'Slope', 'Slope', 'Slope'),
|
||||
(36, 'HumanVisualPerception', 'HumanVisualPerception', 'HumanVisualPerception'),
|
||||
(37, 'Elevation', 'Elevation', 'Elevation');
|
||||
|
||||
|
||||
INSERT INTO gba.unit(
|
||||
unit_id, symbol) VALUES
|
||||
(1, 'klux'),
|
||||
(2, 'hPa'),
|
||||
(3, 'degC'),
|
||||
(4, '%'),
|
||||
(5, 'km_h'),
|
||||
(6, 'min'),
|
||||
(7, 'l_m^2'),
|
||||
(8, 'deg'),
|
||||
(9, 'm_s'),
|
||||
(10, 'mm_h'),
|
||||
(11, 's'),
|
||||
(12, 'hits_cm-2_h'),
|
||||
(13, 'hits_cm-2'),
|
||||
(14, 'mm'),
|
||||
(15, 'W_m^2'),
|
||||
(16, 'bft'),
|
||||
(17, 'm');
|
||||
|
||||
offering observation_type 9 10, 11
|
||||
PointObservation, OM_Measurement, PointTimeSeriesObservation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,34 +1,35 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""This module does blah blah."""
|
||||
|
||||
from ast import List
|
||||
import requests
|
||||
# from insert_sensor.transactional import insert_sensor
|
||||
from insert_sensor.wrapper import (Offering, FoI, Procedure, SensorType)
|
||||
# import json
|
||||
|
||||
|
||||
class Sos():
|
||||
class Sensor:
|
||||
"""
|
||||
A class to represent a sos service.
|
||||
A class to represent an input sensor.
|
||||
...
|
||||
|
||||
Attributes
|
||||
----------
|
||||
sosurl : str
|
||||
name : str
|
||||
first name of the person
|
||||
token : str
|
||||
x : float
|
||||
token to access soso service
|
||||
y : float
|
||||
token to access soso service
|
||||
"""
|
||||
|
||||
def __init__(self, url, token=''):
|
||||
self.sosurl = str(url) # url to access the SOS
|
||||
self.token = str(token) # security token, optional
|
||||
# Test if URL exists
|
||||
try:
|
||||
test = requests.get(self.sosurl)
|
||||
test.raise_for_status()
|
||||
except requests.HTTPError:
|
||||
print("The URL is not valid")
|
||||
def __init__(self, name: str, x_coord: float, y_coord: float,
|
||||
feature_id: str, feature_name: str):
|
||||
self.name = name
|
||||
self.x_coord = x_coord
|
||||
self.y_coord = y_coord
|
||||
self.feature_id = feature_id
|
||||
self.feature_name = feature_name
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -42,7 +43,7 @@ def main():
|
|||
# offering = Offering(
|
||||
# "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
||||
# "inclino1_02",
|
||||
# "Inklinometer inclino1_02, Gschliefgraben Glasfaser"
|
||||
# "Inklinometer, Gschliefgraben Glasfaser"
|
||||
# )
|
||||
# procedure = Procedure( "inclino1_02","inclino1_02")
|
||||
# foi = FoI("degree", "m", (13.774966, 47.910849, 0.0),
|
||||
|
@ -52,7 +53,7 @@ def main():
|
|||
# offering = Offering(
|
||||
# "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
||||
# "inclino1_05",
|
||||
# "Inklinometer inclino1_05, Gschliefgraben Glasfaser"
|
||||
# "Inklinometer, Gschliefgraben Glasfaser"
|
||||
# )
|
||||
# procedure = Procedure("inclino1_05", "inclino1_05")
|
||||
# foi = FoI("degree", "m", (13.774966, 47.910849, 0.0),
|
||||
|
@ -62,37 +63,205 @@ def main():
|
|||
# offering = Offering(
|
||||
# "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
||||
# "inclino1_14",
|
||||
# "Inklinometer inclino1_14, Gschliefgraben Glasfaser"
|
||||
# "Inklinometer, Gschliefgraben Glasfaser"
|
||||
# )
|
||||
# procedure = Procedure("inclino1_14", "inclino1_14")
|
||||
# foi = FoI("degree", "m", (13.774966, 47.910849, 0.0),
|
||||
# "inclino1-glasfaser-gschliefgraben",
|
||||
# "inclino1-glasfaser-gschliefgraben")
|
||||
|
||||
# offering = Offering(
|
||||
# "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
||||
# "inclino1_06",
|
||||
# "Inklinometer, Gschliefgraben Glasfaser"
|
||||
# )
|
||||
# procedure = Procedure("inclino1_06", "inclino1_06")
|
||||
# foi = FoI("degree", "m", (13.774966, 47.910849, 0.0),
|
||||
# "inclino1-glasfaser-gschliefgraben",
|
||||
# "Glasfaser Untersuchungen am Gschliefgraben (Gmunden)")
|
||||
|
||||
offering = Offering(
|
||||
"https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
||||
"inclino1_06",
|
||||
"Inklinometer inclino1_06, Gschliefgraben Glasfaser"
|
||||
)
|
||||
procedure = Procedure("inclino1_06", "inclino1_06")
|
||||
foi = FoI("degree", "m", (13.774966, 47.910849, 0.0),
|
||||
"inclino1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)")
|
||||
sensor_list: List[Sensor] = []
|
||||
|
||||
sensor_type = SensorType("inclinometer")
|
||||
post_data = insert_sensor(offering, procedure, foi, sensor_type)
|
||||
print(post_data)
|
||||
headers = {'Accept': 'application/json'}
|
||||
request = requests.post(sos_url, headers=headers, json=post_data)
|
||||
print(request.text)
|
||||
# appending instances to list
|
||||
## inclino1_01 bis inclino1_20
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_01', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_02', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_03',13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_04', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_05', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_06', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_07', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_08', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_09', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_10', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_11', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_12', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_13', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_14', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_15', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_16', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_17', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_18', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_19', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino1_20', 13.816940062459931, 47.883893347112163,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
|
||||
# {
|
||||
# "request" : "InsertSensor",
|
||||
# "version" : "2.0.0",
|
||||
# "service" : "SOS",
|
||||
# "assignedProcedure" : "inclino1_14",
|
||||
# "assignedOffering" : "inclino1_14"
|
||||
# }
|
||||
## inclino2_04 bis inclino2_22
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_04', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_05', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_06', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_07', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_08', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_09', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_10', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_11', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_12', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_13', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_14', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_15', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_16',13.817740197926463, 47.883901327648893,
|
||||
"bohrloch1-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_17', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_18',13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_19', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
sensor_list.append(
|
||||
Sensor('inclino2_20', 13.817740197926463, 47.883901327648893,
|
||||
"bohrloch2-glasfaser-gschliefgraben",
|
||||
"Glasfaser Untersuchungen am Gschliefgraben (Gmunden)"))
|
||||
|
||||
sensor: Sensor
|
||||
for sensor in sensor_list:
|
||||
# platform wolfsegg
|
||||
offering = Offering(
|
||||
"https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
||||
sensor.name,
|
||||
"Inklinometer, Gschliefgraben Glasfaser"
|
||||
)
|
||||
procedure = Procedure(sensor.name, sensor.name)
|
||||
foi = FoI("degree", "m", (sensor.x_coord, sensor.y_coord, 0.0),
|
||||
sensor.feature_id, sensor.feature_name)
|
||||
|
||||
# now insert sensor via rest service:
|
||||
sensor_type = SensorType("inclinometer")
|
||||
post_data = insert_sensor(offering, procedure, foi, sensor_type)
|
||||
print(post_data)
|
||||
headers = {'Accept': 'application/json'}
|
||||
request = requests.post(sos_url, headers=headers, json=post_data)
|
||||
print(request.text)
|
||||
|
||||
# {
|
||||
# "request" : "InsertSensor",
|
||||
# "version" : "2.0.0",
|
||||
# "service" : "SOS",
|
||||
# "assignedProcedure" : "inclino1_14",
|
||||
# "assignedOffering" : "inclino1_14"
|
||||
# }
|
||||
|
||||
|
||||
def insert_sensor(offering, procedure, foi, sensor_type):
|
||||
|
|
|
@ -22,7 +22,7 @@ from sqlalchemy import func, asc, desc
|
|||
# from db.pg_models import Platform
|
||||
from db.models import (
|
||||
ObservationSchema, Person, PersonSchema, Observation,
|
||||
create_pg_session, Dataset, Procedure, Phenomenon, Platform)
|
||||
create_pg_session, Dataset, Procedure, Phenomenon, Platform, Format)
|
||||
from gschliefgraben_glasfaser.my_api import MyApi
|
||||
|
||||
|
||||
|
@ -56,13 +56,36 @@ def main():
|
|||
|
||||
platform_exists: bool = pg_session.query(Platform.id).filter_by(
|
||||
sta_identifier=platform_sta_identifier).scalar() is not None
|
||||
if platform_exists:
|
||||
# if platform_exists:
|
||||
# sensor_platform = pg_session.query(Platform.id) \
|
||||
# .filter(Platform.sta_identifier == platform_sta_identifier) \
|
||||
# .first()
|
||||
# slope_dataset.fk_platform_id = sensor_platform.id
|
||||
# else:
|
||||
# exit()
|
||||
if not platform_exists:
|
||||
sensor_platform = Platform()
|
||||
# max_id = pg_session.query(func.max(Platform.id)).scalar()
|
||||
# sensor_platform.id = max_id + 1
|
||||
sensor_platform.sta_identifier = platform_sta_identifier.lower()
|
||||
sensor_platform.identifier = platform_sta_identifier.lower()
|
||||
sensor_platform.name = platform_sta_identifier.lower()
|
||||
slope_dataset.platform = sensor_platform
|
||||
else:
|
||||
sensor_platform = pg_session.query(Platform.id) \
|
||||
.filter(Platform.sta_identifier == platform_sta_identifier) \
|
||||
.first()
|
||||
slope_dataset.fk_platform_id = sensor_platform.id
|
||||
else:
|
||||
exit()
|
||||
|
||||
format_exists: bool = pg_session.query(Format.id).filter_by(
|
||||
definition="http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
|
||||
).scalar() is not None
|
||||
if format_exists:
|
||||
sensor_format = pg_session.query(Format.id) \
|
||||
.filter(Format.definition ==
|
||||
"http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement") \
|
||||
.first()
|
||||
slope_dataset.fk_format_id = sensor_format.id
|
||||
|
||||
# create all the observation for the given sensor names
|
||||
create_observations(sensor, slope_dataset)
|
||||
|
@ -98,7 +121,7 @@ def create_observations(sensor: str, slope_dataset: Dataset):
|
|||
# consider the start date as 2021-february 1 st
|
||||
start_date = date(2022, 1, 1)
|
||||
# consider the end date as 2021-march 1 st
|
||||
end_date = date(2022, 3, 6)
|
||||
end_date = date(2022, 3, 20)
|
||||
|
||||
# delta time
|
||||
delta = timedelta(days=7)
|
||||
|
@ -269,6 +292,6 @@ def create(person_json: PersonSchema):
|
|||
|
||||
if __name__ == "__main__":
|
||||
load_dotenv(find_dotenv())
|
||||
sensor_list1 = os.environ.get('GLASFASER_GSCHLIEFGRABEN_SENSORS', [])
|
||||
sensor_list1 = os.environ.get('GLASFASER_GSCHLIEFGRABEN_SENSORS', []).replace(r'\n', '\n')
|
||||
print(f'sensors: {sensor_list1} .')
|
||||
main()
|
||||
|
|
|
@ -98,7 +98,7 @@ def create_observations(sensor: str, slope_dataset: Dataset):
|
|||
|
||||
|
||||
def create_db_observations(sensor: str, query_date, test_api, pg_session, dataset: Dataset):
|
||||
''' to do '''
|
||||
''' parse each observation '''
|
||||
query_date_obj = datetime.strptime(query_date, "%Y-%m-%d")
|
||||
data = test_api.getSensorData(sensor, query_date, query_date)
|
||||
observation_array = (data['FeatureCollection']
|
||||
|
|
|
@ -105,7 +105,7 @@ def main():
|
|||
|
||||
# appending instances to list
|
||||
sensor_list.append(
|
||||
Sensor('gschliefgraben_bohrloch_1', 13.774966, 47.910849,
|
||||
Sensor('gschliefgraben_bohrloch_1', 13.808378638676, 47.882871028831,
|
||||
"bohrloch1-glasfaser-gschliefgraben", "Piezometer1 am Gschliefgraben"))
|
||||
sensor_list.append(
|
||||
Sensor('gschliefgraben_bohrloch_2', 13.80957276439, 47.882524348741,
|
||||
|
|
Loading…
Reference in New Issue
Block a user