|
|
@@ -22,6 +22,7 @@ class WFS(OWS):
|
|
|
layerDefFile = None
|
|
|
lyrobj = None
|
|
|
wfs = None
|
|
|
+ cache = False # do not cache by default
|
|
|
|
|
|
def __init__(self,url=None,qstring=None,configFile=None):
|
|
|
OWS.__init__(self,url,qstring,configFile)
|
|
|
@@ -96,6 +97,10 @@ class WFS(OWS):
|
|
|
layerobj = self.mapobj.getLayerByName(typename)
|
|
|
|
|
|
crs = self.__getLayerCrs(layer.crsOptions)
|
|
|
+
|
|
|
+ if not crs:
|
|
|
+ crs = Crs("epsg:4326")
|
|
|
+
|
|
|
version = request.getValueByName("version")
|
|
|
|
|
|
# get propper bbox for the WFS request
|
|
|
@@ -127,7 +132,10 @@ class WFS(OWS):
|
|
|
and not fes:
|
|
|
# convert "string" to [floats] as [minx,miny,maxx,maxy]
|
|
|
storedbbox = map(lambda x: round(float(x),4), open(bboxfile).read().split(","))
|
|
|
- if (storedbbox[0] <= bbox[0] and\
|
|
|
+
|
|
|
+ # compare bounding boxes
|
|
|
+ if self.cache and \
|
|
|
+ (storedbbox[0] <= bbox[0] and\
|
|
|
storedbbox[1] <= bbox[1] and \
|
|
|
storedbbox[2] >= bbox[2] and \
|
|
|
storedbbox[3] >= bbox[3]) or \
|
|
|
@@ -171,7 +179,16 @@ class WFS(OWS):
|
|
|
logging.debug("Downloading data [%s] from bbox [%f,%f,%f,%f]"%\
|
|
|
(typename, bbox[0],bbox[1],bbox[2],bbox[3]))
|
|
|
bbox.append(crs.getcode())
|
|
|
- feature = self.capabilities.getfeature(
|
|
|
+
|
|
|
+ feature = None
|
|
|
+ if self.capabilities.version == "2.0.0":
|
|
|
+ feature = self.capabilities.getfeature(
|
|
|
+ typename=typename,
|
|
|
+ bbox=bbox,
|
|
|
+ filter=fes,
|
|
|
+ propertyname=None)
|
|
|
+ else:
|
|
|
+ feature = self.capabilities.getfeature(
|
|
|
typename=typename,
|
|
|
bbox=bbox,
|
|
|
filter=fes,
|
|
|
@@ -324,6 +341,8 @@ class WFS(OWS):
|
|
|
lyrobj.setConnectionType(mapscript.MS_OGR,'')
|
|
|
lyrobj.data = re.sub(r".*:","",name)
|
|
|
crs = self.__getLayerCrs(layer.crsOptions)
|
|
|
+ if not(crs):
|
|
|
+ crs = Crs("epsg:4326")
|
|
|
if ds:
|
|
|
ogrLayer = ds.GetLayerByName(name)
|
|
|
extent = self.getLayerExtent(layer,crs)
|
|
|
@@ -431,10 +450,12 @@ class WFS(OWS):
|
|
|
Ofcourse, sometimes, there is no other option, there EPSG:4326, but
|
|
|
take somethign else, if you can
|
|
|
"""
|
|
|
- for crs in crss:
|
|
|
- if crs.getcode() == "EPSG:4326":
|
|
|
- return crs
|
|
|
- return crss[0]
|
|
|
+
|
|
|
+ if len(crss) > 0:
|
|
|
+ for crs in crss:
|
|
|
+ if crs.getcode() == "EPSG:4326":
|
|
|
+ return crs
|
|
|
+ return crss[0]
|
|
|
|
|
|
def __clear(self,datadir,typename):
|
|
|
"""Remove all cached files with following typename
|