From 948dfd5ccc38a0bf4f9991293623aba7c0a4372c Mon Sep 17 00:00:00 2001 From: danistrigaro Date: Wed, 14 Dec 2016 14:52:31 +0100 Subject: [PATCH 1/3] fixed ReferenceSystem in GetCap-OpMet-GetObs-SpaFilt SOS 2.0 response --- istsoslib/renderers/GCresponseRender.py | 5 ++++- istsoslib/responders/GCresponse.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/istsoslib/renderers/GCresponseRender.py b/istsoslib/renderers/GCresponseRender.py index f25b6fe0..9366abac 100755 --- a/istsoslib/renderers/GCresponseRender.py +++ b/istsoslib/renderers/GCresponseRender.py @@ -292,6 +292,9 @@ def render_2_0_0(GC,sosConfig): r += " \n" r += " \n" + # add ReferenceSystem tag + if p.referenceSystem: + r += " \n" r += " \n" if o.name != 'GlobalOperations': @@ -427,4 +430,4 @@ def render_2_0_0(GC,sosConfig): r += " \n" r += " " - return r \ No newline at end of file + return r diff --git a/istsoslib/responders/GCresponse.py b/istsoslib/responders/GCresponse.py index fd80e8c0..44dc1459 100755 --- a/istsoslib/responders/GCresponse.py +++ b/istsoslib/responders/GCresponse.py @@ -90,11 +90,12 @@ class Parameter: allowedValues (list): allowed values range (list): ranges """ - def __init__(self,name,use = "optional",allowedValues=[],range=[]): + def __init__(self,name,use = "optional",allowedValues=[],range=[], referenceSystem=False): self.name=name self.use=use self.allowedValues=allowedValues self.range=range + self.referenceSystem=referenceSystem class Operation: """Operation object @@ -111,8 +112,8 @@ def __init__(self,name,get="",post=""): self.get=get self.post=post self.parameters=[] - def addParameter(self,name,use = "optional",allowedValues=[],range=[]): - self.parameters.append(Parameter(name,use,allowedValues,range)) + def addParameter(self,name,use = "optional",allowedValues=[],range=[], referenceSystem=False): + self.parameters.append(Parameter(name,use,allowedValues,range,referenceSystem)) def BuildSensorIdList(pgdb,sosConfig): """Generate the sensor list @@ -205,10 +206,10 @@ def BuildEnvelopeMinMax(pgdb,sosConfig): st_YMax(envelope) as may FROM ( - select ST_ENVELOPE(ST_Collect(ST_Transform(envelope,3857))) as envelope + select ST_ENVELOPE(ST_Collect(ST_Transform(envelope,4326))) as envelope from ( select - ST_ENVELOPE(ST_Collect(ST_Transform(geom_pos,3857))) as envelope + ST_ENVELOPE(ST_Collect(ST_Transform(geom_pos,4326))) as envelope FROM %s.positions, %s.event_time, %s.procedures WHERE @@ -217,7 +218,7 @@ def BuildEnvelopeMinMax(pgdb,sosConfig): id_eti = id_eti_fk union select - ST_ENVELOPE(ST_Collect(ST_Transform(geom_foi,3857))) as envelope + ST_ENVELOPE(ST_Collect(ST_Transform(geom_foi,4326))) as envelope FROM %s.foi ) as g @@ -543,7 +544,7 @@ def __init__(self,pgdb,sosConfig): GetObservation=Operation(name="GetObservation", get = sosConfig.serviceUrl["get"]) GetObservation.addParameter(name="offering", use = "required", allowedValues = BuildOfferingList_2_0_0(pgdb,sosConfig)) GetObservation.addParameter(name="temporalFilter", use = "optional", allowedValues = [], range=BuildEventTimeRange(pgdb,sosConfig)) - GetObservation.addParameter(name="spatialFilter", use = "optional", allowedValues = [], range=BuildEnvelopeMinMax(pgdb,sosConfig)) + GetObservation.addParameter(name="spatialFilter", use = "optional", allowedValues = [], range=BuildEnvelopeMinMax(pgdb,sosConfig), referenceSystem='EPSG:4326') GetObservation.addParameter(name="procedure", use = "optional", allowedValues = BuildSensorIdList(pgdb,sosConfig)) GetObservation.addParameter(name="observedProperty", use = "optional", allowedValues = BuildobservedPropertyList(pgdb,sosConfig)) GetObservation.addParameter(name="featureOfInterest", use = "optional", allowedValues = BuildfeatureOfInterestList(pgdb,sosConfig)) From 09321fb82bede8933f3035e5aacfd44de6362fd8 Mon Sep 17 00:00:00 2001 From: danistrigaro Date: Wed, 14 Dec 2016 15:43:48 +0100 Subject: [PATCH 2/3] default CRS in the GetCap SOS 2.0 response --- istsoslib/responders/GCresponse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/istsoslib/responders/GCresponse.py b/istsoslib/responders/GCresponse.py index 44dc1459..7759fa26 100755 --- a/istsoslib/responders/GCresponse.py +++ b/istsoslib/responders/GCresponse.py @@ -544,7 +544,7 @@ def __init__(self,pgdb,sosConfig): GetObservation=Operation(name="GetObservation", get = sosConfig.serviceUrl["get"]) GetObservation.addParameter(name="offering", use = "required", allowedValues = BuildOfferingList_2_0_0(pgdb,sosConfig)) GetObservation.addParameter(name="temporalFilter", use = "optional", allowedValues = [], range=BuildEventTimeRange(pgdb,sosConfig)) - GetObservation.addParameter(name="spatialFilter", use = "optional", allowedValues = [], range=BuildEnvelopeMinMax(pgdb,sosConfig), referenceSystem='EPSG:4326') + GetObservation.addParameter(name="spatialFilter", use = "optional", allowedValues = [], range=BuildEnvelopeMinMax(pgdb,sosConfig), referenceSystem="http://www.opengis.net/def/crs/EPSG/0/"+sosConfig.istsosepsg) GetObservation.addParameter(name="procedure", use = "optional", allowedValues = BuildSensorIdList(pgdb,sosConfig)) GetObservation.addParameter(name="observedProperty", use = "optional", allowedValues = BuildobservedPropertyList(pgdb,sosConfig)) GetObservation.addParameter(name="featureOfInterest", use = "optional", allowedValues = BuildfeatureOfInterestList(pgdb,sosConfig)) From 1d310dba1ff7e7c164d2c6bf4416303a5ff8739d Mon Sep 17 00:00:00 2001 From: danistrigaro Date: Wed, 14 Dec 2016 16:09:25 +0100 Subject: [PATCH 3/3] default CRS into the query to build sptailFilter --- istsoslib/responders/GCresponse.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/istsoslib/responders/GCresponse.py b/istsoslib/responders/GCresponse.py index 7759fa26..17e2df17 100755 --- a/istsoslib/responders/GCresponse.py +++ b/istsoslib/responders/GCresponse.py @@ -198,6 +198,9 @@ def BuildEventTimeRange(pgdb,sosConfig): return [rows[0]["b"],rows[0]["e"]] def BuildEnvelopeMinMax(pgdb,sosConfig): + sosEpsgList = [sosConfig.istsosepsg,]*2 + sosSchemaList = [sosConfig.schema,]*3 + sqlParamsList = sosEpsgList+sosSchemaList+[sosConfig.istsosepsg, sosConfig.schema] sql = """ SELECT st_XMin(envelope) as mix, @@ -206,10 +209,10 @@ def BuildEnvelopeMinMax(pgdb,sosConfig): st_YMax(envelope) as may FROM ( - select ST_ENVELOPE(ST_Collect(ST_Transform(envelope,4326))) as envelope + select ST_ENVELOPE(ST_Collect(ST_Transform(envelope,%s))) as envelope from ( select - ST_ENVELOPE(ST_Collect(ST_Transform(geom_pos,4326))) as envelope + ST_ENVELOPE(ST_Collect(ST_Transform(geom_pos,%s))) as envelope FROM %s.positions, %s.event_time, %s.procedures WHERE @@ -218,12 +221,12 @@ def BuildEnvelopeMinMax(pgdb,sosConfig): id_eti = id_eti_fk union select - ST_ENVELOPE(ST_Collect(ST_Transform(geom_foi,4326))) as envelope + ST_ENVELOPE(ST_Collect(ST_Transform(geom_foi,%s))) as envelope FROM %s.foi ) as g ) as s - """ % ((sosConfig.schema,)*4) + """ % (tuple(sqlParamsList)) result = [0,0,0,0] rows=pgdb.select(sql) if len(rows) == 1: