Jachym Cepicky 13 роки тому
батько
коміт
6c2bf2072a
1 змінених файлів з 20 додано та 16 видалено
  1. 20 16
      wfs/__init__.py

+ 20 - 16
wfs/__init__.py

@@ -124,19 +124,21 @@ class WFS(OWS):
                 bboxfile = os.path.join(datadir,"%s.bbox"%typename)
                 filterfile = os.path.join(datadir,"%s.filter"%typename)
                 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]
                     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:
+
                         # remove pre-cached file with only little area
                         logging.info("Removing pre-cached files %s.*"% typename)
                         self.__clear(datadir,typename)
@@ -186,18 +188,20 @@ class WFS(OWS):
             cachefile.write(feature.read())
             cachefile.close()
 
-            # check
-            check = ogr.Open(cachefile.name)
-            if not check:
-                self.__clear(datadir,typename)
-            else:
-                check.Destroy()
 
             #ds = ogr.Open(cachefile.name)
             #drv = ogr.GetDriverByName(ds.GetDriver().name)
             #out = drv.CopyDataSource(ds,outfn)
             #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
         layerobj.connection = os.path.abspath(outfn)