|
@@ -124,19 +124,21 @@ class WFS(OWS):
|
|
|
bboxfile = os.path.join(datadir,"%s.bbox"%typename)
|
|
bboxfile = os.path.join(datadir,"%s.bbox"%typename)
|
|
|
filterfile = os.path.join(datadir,"%s.filter"%typename)
|
|
filterfile = os.path.join(datadir,"%s.filter"%typename)
|
|
|
if os.path.isfile(bboxfile) and not os.path.isfile(filterfile)\
|
|
if os.path.isfile(bboxfile) and not os.path.isfile(filterfile)\
|
|
|
- and not fes:
|
|
|
|
|
|
|
+ and not fes:
|
|
|
# convert "string" to [floats] as [minx,miny,maxx,maxy]
|
|
# convert "string" to [floats] as [minx,miny,maxx,maxy]
|
|
|
storedbbox = map(lambda x: round(float(x),4), open(bboxfile).read().split(","))
|
|
storedbbox = map(lambda x: round(float(x),4), open(bboxfile).read().split(","))
|
|
|
- if storedbbox[0] <= bbox[0] and\
|
|
|
|
|
- storedbbox[1] <= bbox[1] and \
|
|
|
|
|
- storedbbox[2] >= bbox[2] and \
|
|
|
|
|
- storedbbox[3] >= bbox[3]:
|
|
|
|
|
- logging.info(
|
|
|
|
|
- "Using cached file for type [%s] with bbox [%f,%f,%f,%f], not downloading new data"%\
|
|
|
|
|
- (typename, bbox[0],bbox[1],bbox[2],bbox[3]))
|
|
|
|
|
- # setting output file name
|
|
|
|
|
- outfn = os.path.join(datadir,"%s.gml"%typename)
|
|
|
|
|
|
|
+ if (storedbbox[0] <= bbox[0] and\
|
|
|
|
|
+ storedbbox[1] <= bbox[1] and \
|
|
|
|
|
+ storedbbox[2] >= bbox[2] and \
|
|
|
|
|
+ storedbbox[3] >= bbox[3]) or \
|
|
|
|
|
+ self.request.upper() != "GETMAP":
|
|
|
|
|
+ logging.info(
|
|
|
|
|
+ "Using cached file for type [%s] with bbox [%f,%f,%f,%f], not downloading new data"%\
|
|
|
|
|
+ (typename, bbox[0],bbox[1],bbox[2],bbox[3]))
|
|
|
|
|
+ # setting output file name
|
|
|
|
|
+ outfn = os.path.join(datadir,"%s.gml"%typename)
|
|
|
else:
|
|
else:
|
|
|
|
|
+
|
|
|
# remove pre-cached file with only little area
|
|
# remove pre-cached file with only little area
|
|
|
logging.info("Removing pre-cached files %s.*"% typename)
|
|
logging.info("Removing pre-cached files %s.*"% typename)
|
|
|
self.__clear(datadir,typename)
|
|
self.__clear(datadir,typename)
|
|
@@ -186,18 +188,20 @@ class WFS(OWS):
|
|
|
cachefile.write(feature.read())
|
|
cachefile.write(feature.read())
|
|
|
cachefile.close()
|
|
cachefile.close()
|
|
|
|
|
|
|
|
- # check
|
|
|
|
|
- check = ogr.Open(cachefile.name)
|
|
|
|
|
- if not check:
|
|
|
|
|
- self.__clear(datadir,typename)
|
|
|
|
|
- else:
|
|
|
|
|
- check.Destroy()
|
|
|
|
|
|
|
|
|
|
#ds = ogr.Open(cachefile.name)
|
|
#ds = ogr.Open(cachefile.name)
|
|
|
#drv = ogr.GetDriverByName(ds.GetDriver().name)
|
|
#drv = ogr.GetDriverByName(ds.GetDriver().name)
|
|
|
#out = drv.CopyDataSource(ds,outfn)
|
|
#out = drv.CopyDataSource(ds,outfn)
|
|
|
#out.Destroy()
|
|
#out.Destroy()
|
|
|
|
|
|
|
|
|
|
+ # check
|
|
|
|
|
+ if self.request.upper() in ["GETMAP"]:
|
|
|
|
|
+ check = ogr.Open(outfn)
|
|
|
|
|
+ if not check:
|
|
|
|
|
+ self.__clear(datadir,typename)
|
|
|
|
|
+ else:
|
|
|
|
|
+ check.Destroy()
|
|
|
|
|
+
|
|
|
# set layer connection
|
|
# set layer connection
|
|
|
layerobj.connection = os.path.abspath(outfn)
|
|
layerobj.connection = os.path.abspath(outfn)
|
|
|
|
|
|