Search in sources :

Example 1 with BreadthFirstInstanceTraverser

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();
}
Also used : BreadthFirstInstanceTraverser(eu.esdihumboldt.hale.common.instance.helper.BreadthFirstInstanceTraverser)

Example 2 with BreadthFirstInstanceTraverser

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;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryProperty(eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty) GeometryFinder(eu.esdihumboldt.hale.common.instance.geometry.GeometryFinder) BreadthFirstInstanceTraverser(eu.esdihumboldt.hale.common.instance.helper.BreadthFirstInstanceTraverser)

Aggregations

BreadthFirstInstanceTraverser (eu.esdihumboldt.hale.common.instance.helper.BreadthFirstInstanceTraverser)2 GeometryFinder (eu.esdihumboldt.hale.common.instance.geometry.GeometryFinder)1 GeometryProperty (eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty)1 Geometry (org.locationtech.jts.geom.Geometry)1