Search in sources :

Example 1 with RegionBuilder

use of de.topobyte.osm4j.geometry.RegionBuilder in project osm4j-geometry by topobyte.

the class TestBuildLinework method main.

public static void main(String[] args) throws MalformedURLException, IOException, ParserConfigurationException, SAXException, EntityNotFoundException {
    if (args.length == 0) {
        System.out.println("Please specify an input file");
        usage();
    }
    if (args.length != 1) {
        System.out.println("Please specify only one input file");
        usage();
    }
    InputStream input = new FileInputStream(args[0]);
    OsmIterator iterator = new TboIterator(input, true, true);
    InMemoryMapDataSet data = MapDataSetLoader.read(iterator, false, false, true);
    TLongObjectMap<OsmRelation> relations = data.getRelations();
    if (relations.isEmpty()) {
        logger.warn("No relation found");
        return;
    }
    LineworkBuilder lineworkBuilder = new LineworkBuilder();
    lineworkBuilder.setMissingEntitiesStrategy(MissingEntitiesStrategy.BUILD_PARTIAL);
    lineworkBuilder.setMissingWayNodeStrategy(MissingWayNodeStrategy.SPLIT_POLYLINE);
    RegionBuilder regionBuilder = new RegionBuilder();
    regionBuilder.setMissingEntitiesStrategy(MissingEntitiesStrategy.BUILD_PARTIAL);
    long[] ids = relations.keys();
    Arrays.sort(ids);
    for (long id : ids) {
        OsmRelation relation = relations.get(id);
        logger.info("Relation " + relation.getId());
        lineworkBuilder.build(relation, data);
        regionBuilder.build(relation, data);
    }
}
Also used : InMemoryMapDataSet(de.topobyte.osm4j.core.dataset.InMemoryMapDataSet) TboIterator(de.topobyte.osm4j.tbo.access.TboIterator) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) OsmRelation(de.topobyte.osm4j.core.model.iface.OsmRelation) RegionBuilder(de.topobyte.osm4j.geometry.RegionBuilder) OsmIterator(de.topobyte.osm4j.core.access.OsmIterator) FileInputStream(java.io.FileInputStream) LineworkBuilder(de.topobyte.osm4j.geometry.LineworkBuilder)

Aggregations

OsmIterator (de.topobyte.osm4j.core.access.OsmIterator)1 InMemoryMapDataSet (de.topobyte.osm4j.core.dataset.InMemoryMapDataSet)1 OsmRelation (de.topobyte.osm4j.core.model.iface.OsmRelation)1 LineworkBuilder (de.topobyte.osm4j.geometry.LineworkBuilder)1 RegionBuilder (de.topobyte.osm4j.geometry.RegionBuilder)1 TboIterator (de.topobyte.osm4j.tbo.access.TboIterator)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1