use of org.geotools.gml.GMLFilterGeometry in project exist by eXist-db.
the class GMLIndexTest method lowLevelSearch.
@Test
public void lowLevelSearch() throws EXistException, SAXException, ParserConfigurationException, SpatialIndexException, IOException {
GMLHandlerJTS geometryHandler = new GeometryHandler();
GMLFilterGeometry geometryFilter = new GMLFilterGeometry(geometryHandler);
GMLFilterDocument handler = new GMLFilterDocument(geometryFilter);
final BrokerPool pool = server.getBrokerPool();
try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
AbstractGMLJDBCIndexWorker indexWorker = (AbstractGMLJDBCIndexWorker) broker.getIndexController().getWorkerByIndexId(AbstractGMLJDBCIndex.ID);
// Unplugged
if (indexWorker != null) {
SAXParserFactory factory = ExistSAXParserFactory.getSAXParserFactory();
factory.setNamespaceAware(true);
InputSource src = new InputSource(new StringReader(IN_MEMORY_GML));
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
SAXAdapter adapter = new SAXAdapter();
reader.setContentHandler(handler);
reader.setProperty("http://xml.org/sax/properties/lexical-handler", adapter);
reader.parse(src);
Geometry EPSG4326_geometry = indexWorker.transformGeometry(currentGeometry, "osgb:BNG", "EPSG:4326");
assertNotNull(EPSG4326_geometry);
NodeSet ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.EQUALS);
assertTrue(ns.getLength() > 0);
ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.DISJOINT);
assertTrue(ns.getLength() > 0);
ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.INTERSECTS);
assertTrue(ns.getLength() > 0);
ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.TOUCHES);
// assertTrue(ns.getLength() > 0);
ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.CROSSES);
// assertTrue(ns.getLength() > 0);
ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.WITHIN);
assertTrue(ns.getLength() > 0);
ns = indexWorker.search(broker, null, EPSG4326_geometry, SpatialOperator.CONTAINS);
assertTrue(ns.getLength() > 0);
// ns = ((GMLIndexWorker)index.getWorker()).search(broker, EPSG4326_geometry, SpatialOperator.OVERLAPS);
// assertTrue(ns.getLength() > 0);
}
}
}
use of org.geotools.gml.GMLFilterGeometry in project chordatlas by twak.
the class Footprints method parse.
public static Callback parse(InputSource input) throws IOException, SAXException {
// parse xml
XMLReader reader = XMLReaderFactory.createXMLReader();
Callback callback = new Callback();
GMLFilterGeometry geometryCallback = new GMLFilterGeometry(callback);
GMLFilterDocument gmlCallback = new GMLFilterDocument(geometryCallback);
reader.setContentHandler(gmlCallback);
ComplexContentHandler ch;
reader.parse(input);
return callback;
}
Aggregations