From 923bd0ab87a4bc6a1bc0daa69282c07b02af5ddf Mon Sep 17 00:00:00 2001 From: Dave Foster Date: Tue, 18 Jun 2013 10:10:08 -0400 Subject: [PATCH] Add get_capabilities/get_feature_type_info simulated methods to ShorelineFile --- paegan/transport/shoreline.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/paegan/transport/shoreline.py b/paegan/transport/shoreline.py index b751182..443f6c3 100644 --- a/paegan/transport/shoreline.py +++ b/paegan/transport/shoreline.py @@ -72,7 +72,7 @@ def get_capabilities(self): """ Gets capabilities. - Only defined in ShorelineWFS. Queries WFS server for its capabilities. + Queries WFS server or file for its capabilities (or simulated capabilities). """ return None @@ -80,7 +80,7 @@ def get_feature_type_info(self): """ Gets FeatureType as a python dict. - Only defined in ShorelineWFS. Transforms feature_name info into python dict. + Transforms feature_name info into python dict. """ return None @@ -318,6 +318,31 @@ def close(self): # Srsly. Per GDAL docs this is how we should close the dataset. self._source = None + def get_capabilities(self): + """ + Gets capabilities. + + This is a simulation of a GetCapabilities WFS request. Returns a python dict + with LatLongBoundingBox and Name keys defined. + """ + d = {} + + ext = self._layer.GetExtent() # @TODO if a filter is on this may give different results + llbb = [round(float(v), 4) for v in ext] + + d['LatLongBoundingBox'] = box(llbb[0], llbb[2], llbb[1], llbb[3]) + d['Name'] = self._file.split('/')[-1].split('.')[0] + + return d + + def get_feature_type_info(self): + """ + Gets FeatureType as a python dict. + + On ShorelineFile this is a passthrough to the simulated get_capabilities. + """ + return self.get_capabilities() + def get_geoms_for_bounds(self, bounds): """ Helper method to get geometries within a certain bounds (as WKT). @@ -377,7 +402,7 @@ def get_capabilities(self): """ Gets capabilities. - Queries WFS server for its capabilities. Internally ised by get_feature_type_info. + Queries WFS server for its capabilities. Internally used by get_feature_type_info. """ params = {'service' : 'WFS', 'request' : 'GetCapabilities',