Search in sources :

Example 1 with IProgress

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

the class DownloadOsmGPX method generateObfFile.

private void generateObfFile(QueryParams qp) throws IOException, SQLException, InterruptedException, XmlPullParserException {
    if (qp.obfFile != null) {
        IndexCreatorSettings settings = new IndexCreatorSettings();
        settings.indexMap = true;
        settings.indexAddress = false;
        settings.indexPOI = true;
        settings.indexTransport = false;
        settings.indexRouting = false;
        RTree.clearCache();
        File folder = new File(qp.obfFile.getParentFile(), "gen");
        String fileName = qp.obfFile.getName();
        File targetObf = qp.obfFile;
        try {
            folder.mkdirs();
            IndexCreator ic = new IndexCreator(folder, settings);
            MapRenderingTypesEncoder types = new MapRenderingTypesEncoder(null, fileName);
            ic.setMapFileName(fileName);
            IProgress prog = IProgress.EMPTY_PROGRESS;
            prog = new ConsoleProgressImplementation();
            ic.generateIndexes(qp.osmFile, prog, null, MapZooms.getDefault(), types, null);
            new File(folder, ic.getMapFileName()).renameTo(targetObf);
        } finally {
            Algorithms.removeAllFiles(folder);
        }
    }
}
Also used : IndexCreatorSettings(net.osmand.obf.preparation.IndexCreatorSettings) MapRenderingTypesEncoder(net.osmand.osm.MapRenderingTypesEncoder) IProgress(net.osmand.IProgress) IndexCreator(net.osmand.obf.preparation.IndexCreator) GPXFile(net.osmand.GPXUtilities.GPXFile) File(java.io.File) ConsoleProgressImplementation(net.osmand.impl.ConsoleProgressImplementation)

Example 2 with IProgress

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

the class OsmGpxWriteContext method writeObf.

public File writeObf(List<File> files, File tmpFolder, String fileName, File targetObf) throws IOException, SQLException, InterruptedException, XmlPullParserException {
    startDocument();
    for (File gf : files) {
        GPXFile f = GPXUtilities.loadGPXFile(gf);
        GPXTrackAnalysis analysis = f.getAnalysis(gf.lastModified());
        writeTrack(null, null, f, analysis, "GPX");
    }
    endDocument();
    IndexCreatorSettings settings = new IndexCreatorSettings();
    settings.indexMap = true;
    settings.indexAddress = false;
    settings.indexPOI = true;
    settings.indexTransport = false;
    settings.indexRouting = false;
    RTree.clearCache();
    try {
        tmpFolder.mkdirs();
        IndexCreator ic = new IndexCreator(tmpFolder, settings);
        MapRenderingTypesEncoder types = new MapRenderingTypesEncoder(null, fileName);
        ic.setMapFileName(fileName);
        // IProgress.EMPTY_PROGRESS
        IProgress prog = IProgress.EMPTY_PROGRESS;
        // prog = new ConsoleProgressImplementation();
        ic.generateIndexes(qp.osmFile, prog, null, MapZooms.getDefault(), types, null);
        new File(tmpFolder, ic.getMapFileName()).renameTo(targetObf);
    } finally {
        Algorithms.removeAllFiles(tmpFolder);
    }
    return targetObf;
}
Also used : IndexCreatorSettings(net.osmand.obf.preparation.IndexCreatorSettings) MapRenderingTypesEncoder(net.osmand.osm.MapRenderingTypesEncoder) IProgress(net.osmand.IProgress) GPXTrackAnalysis(net.osmand.GPXUtilities.GPXTrackAnalysis) IndexCreator(net.osmand.obf.preparation.IndexCreator) GPXFile(net.osmand.GPXUtilities.GPXFile) GPXFile(net.osmand.GPXUtilities.GPXFile)

Aggregations

GPXFile (net.osmand.GPXUtilities.GPXFile)2 IProgress (net.osmand.IProgress)2 IndexCreator (net.osmand.obf.preparation.IndexCreator)2 IndexCreatorSettings (net.osmand.obf.preparation.IndexCreatorSettings)2 MapRenderingTypesEncoder (net.osmand.osm.MapRenderingTypesEncoder)2 File (java.io.File)1 GPXTrackAnalysis (net.osmand.GPXUtilities.GPXTrackAnalysis)1 ConsoleProgressImplementation (net.osmand.impl.ConsoleProgressImplementation)1