From a6b96b49eb5d4fb6661165e0115e0b8ca3d8f995 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sat, 16 Jun 2018 11:22:44 +0200 Subject: [PATCH] Update regions prepare file --- .../main/java/net/osmand/map/OsmandRegions.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java b/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java index f1faff0222..c094a160ea 100644 --- a/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java +++ b/OsmAnd-java/src/main/java/net/osmand/map/OsmandRegions.java @@ -15,7 +15,9 @@ import net.osmand.util.MapAlgorithms; import net.osmand.util.MapUtils; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.RandomAccessFile; import java.util.ArrayList; import java.util.Arrays; @@ -92,6 +94,18 @@ public class OsmandRegions { } + + public BinaryMapIndexReader prepareFile() throws IOException { + File regions = new File("regions.ocbf"); + if (!regions.exists()) { + InputStream is = OsmandRegions.class.getResourceAsStream("regions.ocbf"); + FileOutputStream fous = new FileOutputStream(regions); + Algorithms.streamCopy(is, fous); + fous.close(); + } + return prepareFile(regions.getAbsolutePath()); + } + public BinaryMapIndexReader prepareFile(String fileName) throws IOException { reader = new BinaryMapIndexReader(new RandomAccessFile(fileName, "r"), new File(fileName)); // final Collator clt = OsmAndCollator.primaryCollator();