54b210c07d
- add code for exporting firebird data to postgis db
84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""This module does blah blah."""
|
|
|
|
import requests
|
|
from transactional import insert_sensor
|
|
from 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")
|
|
|
|
|
|
def main():
|
|
"""
|
|
main function
|
|
"""
|
|
sos_url = 'https://geomon.geologie.ac.at/52n-sos-webapp/service'
|
|
|
|
######################## Sibratsgfall
|
|
offering = Offering(
|
|
"https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
|
"sibratsgfall_3",
|
|
"Inklinometer 3, Sibratsgfaell Sensor"
|
|
)
|
|
procedure = Procedure( "sibratsgfall_3","sibratsgfall-3")
|
|
foi = FoI("degree", "m", (47.4279288, 10.0360888, 0.0),
|
|
"sibratsgfall", "Sibratsgfall Beobachtung der Bodenbewegungen Test")
|
|
|
|
######################## Gschliefgraben
|
|
# offering = Offering(
|
|
# "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
|
# "gschliefgraben_2",
|
|
# "Inklinometer 2, Gschliefgraben Sensor"
|
|
# )
|
|
# procedure = Procedure( "gschliefgraben_2","gschliefgraben-2")
|
|
|
|
# foi = FoI("degree", "m", (47.8845629, 13.8199351, 0.0),
|
|
# "GSA01A-033-0909", "Geophysikalische Untersuchungen am Gschliefgraben (Gmunden)")
|
|
|
|
######################## Laakirchen
|
|
# offering = Offering(
|
|
# "https://geomon.geologie.ac.at/52n-sos-webapp/api/offerings/",
|
|
# "laakirchen_10",
|
|
# "Inklinometer 10, Laakirchen Sensor"
|
|
# )
|
|
# procedure = Procedure( "laakirchen_10","laakirchen-10")
|
|
|
|
# foi = FoI("degree", "m", (47.9789118, 13.8141457, 0.0),
|
|
# "GSA02B-007-0911", "Massenbewegung Laakirchen")
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|