def select (self, action): param = {"VERSION" : self.version, "SERVICE" : "WFS", "REQUEST" : "GetFeature", "TYPENAME" : self.typename} if action.id is not None: param["FEATUREID"] = str(action.id) else: if action.bbox: param["BBOX"] = ",".join(map(str, action.bbox)) if action.attributes: raise NotImplementedError("WFS attribute query") if action.maxfeatures: param["MAXFEATURES"] = str(action.maxfeatures) url = self.url if "?" not in url and "&" not in url: url += "?" url += urllib.urlencode(param) tmpfile, headers = urllib.urlretrieve(url) import ogr try: ds = OGR("GML", dsn = tmpfile, writable = 0) result = ds.select(action) except ogr.OGRError, E: raise Exception("OGR could not read the WFS result: %s. Data was: %s" % (E, open(tmpfile).read()))