Skip to content

Commit

Permalink
Merge pull request #10 from danistrigaro/master
Browse files Browse the repository at this point in the history
fixed ReferenceSystem in GetCap-OpMet-GetObs-SpaFilt SOS 2.0 response
  • Loading branch information
mantonovic authored Dec 19, 2016
2 parents 7971b73 + 1d310db commit 31ae03f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
5 changes: 4 additions & 1 deletion istsoslib/renderers/GCresponseRender.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ def render_2_0_0(GC,sosConfig):
r += " </ows:Range>\n"

r += " </ows:AllowedValues>\n"
# add ReferenceSystem tag
if p.referenceSystem:
r += " <ows:ReferenceSystem reference='" + str(p.referenceSystem) + "' />\n"
r += " </ows:Parameter>\n"

if o.name != 'GlobalOperations':
Expand Down Expand Up @@ -427,4 +430,4 @@ def render_2_0_0(GC,sosConfig):
r += " </sos:contents>\n"

r += " </sos:Capabilities>"
return r
return r
20 changes: 12 additions & 8 deletions istsoslib/responders/GCresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -197,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,
Expand All @@ -205,10 +209,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,%s))) as envelope
from (
select
ST_ENVELOPE(ST_Collect(ST_Transform(geom_pos,3857))) as envelope
ST_ENVELOPE(ST_Collect(ST_Transform(geom_pos,%s))) as envelope
FROM
%s.positions, %s.event_time, %s.procedures
WHERE
Expand All @@ -217,12 +221,12 @@ 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,%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:
Expand Down Expand Up @@ -543,7 +547,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="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))
Expand Down

0 comments on commit 31ae03f

Please sign in to comment.