|
@@ -15,6 +15,7 @@ from string import Template
|
|
|
from osgeo import osr
|
|
from osgeo import osr
|
|
|
from osgeo import ogr
|
|
from osgeo import ogr
|
|
|
import OWSExceptions
|
|
import OWSExceptions
|
|
|
|
|
+from owslib import crs as CRS
|
|
|
|
|
|
|
|
class OWS:
|
|
class OWS:
|
|
|
|
|
|
|
@@ -255,23 +256,18 @@ class OWS:
|
|
|
|
|
|
|
|
return defFileName
|
|
return defFileName
|
|
|
|
|
|
|
|
- def getLayerExtent(self,layer,crs=None,wkt=None):
|
|
|
|
|
|
|
+ def getLayerExtent(self,layer,crs=None):
|
|
|
"""Get extent of layer in form of minx, miny, maxx,maxy
|
|
"""Get extent of layer in form of minx, miny, maxx,maxy
|
|
|
|
|
+
|
|
|
|
|
+ :returns: [minx, miny, maxx, maxy]
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
bbox = None
|
|
bbox = None
|
|
|
if layer.boundingBoxWGS84:
|
|
if layer.boundingBoxWGS84:
|
|
|
|
|
|
|
|
dest = osr.SpatialReference()
|
|
dest = osr.SpatialReference()
|
|
|
- if crs:
|
|
|
|
|
- try:
|
|
|
|
|
- crsSplit = crs.split(":")
|
|
|
|
|
- epsg = int(crsSplit[len(crsSplit)-1])
|
|
|
|
|
- dest.ImportFromEPSG(epsg)
|
|
|
|
|
- except (ValueError):
|
|
|
|
|
- logging.debug("Unable to parse crs '%s'" % crs)
|
|
|
|
|
- else:
|
|
|
|
|
- dest.ImportFromWkt(wkt)
|
|
|
|
|
|
|
+ dest.ImportFromEPSG(crs.code)
|
|
|
|
|
+
|
|
|
source = osr.SpatialReference()
|
|
source = osr.SpatialReference()
|
|
|
source.ImportFromEPSG(4326)
|
|
source.ImportFromEPSG(4326)
|
|
|
|
|
|
|
@@ -279,6 +275,7 @@ class OWS:
|
|
|
|
|
|
|
|
# TODO rewrite this using ogr CoordinateTransformation
|
|
# TODO rewrite this using ogr CoordinateTransformation
|
|
|
# http://www.gdal.org/ogr/osr_tutorial.html
|
|
# http://www.gdal.org/ogr/osr_tutorial.html
|
|
|
|
|
+ # WELL: it does NOT seem to be THAT better
|
|
|
geom = ogr.CreateGeometryFromWkt("""POINT(%s %s)""" % (layer.boundingBoxWGS84[0],layer.boundingBoxWGS84[1]),source)
|
|
geom = ogr.CreateGeometryFromWkt("""POINT(%s %s)""" % (layer.boundingBoxWGS84[0],layer.boundingBoxWGS84[1]),source)
|
|
|
geom.TransformTo(dest)
|
|
geom.TransformTo(dest)
|
|
|
bbox.append(geom.GetX())
|
|
bbox.append(geom.GetX())
|
|
@@ -314,7 +311,6 @@ class OWS:
|
|
|
# set the filter
|
|
# set the filter
|
|
|
layerobj.setMetaData("wfs_filter",msFilter)
|
|
layerobj.setMetaData("wfs_filter",msFilter)
|
|
|
|
|
|
|
|
-
|
|
|
|
|
def getService(configFile=None):
|
|
def getService(configFile=None):
|
|
|
|
|
|
|
|
qstring = os.environ["QUERY_STRING"]
|
|
qstring = os.environ["QUERY_STRING"]
|