use of eu.esdihumboldt.hale.common.instance.helper.BreadthFirstInstanceTraverser in project hale by halestudio.
the class GMLGeometryUtil method findCRS.
/**
* Find the CRS definition to be associated with the geometry contained in
* the given instance.
*
* @param instance the given instance
* @return the CRS definition or <code>null</code> if none could be
* identified
*/
public static CRSDefinition findCRS(Instance instance) {
BreadthFirstInstanceTraverser traverser = new BreadthFirstInstanceTraverser();
CRSFinder finder = new CRSFinder();
traverser.traverse(instance, finder);
return finder.getDefinition();
}
use of eu.esdihumboldt.hale.common.instance.helper.BreadthFirstInstanceTraverser in project hale by halestudio.
the class AbstractHandlerTest method checkSingleGeometry.
/**
* Check a single geometry contained in an instance (at an arbitrary path).
*
* @param instance the geometry instance
* @param checker the checker (should throw an exception when the check
* fails)
* @return the collection of encountered geometries
*/
protected Collection<GeometryProperty<?>> checkSingleGeometry(Instance instance, @Nullable Consumer<Geometry> checker) {
GeometryFinder finder = new GeometryFinder(null);
BreadthFirstInstanceTraverser traverser = new BreadthFirstInstanceTraverser();
traverser.traverse(instance, finder);
List<GeometryProperty<?>> geoms = finder.getGeometries();
assertFalse("No geometry found in instances", geoms.isEmpty());
assertEquals("More than one geometry found in instance", 1, geoms.size());
Geometry geom = geoms.get(0).getGeometry();
if (checker != null) {
checker.accept(geom);
}
return geoms;
}
Aggregations