def _toXML(filter, pretty=True, version=1.0): """ Encodes a filter object as XML. """ ogc, ogcconfig = _ogc(version) e = Encoder(ogcconfig) e.indenting = pretty e.omitXMLDeclaration = True out = io.ByteArrayOutputStream() e.encode(filter, ogc.Filter, out) return str(lang.String(out.toByteArray()))
def toGML(self,out=sys.stdout): try: from net.opengis.wfs import WfsFactory from org.geotools.wfs.v1_1 import WFS, WFSConfiguration from org.geotools.xml import Encoder except ImportError: raise Exception('toGML() not available, GML libraries not on classpath.') features = self._source.features fc = WfsFactory.eINSTANCE.createFeatureCollectionType() fc.feature.add(features) e = Encoder(WFSConfiguration()) uri = self._source.name.namespaceURI prefix = 'gt' e.namespaces.declarePrefix(prefix,uri) e.indenting = True e.encode(fc, WFS.FeatureCollection, out)
def toGML(self, out=sys.stdout): try: from net.opengis.wfs import WfsFactory from org.geotools.wfs.v1_1 import WFS, WFSConfiguration from org.geotools.xml import Encoder except ImportError: raise Exception( 'toGML() not available, GML libraries not on classpath.') features = self._source.features fc = WfsFactory.eINSTANCE.createFeatureCollectionType() fc.feature.add(features) e = Encoder(WFSConfiguration()) uri = self._source.name.namespaceURI prefix = 'gt' e.namespaces.declarePrefix(prefix, uri) e.indenting = True e.encode(fc, WFS.FeatureCollection, out)