diff --git a/automatic_inclinometer/firebird_queries.sql b/automatic_inclinometer/firebird_queries.sql
new file mode 100644
index 0000000..86f1f2c
--- /dev/null
+++ b/automatic_inclinometer/firebird_queries.sql
@@ -0,0 +1,84 @@
+SELECT a.CATENA, a.SENSORE, a.DATA, a.ORA, a.TENSIONE, a.ASSORBIMENTO, c.NOME
+FROM ALIMENTAZIONI as a, CATENE as c
+WHERE c.CHIAVE = a.CATENA AND
+c.NOME = 'Sibratsgfall';
+
+
+SELECT "DATI_ACQUISITI"."PITCH", "DATI_ACQUISITI"."ROLL", "DATI_ACQUISITI"."ORA", "DATI_ACQUISITI"."SENSORE", "DATI_ACQUISITI"."DATA", "DATI_ACQUISITI"."TEMPERATURA", "DATI_ACQUISITI"."CATENA", "CATENE_1"."CHIAVE", "CATENE_1"."NOME"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA" LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "DATI_ACQUISITI"."SENSORE" = 1 AND "CATENE"."NOME" = 'Sibratsgfall'
+
+
+SELECT COUNT(*), SENSORE
+FROM DATI_ACQUISITI GROUP BY SENSORE
+
+SELECT "DATI_ACQUISITI"."SENSORE", "CATENE_1"."NOME"
+
+SELECT COUNT(*), "DATI_ACQUISITI"."SENSORE"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA" LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "CATENE_1"."NOME" = 'GSA01A-033-0909'
+GROUP BY "DATI_ACQUISITI"."SENSORE"
+
+SELECT COUNT(*), "DATI_ACQUISITI"."SENSORE"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "CATENE_1"."NOME" = 'Sibratsgfall'
+GROUP BY "DATI_ACQUISITI"."SENSORE"
+
+SELECT "DATI_ACQUISITI"."PITCH", "DATI_ACQUISITI"."ROLL", "DATI_ACQUISITI"."SENSORE"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA" LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "CATENE_1"."NOME" = 'Sibratsgfall'
+
+
+SELECT COUNT(*), "DATI_ACQUISITI"."SENSORE"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA" LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "CATENE_1"."NOME" = 'GSA02B-007-0911'
+GROUP BY "DATI_ACQUISITI"."SENSORE"
+
+SELECT "DATI_ACQUISITI"."PITCH", "DATI_ACQUISITI"."ROLL", "DATI_ACQUISITI"."SENSORE"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA" LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "CATENE_1"."NOME" = 'GSA02B-007-0911'
+
+SELECT CHIAVE, NOME, NUMERO_SENSORI, SITO
+FROM CATENE ORDER BY CHIAVE ;
+
+SELECT a.CATENA, a.SENSORE, a.DATA, a.ORA, a.TENSIONE, a.ASSORBIMENTO, c.NOME
+FROM ALIMENTAZIONI as a, CATENE as c
+WHERE c.CHIAVE = a.CATENA AND
+c.NOME = 'TAC003-020-0517';
+
+SELECT COUNT(*), "DATI_ACQUISITI"."SENSORE"
+FROM "DATI_ACQUISITI"
+JOIN "CATENE" ON "CATENE"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+LEFT OUTER JOIN "CATENE" AS "CATENE_1" ON "CATENE_1"."CHIAVE" = "DATI_ACQUISITI"."CATENA"
+WHERE "CATENE_1"."NOME" = 'TAC003-020-0517'
+GROUP BY "DATI_ACQUISITI"."SENSORE"
+
+
+
+CHIAVE NOME NUMERO_SENSORI SITO x y
+2 Sibratsgfall 17 Sibratsgfaell 47.4279229,10.0360845
+3 GSA01A-033-0909 34 Gschliefgraben (Gmunden) 47.8845629,13.8199351
+5 GSA002-017-0510 17 Rosano 43.7685394,11.4232703
+6 GSA02A-010-1210 10 Ampflwang - KB1 48.0889892,13.5583703
+7 GSA02B-007-1210 17 Ampflwang - KB2 48.088,13.5583
+8 GSA02B-007-0911 19 Laakirchen 47.9789118,13.8141457
+9 Copy of GSA002-017-0510 17 Rosano 43.7685394,11.4232703
+10 GSA02B-007-0613 17 Pechgraben Haus 47.9193704,14.5242307
+11 Copy of GSA02B-007-0911 19 Laakirchen 47.9789118,13.8141457
+12 GSA02A-010-0613 10 Pechgraben Wiese 47.9193704,14.5242307
+13 TAC003-020-0713 20 Pechgraben 47.9193704,14.5242307
+14 TAC003-020-1213 20 Pechgraben KB1 47.9193704,14.5242307
+15 GSA02A-010-1213 10 Pechgraben KB2 47.9193704,14.5242307
+16 TAC003-020-0414 20 Pechgraben KB1 47.9193704,14.5242307
+17 TAC003-020-0517 20 Wolfsegg KB1 48.1064354,13.6731638
+18 GSA02A-010-0517 10 Wolfsegg KB3 48.1064354,13.6731638
+19 TAC005-013-0517 14 Wolfsegg KB2 48.1064354,13.6731638
+20 GSA003-020-0517 34 Wolfsegg KB5 48.1064354,13.6731638
+21 Copy of TAC003-020-0517 20 Wolfsegg KB1 48.1064354,13.6731638
diff --git a/automatic_inclinometer/import_observations_wolfsegg_kb1.py b/automatic_inclinometer/import_observations_wolfsegg_kb1.py
index a0d7cfb..2c145de 100644
--- a/automatic_inclinometer/import_observations_wolfsegg_kb1.py
+++ b/automatic_inclinometer/import_observations_wolfsegg_kb1.py
@@ -27,7 +27,7 @@ def main():
feature_of_interest = 'TAC003-020-0517' # Wolfsegg KB1
# sensor name in postgis db
sensor = 'wolfsegg_kb1_0'
- platform = 'wolfsegg'
+ platform = 'wolfsegg_inclinometer'
firebird_session: session = create_session()
# db_observation = session.query(Observation) \
diff --git a/automatic_inclinometer/insert_sensors/import_sensors_laakirchen.py b/automatic_inclinometer/insert_sensors/import_sensors_laakirchen.py
new file mode 100644
index 0000000..37dae67
--- /dev/null
+++ b/automatic_inclinometer/insert_sensors/import_sensors_laakirchen.py
@@ -0,0 +1,238 @@
+# -*- 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():
+ """
+ A class to represent a sos service.
+ ...
+
+ Attributes
+ ----------
+ sosurl : str
+ first name of the person
+ token : str
+ 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")
+
+# Python3 code here creating class
+
+
+class Sensor:
+ """
+ A class to represent an input sensor.
+ ...
+
+ Attributes
+ ----------
+ name : str
+ first name of the person
+ x : float
+ token to access soso service
+ y : float
+ token to access soso service
+ """
+
+ def __init__(self, name: str, x_coord: float, y_coord: float):
+ self.name = name
+ self.x_coord = x_coord
+ self.y_coord = y_coord
+
+
+def main():
+ """
+ main function
+ """
+ sos_url = 'https://geomon.geologie.ac.at/52n-sos-webapp/service'
+
+ # creating list
+ sensor_list: List[Sensor] = []
+
+ # appending instances to list
+ sensor_list.append(
+ Sensor('laakirchen_0', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_1', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_2', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_3', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_4', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_5', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_6', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_7', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_8', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_9', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_10', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_11', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_12', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_13', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_14', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_15', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_16', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_17', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_18', 13.8141457, 47.9789118))
+ sensor_list.append(
+ Sensor('laakirchen_19', 13.8141457, 47.9789118))
+
+ sensor: Sensor
+ for sensor in sensor_list:
+ # platform laakirchen_inclinometer
+ # offering = Offering(
+ # "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
+ # sensor.name,
+ # "Bohrloch, Wolfsegg Inklinometer"
+ # )
+ # procedure = Procedure(sensor.name, sensor.name)
+ # foi = FoI("degree", "m", (sensor.x_coord, sensor.y_coord, 0.0),
+ # "TAC003-020-0517", "Wolfsegg KB1")
+ ######################## Laakirchen
+ offering = Offering(
+ "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
+ sensor.name,
+ "Inklinometer, Laakirchen Sensor"
+ )
+ procedure = Procedure( sensor.name, sensor.name,)
+
+ foi = FoI("degree", "m", (sensor.x_coord, sensor.y_coord, 0.0),
+ "GSA02B-007-0911", "Massenbewegung Laakirchen")
+
+ # 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)
+
+ # # platform Wolfsegg
+ # offering = Offering(
+ # "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
+ # "wolfsegg_1",
+ # "Bohrloch, Wolfsegg Inklinometer"
+ # )
+ # procedure = Procedure("wolfsegg_1", "wolfsegg_1")
+ # foi = FoI("degree", "m", (13.6731638, 48.1064354, 0.0),
+ # "TAC003-020-0517", "Wolfsegg KB1")
+
+
+
+def insert_sensor(offering, procedure, foi, sensor_type):
+ """
+ Prepares the body of a InsertSensor request for JSON biding.
+ :param offering: an instance of class Offering.Type object.
+ :param Procedure: instance of class Procedure. type object.
+ :param foi: feature of interest. Instance of FoI
+ :param sensor_type: SensorType object
+ :return: valid body for an InsertSensor request.
+ """
+
+ # shortName = offering.name # string
+ # longName = 'Sibratsgfall test' # string
+
+ # Offering values
+ gml_id='\"' + str(procedure.id) + '\"' # Offering name, double quoted
+ offering_name=offering.name
+ offering_label=offering.label
+ # offID = offering.fullId # URL format of full id
+
+ # featureName = featureID = cordX = cordY = height = h_unit = z_unit = coordinates = ""
+ # check if feature of interest should be declare
+ if foi is not None:
+ # feature_id = 'https://geomon.geologie.ac.at/52n-sos-webapp/api/features/' + \
+ # str(foi.fid) # URL format
+ cord_x=str(foi.x) # longitude degrees, float
+ cord_y=str(foi.y) # latitude degrees, float
+ coordinates=cord_x + " " + cord_y
+ height=str(foi.z) # altitude in meters, float
+ # h_unit = foi.Hunit # units for horizontal coordinates
+ # z_unit = foi.Vunit # units for altitude
+ feature_id=foi.fid # "feature location"
+ feature_name=foi.name # "feature location"
+ else:
+ pass
+
+ procedure_name=procedure.name
+ procedure_identifier=procedure.id # URL,
+ obs_types=[]
+ output_list='' # output list element for describe procedure
+ properties_list=[]
+ for attr in sensor_type.pattern["attributes"]:
+ obs_prop_name='\"' + attr[0] + '\"' # attribute name
+ # print(obs_prop_name)
+ unit_name=sensor_type.om_types[attr[1]] # om type
+ # magnitud = a # ??
+
+ obs_name=obs_prop_name.replace('\"', '')
+ obs_name="".join(obs_name.split()) # observable property name
+ output=''
+ output_list=output_list + output
+ # add property identifier to the list.
+ properties_list.append(obs_name)
+ # prepare list of measurement types
+ # A sensor can not registry duplicated sensor types.
+ this_type="http://www.opengis.net/def/observationType/OGC-OM/2.0/"+unit_name
+ if this_type not in obs_types: # when new type appears
+ obs_types.append(this_type)
+ else:
+ continue
+
+ # Unit of measurement:
+ unit_name='\"' + procedure.name + '\"' # double quoted string
+ # unit = omType # one of the MO measurement types
+
+ body={
+ "request": "InsertSensor",
+ "service": "SOS",
+ "version": "2.0.0",
+ "procedureDescriptionFormat": "http://www.opengis.net/sensorml/2.0",
+ "procedureDescription": f'{procedure_identifier}longName{procedure_name}shortName{procedure_name}{offering_label}{offering_name}truefalsefeaturesOfInterest{feature_id}{feature_name}{coordinates}SlopeRollInSystemTemperature{cord_x}{cord_y}{height}',
+ "observableProperty": [
+ "Slope",
+ "Roll",
+ "InSystemTemperature"
+ ],
+ "observationType": [
+ "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
+ ],
+ "featureOfInterestType":
+ "http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint"
+ }
+ return body
+
+
+if __name__ == '__main__':
+ main()
diff --git a/automatic_inclinometer/insert_sensors/import_sensors_wolfsegg.py b/automatic_inclinometer/insert_sensors/import_sensors_wolfsegg.py
index d0e0a67..0b9f8c7 100644
--- a/automatic_inclinometer/insert_sensors/import_sensors_wolfsegg.py
+++ b/automatic_inclinometer/insert_sensors/import_sensors_wolfsegg.py
@@ -108,7 +108,7 @@ def main():
sensor: Sensor
for sensor in sensor_list:
- # platform wolfsegg
+ # platform wolfsegg_inclinometer
offering = Offering(
"https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
sensor.name,
diff --git a/gschliefgraben_glasfaser/main.py b/gschliefgraben_glasfaser/main.py
index d5b013c..b616e25 100644
--- a/gschliefgraben_glasfaser/main.py
+++ b/gschliefgraben_glasfaser/main.py
@@ -76,6 +76,8 @@ def main():
.filter(Platform.sta_identifier == platform_sta_identifier) \
.first()
slope_dataset.fk_platform_id = sensor_platform.id
+
+ pg_session.commit()
format_exists: bool = pg_session.query(Format.id).filter_by(
definition="http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement"
@@ -85,7 +87,8 @@ def main():
.filter(Format.definition ==
"http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement") \
.first()
- slope_dataset.fk_format_id = sensor_format.id
+ slope_dataset.fk_format_id = sensor_format.id
+ pg_session.commit()
# create all the observation for the given sensor names
create_observations(sensor, slope_dataset)
diff --git a/gschliefgraben_glasfaser/update_daily_cron.py b/gschliefgraben_glasfaser/update_daily_cron.py
index 34fae8a..e6d652f 100644
--- a/gschliefgraben_glasfaser/update_daily_cron.py
+++ b/gschliefgraben_glasfaser/update_daily_cron.py
@@ -47,13 +47,13 @@ def main():
slope_dataset.value_type = "quantity"
pg_session.commit()
- platform_exists: bool = pg_session.query(Platform.id).filter_by(
- sta_identifier=platform_sta_identifier).scalar() is not None
- 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
+ # platform_exists: bool = pg_session.query(Platform.id).filter_by(
+ # sta_identifier=platform_sta_identifier).scalar() is not None
+ # 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
# create all the observation for the given sensor names
create_observations(sensor, slope_dataset)
diff --git a/gschliefgraben_piezometer/import_feature_sensor.py b/gschliefgraben_piezometer/import_feature_sensor.py
index e0c28a1..4f0c12d 100644
--- a/gschliefgraben_piezometer/import_feature_sensor.py
+++ b/gschliefgraben_piezometer/import_feature_sensor.py
@@ -105,23 +105,23 @@ def main():
# appending instances to list
sensor_list.append(
- Sensor('gschliefgraben_bohrloch_1', 13.808378638676, 47.882871028831,
- "bohrloch1-glasfaser-gschliefgraben", "Piezometer1 am Gschliefgraben"))
+ Sensor('gschliefgraben_piezometer_1', 13.808378638676, 47.882871028831,
+ "bohrloch1-piezometer-gschliefgraben", "Piezometer1 am Gschliefgraben"))
sensor_list.append(
- Sensor('gschliefgraben_bohrloch_2', 13.80957276439, 47.882524348741,
- "bohrloch2-glasfaser-gschliefgraben", "Piezometer2 am Gschliefgraben"))
+ Sensor('gschliefgraben_piezometer_2', 13.80957276439, 47.882524348741,
+ "bohrloch2-piezometer-gschliefgraben", "Piezometer2 am Gschliefgraben"))
sensor_list.append(
- Sensor('gschliefgraben_bohrloch_3', 13.809990909737, 47.882824994038,
- "bohrloch3-glasfaser-gschliefgraben", "Piezometer3 am Gschliefgraben"))
+ Sensor('gschliefgraben_piezometer_3', 13.809990909737, 47.882824994038,
+ "bohrloch3-piezometer-gschliefgraben", "Piezometer3 am Gschliefgraben"))
sensor_list.append(
- Sensor('gschliefgraben_bohrloch_4', 13.809379587392, 47.883098856837,
- "bohrloch4-glasfaser-gschliefgraben", "Piezometer4 am Gschliefgraben"))
+ Sensor('gschliefgraben_piezometer_4', 13.809379587392, 47.883098856837,
+ "bohrloch4-piezometer-gschliefgraben", "Piezometer4 am Gschliefgraben"))
sensor_list.append(
- Sensor('gschliefgraben_bohrloch_5', 13.81120655331, 47.884145740545,
- "bohrloch5-glasfaser-gschliefgraben", "Piezometer5 am Gschliefgraben"))
+ Sensor('gschliefgraben_piezometer_5', 13.81120655331, 47.884145740545,
+ "bohrloch5-piezometer-gschliefgraben", "Piezometer5 am Gschliefgraben"))
sensor_list.append(
- Sensor('gschliefgraben_bohrloch_6', 13.811537883268, 47.885082327907,
- "bohrloch6-glasfaser-gschliefgraben", "Piezometer6 am Gschliefgraben"))
+ Sensor('gschliefgraben_piezometer_6', 13.811537883268, 47.885082327907,
+ "bohrloch6-piezometer-gschliefgraben", "Piezometer6 am Gschliefgraben"))
sensor: Sensor
for sensor in sensor_list: