Search in sources :

Example 1 with MapZooms

use of net.osmand.binary.MapZooms in project OsmAnd-tools by osmandapp.

the class IndexCreator method main.

public static void main(String[] args) throws IOException, SQLException, InterruptedException, XmlPullParserException {
    long time = System.currentTimeMillis();
    // if(true){ generateRegionsFile(); return;}
    String rootFolder = "/Users/victorshcherb/osmand/";
    IndexPoiCreator.ZIP_LONG_STRINGS = false;
    // $NON-NLS-1$
    IndexCreator creator = new IndexCreator(new File(rootFolder + "/maps/"));
    creator.setIndexMap(true);
    // creator.setIndexAddress(true);
    creator.setIndexPOI(true);
    // creator.setIndexTransport(true);
    creator.setIndexRouting(true);
    // creator.deleteDatabaseIndexes = false;
    // creator.recreateOnlyBinaryFile = true;
    // creator.deleteOsmDB = false;
    creator.setZoomWaySmoothness(2);
    // MapZooms.parseZooms("15-");
    MapZooms zooms = MapZooms.getDefault();
    String file = rootFolder + "/temp/map.osm";
    // String file = rootFolder + "/temp/ukraine_kiev-city_europe.pbf";
    // String file = rootFolder + "/maps/diff/2017_08_28_00_30_before.osm";
    // String file = rootFolder + "/maps/diff/ukraine_kiev-city_europe.pbf";
    // String file = rootFolder + "/repos/resources/test-resources/synthetic_test_rendering.osm";
    int st = file.lastIndexOf('/');
    int e = file.indexOf('.', st);
    creator.setNodesDBFile(new File(rootFolder + "/maps/" + file.substring(st, e) + ".tmp.odb"));
    creator.setSRTMData(new File(rootFolder + "/maps/srtm/"));
    MapPoiTypes.setDefault(new MapPoiTypes(rootFolder + "/repos//resources/poi/poi_types.xml"));
    MapRenderingTypesEncoder rt = new MapRenderingTypesEncoder(rootFolder + "/repos//resources/obf_creation/rendering_types.xml", new File(file).getName());
    creator.setLastModifiedDate(1504224000000l);
    creator.generateIndexes(new File(file), new ConsoleProgressImplementation(1), null, zooms, rt, log);
    // new File(file),
    // $NON-NLS-1$
    log.info("WHOLE GENERATION TIME :  " + (System.currentTimeMillis() - time));
    // $NON-NLS-1$ //$NON-NLS-2$
    log.info("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE + " count " + BinaryMapIndexWriter.COORDINATES_COUNT);
    // $NON-NLS-1$
    log.info("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE);
    // $NON-NLS-1$
    log.info("ID_SIZE " + BinaryMapIndexWriter.ID_SIZE);
    // $NON-NLS-1$
    log.info("- COORD_TYPES_ID SIZE " + (BinaryMapIndexWriter.COORDINATES_SIZE + BinaryMapIndexWriter.TYPES_SIZE + BinaryMapIndexWriter.ID_SIZE));
    // $NON-NLS-1$
    log.info("- MAP_DATA_SIZE " + BinaryMapIndexWriter.MAP_DATA_SIZE);
    // $NON-NLS-1$
    log.info("- STRING_TABLE_SIZE " + BinaryMapIndexWriter.STRING_TABLE_SIZE);
    // $NON-NLS-1$
    log.info("-- MAP_DATA_AND_STRINGS SIZE " + (BinaryMapIndexWriter.MAP_DATA_SIZE + BinaryMapIndexWriter.STRING_TABLE_SIZE));
}
Also used : MapRenderingTypesEncoder(net.osmand.osm.MapRenderingTypesEncoder) MapZooms(net.osmand.binary.MapZooms) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) ConsoleProgressImplementation(net.osmand.impl.ConsoleProgressImplementation) MapPoiTypes(net.osmand.osm.MapPoiTypes)

Example 2 with MapZooms

use of net.osmand.binary.MapZooms in project OsmAnd-tools by osmandapp.

the class BasemapProcessor method main.

public static void main(String[] p) throws InterruptedException, SQLException, IOException, XMLStreamException, XmlPullParserException {
    if (p.length == 0) {
        System.out.println("Please specify folder with basemap *.osm or *.osm.bz2 files");
    } else {
        boolean mini = false;
        long time = System.currentTimeMillis();
        MapRenderingTypesEncoder rt = new MapRenderingTypesEncoder("basemap");
        // BASEMAP generation
        File folder = new File(p[0]);
        if (p.length >= 2 && p[1].equals("mini")) {
            mini = true;
        }
        // MapZooms zooms = MapZooms.parseZooms("1-2;3;4-5;6-7;8-9;10-");
        int zoomSmoothness = mini ? 2 : 2;
        MapZooms zooms = mini ? MapZooms.parseZooms("1-2;3;4-5;6-") : MapZooms.parseZooms("1-2;3;4-5;6-7;8;9-");
        MOST_DETAILED_APPROXIMATION = mini ? 6 : 11;
        // $NON-NLS-1$
        IndexCreator creator = new IndexCreator(folder);
        creator.setDialects(DBDialect.SQLITE_IN_MEMORY, DBDialect.SQLITE_IN_MEMORY);
        creator.setIndexMap(true);
        creator.setIndexPOI(mini ? false : true);
        creator.setZoomWaySmoothness(zoomSmoothness);
        creator.setMapFileName(mini ? "World_basemap_mini_test_2.obf" : "World_basemap_2.obf");
        ArrayList<File> src = new ArrayList<File>();
        for (File f : folder.listFiles()) {
            if (f.getName().endsWith(".osm") || f.getName().endsWith(".osm.bz2")) {
                src.add(f);
            }
        }
        // BASEMAP generation
        // creator.generateBasemapIndex(new ConsoleProgressImplementation(1), null, zooms, rt, log, "basemap",
        // new File(basemapParent, "10m_coastline_out_fix_caspean_arctic.osm")
        // ,new File(basemapParent, "roads_gen.osm")
        // ,new File(basemapParent, "10m_admin_level.osm")
        // ,new File(basemapParent, "10m_rivers.osm")
        // ,new File(basemapParent, "10m_lakes.osm")
        // ,new File(basemapParent, "10m_populated_places.osm")
        // );
        creator.generateBasemapIndex(new ConsoleProgressImplementation(1), null, zooms, rt, log, "basemap", src.toArray(new File[src.size()]));
    }
}
Also used : MapRenderingTypesEncoder(net.osmand.osm.MapRenderingTypesEncoder) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) MapZooms(net.osmand.binary.MapZooms) File(java.io.File) ConsoleProgressImplementation(net.osmand.impl.ConsoleProgressImplementation)

Example 3 with MapZooms

use of net.osmand.binary.MapZooms in project OsmAnd-tools by osmandapp.

the class CountryOcbfGeneration method createFile.

private void createFile(CountryRegion global, Map<String, Set<TranslateEntity>> translates, Map<String, File> polygonFiles, String targetObf, String targetOsmXml) throws IOException, SQLException, InterruptedException, XmlPullParserException {
    File osm = new File(targetOsmXml);
    XmlSerializer serializer = new org.kxml2.io.KXmlSerializer();
    FileOutputStream fous = new FileOutputStream(osm);
    serializer.setOutput(fous, "UTF-8");
    serializer.startDocument("UTF-8", true);
    serializer.startTag(null, "osm");
    serializer.attribute(null, "version", "0.6");
    serializer.attribute(null, "generator", "OsmAnd");
    serializer.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true);
    for (CountryRegion r : global.children) {
        r.parent = null;
        processRegion(r, translates, polygonFiles, targetObf, targetOsmXml, "", serializer);
    }
    serializer.endDocument();
    serializer.flush();
    fous.close();
    // $NON-NLS-1$
    IndexCreator creator = new IndexCreator(new File(targetObf).getParentFile());
    creator.setMapFileName(new File(targetObf).getName());
    creator.setIndexMap(true);
    creator.setIndexAddress(false);
    creator.setIndexPOI(false);
    creator.setIndexTransport(false);
    creator.setIndexRouting(false);
    MapZooms zooms = MapZooms.parseZooms("5-6");
    creator.generateIndexes(osm, new ConsoleProgressImplementation(1), null, zooms, new MapRenderingTypesEncoder("regions"), log);
}
Also used : MapRenderingTypesEncoder(net.osmand.osm.MapRenderingTypesEncoder) FileOutputStream(java.io.FileOutputStream) MapZooms(net.osmand.binary.MapZooms) IndexCreator(net.osmand.data.preparation.IndexCreator) File(java.io.File) ConsoleProgressImplementation(net.osmand.impl.ConsoleProgressImplementation) XmlSerializer(org.xmlpull.v1.XmlSerializer)

Example 4 with MapZooms

use of net.osmand.binary.MapZooms in project OsmAnd-tools by osmandapp.

the class IndexCreator method generateRegionsFile.

public static void generateRegionsFile() throws IOException, SQLException, InterruptedException, XmlPullParserException {
    MapRenderingTypesEncoder rt = new MapRenderingTypesEncoder("regions");
    String file = "/home/victor/projects/osmand/repo/resources/osmand_regions.osm";
    String folder = "/home/victor/projects/osmand/repo/resources/countries-info/";
    // $NON-NLS-1$
    IndexCreator creator = new IndexCreator(new File(folder));
    creator.setMapFileName("regions.ocbf");
    creator.setIndexMap(true);
    creator.setIndexAddress(false);
    creator.setIndexPOI(false);
    creator.setIndexTransport(false);
    creator.setIndexRouting(false);
    MapZooms zooms = MapZooms.parseZooms("5-6");
    creator.zoomWaySmoothness = 1;
    int st = file.lastIndexOf('/');
    int e = file.indexOf('.', st);
    creator.setNodesDBFile(new File(folder + file.substring(st, e) + ".tmp.odb"));
    creator.generateIndexes(new File(file), new ConsoleProgressImplementation(1), null, zooms, rt, log);
}
Also used : MapRenderingTypesEncoder(net.osmand.osm.MapRenderingTypesEncoder) MapZooms(net.osmand.binary.MapZooms) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) ConsoleProgressImplementation(net.osmand.impl.ConsoleProgressImplementation)

Aggregations

File (java.io.File)4 MapZooms (net.osmand.binary.MapZooms)4 ConsoleProgressImplementation (net.osmand.impl.ConsoleProgressImplementation)4 MapRenderingTypesEncoder (net.osmand.osm.MapRenderingTypesEncoder)4 RandomAccessFile (java.io.RandomAccessFile)2 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 FileOutputStream (java.io.FileOutputStream)1 ArrayList (java.util.ArrayList)1 IndexCreator (net.osmand.data.preparation.IndexCreator)1 MapPoiTypes (net.osmand.osm.MapPoiTypes)1 XmlSerializer (org.xmlpull.v1.XmlSerializer)1