Search in sources :

Example 1 with HashMultiSet

use of de.topobyte.adt.multicollections.HashMultiSet in project osm4j-geometry by topobyte.

the class RegionBuilder method build.

/**
 * Build a MultiPolygon from a Relation.
 *
 * @param relation
 *            a relation to construct the region for.
 * @return the constructed MultiPolygon.
 * @throws EntityNotFoundException
 *             when a required entity cannot be obtained.
 */
public RegionBuilderResult build(OsmRelation relation, OsmEntityProvider resolver) throws EntityNotFoundException {
    EntityNotFoundStrategy enfs = Util.strategy(missingEntitiesStrategy, log, logLevel);
    logger.debug("building region id:" + relation.getId());
    Set<OsmRelation> relations = new HashSet<>();
    MultiSet<OsmWay> ways = new HashMultiSet<>();
    EntityFinder finder = EntityFinders.create(resolver, enfs);
    relations.add(relation);
    finder.findMemberRelationsRecursively(relation, relations);
    finder.findMemberWays(relations, ways);
    Set<OsmNode> nodes = new HashSet<>();
    if (includePuntal) {
        finder.findMemberNodes(relations, nodes);
    }
    return build(ways, resolver, nodes);
}
Also used : OsmWay(de.topobyte.osm4j.core.model.iface.OsmWay) OsmNode(de.topobyte.osm4j.core.model.iface.OsmNode) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) HashMultiSet(de.topobyte.adt.multicollections.HashMultiSet) EntityNotFoundStrategy(de.topobyte.osm4j.core.resolve.EntityNotFoundStrategy) EntityFinder(de.topobyte.osm4j.core.resolve.EntityFinder) HashSet(java.util.HashSet)

Aggregations

HashMultiSet (de.topobyte.adt.multicollections.HashMultiSet)1 OsmNode (de.topobyte.osm4j.core.model.iface.OsmNode)1 OsmRelation (de.topobyte.osm4j.core.model.iface.OsmRelation)1 OsmWay (de.topobyte.osm4j.core.model.iface.OsmWay)1 EntityFinder (de.topobyte.osm4j.core.resolve.EntityFinder)1 EntityNotFoundStrategy (de.topobyte.osm4j.core.resolve.EntityNotFoundStrategy)1 HashSet (java.util.HashSet)1