Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ad75342815
2 changed files with 33 additions and 37 deletions
|
@ -282,19 +282,19 @@ public class BinaryInspector {
|
||||||
ous.writeRawByte(v & 0xFF);
|
ous.writeRawByte(v & 0xFF);
|
||||||
//written += 4;
|
//written += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static List<Float> combineParts(File fileToExtract, Map<File, String> partsToExtractFrom) throws IOException {
|
public static List<Float> combineParts(File fileToExtract, Map<File, String> partsToExtractFrom) throws IOException {
|
||||||
BinaryMapIndexReader[] indexes = new BinaryMapIndexReader[partsToExtractFrom.size()];
|
BinaryMapIndexReader[] indexes = new BinaryMapIndexReader[partsToExtractFrom.size()];
|
||||||
RandomAccessFile[] rafs = new RandomAccessFile[partsToExtractFrom.size()];
|
RandomAccessFile[] rafs = new RandomAccessFile[partsToExtractFrom.size()];
|
||||||
|
|
||||||
LinkedHashSet<Float>[] partsSet = new LinkedHashSet[partsToExtractFrom.size()];
|
LinkedHashSet<Float>[] partsSet = new LinkedHashSet[partsToExtractFrom.size()];
|
||||||
int c = 0;
|
int c = 0;
|
||||||
Set<String> addressNames = new LinkedHashSet<String>();
|
Set<String> addressNames = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
|
||||||
int version = -1;
|
int version = -1;
|
||||||
// Go through all files and validate conistency
|
// Go through all files and validate conistency
|
||||||
for(File f : partsToExtractFrom.keySet()){
|
for(File f : partsToExtractFrom.keySet()){
|
||||||
if(f.getAbsolutePath().equals(fileToExtract.getAbsolutePath())){
|
if(f.getAbsolutePath().equals(fileToExtract.getAbsolutePath())){
|
||||||
System.err.println("Error : Input file is equal to output file " + f.getAbsolutePath());
|
System.err.println("Error : Input file is equal to output file " + f.getAbsolutePath());
|
||||||
|
@ -311,7 +311,7 @@ public class BinaryInspector {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkedHashSet<Float> temp = new LinkedHashSet<Float>();
|
LinkedHashSet<Float> temp = new LinkedHashSet<Float>();
|
||||||
String pattern = partsToExtractFrom.get(f);
|
String pattern = partsToExtractFrom.get(f);
|
||||||
boolean minus = true;
|
boolean minus = true;
|
||||||
|
@ -320,7 +320,7 @@ public class BinaryInspector {
|
||||||
BinaryIndexPart part = indexes[c].getIndexes().get(i);
|
BinaryIndexPart part = indexes[c].getIndexes().get(i);
|
||||||
if(part instanceof MapIndex){
|
if(part instanceof MapIndex){
|
||||||
List<MapRoot> roots = ((MapIndex) part).getRoots();
|
List<MapRoot> roots = ((MapIndex) part).getRoots();
|
||||||
int rsize = roots.size();
|
int rsize = roots.size();
|
||||||
for(int j=0; j<rsize; j++){
|
for(int j=0; j<rsize; j++){
|
||||||
partsSet[c].add((i + 1f) + (j + 1) / 10f);
|
partsSet[c].add((i + 1f) + (j + 1) / 10f);
|
||||||
}
|
}
|
||||||
|
@ -350,17 +350,17 @@ public class BinaryInspector {
|
||||||
|
|
||||||
c++;
|
c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// write files
|
// write files
|
||||||
FileOutputStream fout = new FileOutputStream(fileToExtract);
|
FileOutputStream fout = new FileOutputStream(fileToExtract);
|
||||||
CodedOutputStream ous = CodedOutputStream.newInstance(fout, BUFFER_SIZE);
|
CodedOutputStream ous = CodedOutputStream.newInstance(fout, BUFFER_SIZE);
|
||||||
List<Float> list = new ArrayList<Float>();
|
List<Float> list = new ArrayList<Float>();
|
||||||
byte[] BUFFER_TO_READ = new byte[BUFFER_SIZE];
|
byte[] BUFFER_TO_READ = new byte[BUFFER_SIZE];
|
||||||
|
|
||||||
ous.writeInt32(OsmandOdb.OsmAndStructure.VERSION_FIELD_NUMBER, version);
|
ous.writeInt32(OsmandOdb.OsmAndStructure.VERSION_FIELD_NUMBER, version);
|
||||||
ous.writeInt64(OsmandOdb.OsmAndStructure.DATECREATED_FIELD_NUMBER, System.currentTimeMillis());
|
ous.writeInt64(OsmandOdb.OsmAndStructure.DATECREATED_FIELD_NUMBER, System.currentTimeMillis());
|
||||||
|
|
||||||
|
|
||||||
for (int k = 0; k < indexes.length; k++) {
|
for (int k = 0; k < indexes.length; k++) {
|
||||||
LinkedHashSet<Float> partSet = partsSet[k];
|
LinkedHashSet<Float> partSet = partsSet[k];
|
||||||
BinaryMapIndexReader index = indexes[k];
|
BinaryMapIndexReader index = indexes[k];
|
||||||
|
@ -373,7 +373,7 @@ public class BinaryInspector {
|
||||||
|
|
||||||
BinaryIndexPart part = index.getIndexes().get(i);
|
BinaryIndexPart part = index.getIndexes().get(i);
|
||||||
String map;
|
String map;
|
||||||
|
|
||||||
if (part instanceof MapIndex) {
|
if (part instanceof MapIndex) {
|
||||||
ous.writeTag(OsmandOdb.OsmAndStructure.MAPINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED);
|
ous.writeTag(OsmandOdb.OsmAndStructure.MAPINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED);
|
||||||
map = "Map";
|
map = "Map";
|
||||||
|
@ -401,15 +401,15 @@ public class BinaryInspector {
|
||||||
copyBinaryPart(ous, BUFFER_TO_READ, raf, part.getFilePointer(), part.getLength());
|
copyBinaryPart(ous, BUFFER_TO_READ, raf, part.getFilePointer(), part.getLength());
|
||||||
System.out.println(MessageFormat.format("{2} part {0} is extracted {1} bytes",
|
System.out.println(MessageFormat.format("{2} part {0} is extracted {1} bytes",
|
||||||
new Object[]{part.getName(), part.getLength(), map}));
|
new Object[]{part.getName(), part.getLength(), map}));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ous.writeInt32(OsmandOdb.OsmAndStructure.VERSIONCONFIRM_FIELD_NUMBER, version);
|
ous.writeInt32(OsmandOdb.OsmAndStructure.VERSIONCONFIRM_FIELD_NUMBER, version);
|
||||||
ous.flush();
|
ous.flush();
|
||||||
fout.close();
|
fout.close();
|
||||||
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@ public class BinaryInspector {
|
||||||
toRead -= read;
|
toRead -= read;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String formatBounds(int left, int right, int top, int bottom) {
|
protected String formatBounds(int left, int right, int top, int bottom) {
|
||||||
double l = MapUtils.get31LongitudeX(left);
|
double l = MapUtils.get31LongitudeX(left);
|
||||||
|
@ -512,7 +512,7 @@ public class BinaryInspector {
|
||||||
} else if (p instanceof PoiRegion && (vInfo != null && vInfo.isVpoi())) {
|
} else if (p instanceof PoiRegion && (vInfo != null && vInfo.isVpoi())) {
|
||||||
printPOIDetailInfo(vInfo, index, (PoiRegion) p);
|
printPOIDetailInfo(vInfo, index, (PoiRegion) p);
|
||||||
} else if (p instanceof TransportIndex && (vInfo != null && vInfo.isVtransport())) {
|
} else if (p instanceof TransportIndex && (vInfo != null && vInfo.isVtransport())) {
|
||||||
|
|
||||||
} else if (p instanceof AddressRegion) {
|
} else if (p instanceof AddressRegion) {
|
||||||
List<CitiesBlock> cities = ((AddressRegion) p).cities;
|
List<CitiesBlock> cities = ((AddressRegion) p).cities;
|
||||||
for (CitiesBlock c : cities) {
|
for (CitiesBlock c : cities) {
|
||||||
|
@ -557,12 +557,12 @@ public class BinaryInspector {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b.setLength(0);
|
b.setLength(0);
|
||||||
b.append("Road ");
|
b.append("Road ");
|
||||||
b.append(obj.id);
|
b.append(obj.id);
|
||||||
b.append(" osmid ").append(obj.getId() >> (SHIFT_ID));
|
b.append(" osmid ").append(obj.getId() >> (SHIFT_ID));
|
||||||
|
|
||||||
for (int i = 0; i < obj.getTypes().length; i++) {
|
for (int i = 0; i < obj.getTypes().length; i++) {
|
||||||
RouteTypeRule rr = obj.region.quickGetEncodingRule(obj.getTypes()[i]);
|
RouteTypeRule rr = obj.region.quickGetEncodingRule(obj.getTypes()[i]);
|
||||||
b.append(" ").append(rr.getTag()).append("='").append(rr.getValue()).append("'");
|
b.append(" ").append(rr.getTag()).append("='").append(rr.getValue()).append("'");
|
||||||
|
@ -1070,7 +1070,7 @@ public class BinaryInspector {
|
||||||
name = name.replace("&", "&");
|
name = name.replace("&", "&");
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printOsmMapDetails(BinaryMapDataObject obj, StringBuilder b) {
|
private void printOsmMapDetails(BinaryMapDataObject obj, StringBuilder b) {
|
||||||
boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0;
|
boolean multipolygon = obj.getPolygonInnerCoordinates() != null && obj.getPolygonInnerCoordinates().length > 0;
|
||||||
boolean point = obj.getPointsLength() == 1;
|
boolean point = obj.getPointsLength() == 1;
|
||||||
|
@ -1169,7 +1169,7 @@ public class BinaryInspector {
|
||||||
b.append("</way>\n");
|
b.append("</way>\n");
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void printTransportDetailInfo(VerboseInfo verbose, BinaryMapIndexReader index, TransportIndex p) throws IOException {
|
private void printTransportDetailInfo(VerboseInfo verbose, BinaryMapIndexReader index, TransportIndex p) throws IOException {
|
||||||
SearchRequest<TransportStop> sr = BinaryMapIndexReader.buildSearchTransportRequest(
|
SearchRequest<TransportStop> sr = BinaryMapIndexReader.buildSearchTransportRequest(
|
||||||
MapUtils.get31TileNumberX(verbose.lonleft),
|
MapUtils.get31TileNumberX(verbose.lonleft),
|
||||||
|
@ -1245,10 +1245,10 @@ public class BinaryInspector {
|
||||||
|
|
||||||
index.initCategories(p);
|
index.initCategories(p);
|
||||||
println("\tRegion: " + p.name);
|
println("\tRegion: " + p.name);
|
||||||
|
|
||||||
println("\t\tBounds " + formatLatBounds(MapUtils.get31LongitudeX(p.left31),
|
println("\t\tBounds " + formatLatBounds(MapUtils.get31LongitudeX(p.left31),
|
||||||
MapUtils.get31LongitudeX(p.right31),
|
MapUtils.get31LongitudeX(p.right31),
|
||||||
MapUtils.get31LatitudeY(p.top31),
|
MapUtils.get31LatitudeY(p.top31),
|
||||||
MapUtils.get31LatitudeY(p.bottom31)));
|
MapUtils.get31LatitudeY(p.bottom31)));
|
||||||
println("\t\tCategories:");
|
println("\t\tCategories:");
|
||||||
for (int i = 0; i < p.categories.size(); i++) {
|
for (int i = 0; i < p.categories.size(); i++) {
|
||||||
|
@ -1274,15 +1274,13 @@ public class BinaryInspector {
|
||||||
System.out.println("It allows print info about file, extract parts and merge indexes.");
|
System.out.println("It allows print info about file, extract parts and merge indexes.");
|
||||||
System.out.println("\nUsage for print info : inspector [-vaddress] [-vcitynames] [-vstreetgroups] [-vstreets] [-vbuildings] [-vintersections] [-vmap] [-vmapobjects] [-vmapcoordinates] [-osm] [-vpoi] [-vrouting] [-vtransport] [-zoom=Zoom] [-bbox=LeftLon,TopLat,RightLon,BottomLat] [file]");
|
System.out.println("\nUsage for print info : inspector [-vaddress] [-vcitynames] [-vstreetgroups] [-vstreets] [-vbuildings] [-vintersections] [-vmap] [-vmapobjects] [-vmapcoordinates] [-osm] [-vpoi] [-vrouting] [-vtransport] [-zoom=Zoom] [-bbox=LeftLon,TopLat,RightLon,BottomLat] [file]");
|
||||||
System.out.println(" Prints information about [file] binary index of OsmAnd.");
|
System.out.println(" Prints information about [file] binary index of OsmAnd.");
|
||||||
System.out.println(" -v.. more verbouse output (like all cities and their streets or all map objects with tags/values and coordinates)");
|
System.out.println(" -v.. more verbose output (like all cities and their streets or all map objects with tags/values and coordinates)");
|
||||||
System.out.println("\nUsage for combining indexes : inspector -c file_to_create (file_from_extract ((+|-)parts_to_extract)? )*");
|
System.out.println("\nUsage for combining indexes : inspector -c file_to_create (file_from_extract ((+|-)parts_to_extract)? )*");
|
||||||
System.out.println("\tCreate new file of extracted parts from input file. [parts_to_extract] could be parts to include or exclude.");
|
System.out.println("\tCreate new file of extracted parts from input file. [parts_to_extract] could be parts to include or exclude.");
|
||||||
System.out.println(" Example : inspector -c output_file input_file +1,2,3\n\tExtracts 1, 2, 3 parts (could be find in print info)");
|
System.out.println(" Example : inspector -c output_file input_file +1,2,3\n\tExtracts 1, 2, 3 parts (could be find in print info)");
|
||||||
System.out.println(" Example : inspector -c output_file input_file -2,3\n\tExtracts all parts excluding 2, 3");
|
System.out.println(" Example : inspector -c output_file input_file -2,3\n\tExtracts all parts excluding 2, 3");
|
||||||
System.out.println(" Example : inspector -c output_file input_file1 input_file2 input_file3\n\tSimply combine 3 files");
|
System.out.println(" Example : inspector -c output_file input_file1 input_file2 input_file3\n\tSimply combine 3 files");
|
||||||
System.out.println(" Example : inspector -c output_file input_file1 input_file2 -4\n\tCombine all parts of 1st file and all parts excluding 4th part of 2nd file");
|
System.out.println(" Example : inspector -c output_file input_file1 input_file2 -4\n\tCombine all parts of 1st file and all parts excluding 4th part of 2nd file");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,10 +4,10 @@ package net.osmand.binary;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BinaryInspectorNative {
|
public class BinaryInspectorNative {
|
||||||
|
|
||||||
|
|
||||||
public static final int BUFFER_SIZE = 1 << 20;
|
public static final int BUFFER_SIZE = 1 << 20;
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
if(args == null || args.length == 0) {
|
if(args == null || args.length == 0) {
|
||||||
printUsage(null);
|
printUsage(null);
|
||||||
|
@ -16,7 +16,7 @@ public class BinaryInspectorNative {
|
||||||
args = new String[]{"-vmap", "-bbox=11.3,47.1,11.6,47", "/home/victor/projects/OsmAnd/data/osm-gen/Austria_2.obf"};
|
args = new String[]{"-vmap", "-bbox=11.3,47.1,11.6,47", "/home/victor/projects/OsmAnd/data/osm-gen/Austria_2.obf"};
|
||||||
// test cases show info
|
// test cases show info
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void printUsage(String warning) {
|
public static void printUsage(String warning) {
|
||||||
if(warning != null){
|
if(warning != null){
|
||||||
println(warning);
|
println(warning);
|
||||||
|
@ -25,15 +25,13 @@ public class BinaryInspectorNative {
|
||||||
println("It allows print info about file, extract parts and merge indexes.");
|
println("It allows print info about file, extract parts and merge indexes.");
|
||||||
println("\nUsage for print info : inspector [-vaddress] [-vstreetgroups] [-vstreets] [-vbuildings] [-vintersections] [-vmap] [-vpoi] [-vtransport] [-zoom=Zoom] [-bbox=LeftLon,TopLat,RightLon,BottomLan] [file]");
|
println("\nUsage for print info : inspector [-vaddress] [-vstreetgroups] [-vstreets] [-vbuildings] [-vintersections] [-vmap] [-vpoi] [-vtransport] [-zoom=Zoom] [-bbox=LeftLon,TopLat,RightLon,BottomLan] [file]");
|
||||||
println(" Prints information about [file] binary index of OsmAnd.");
|
println(" Prints information about [file] binary index of OsmAnd.");
|
||||||
println(" -v.. more verbouse output (like all cities and their streets or all map objects with tags/values and coordinates)");
|
println(" -v.. more verbose output (like all cities and their streets or all map objects with tags/values and coordinates)");
|
||||||
println("\nUsage for combining indexes : inspector -c file_to_create (file_from_extract ((+|-)parts_to_extract)? )*");
|
println("\nUsage for combining indexes : inspector -c file_to_create (file_from_extract ((+|-)parts_to_extract)? )*");
|
||||||
println("\tCreate new file of extracted parts from input file. [parts_to_extract] could be parts to include or exclude.");
|
println("\tCreate new file of extracted parts from input file. [parts_to_extract] could be parts to include or exclude.");
|
||||||
println(" Example : inspector -c output_file input_file +1,2,3\n\tExtracts 1, 2, 3 parts (could be find in print info)");
|
println(" Example : inspector -c output_file input_file +1,2,3\n\tExtracts 1, 2, 3 parts (could be find in print info)");
|
||||||
println(" Example : inspector -c output_file input_file -2,3\n\tExtracts all parts excluding 2, 3");
|
println(" Example : inspector -c output_file input_file -2,3\n\tExtracts all parts excluding 2, 3");
|
||||||
println(" Example : inspector -c output_file input_file1 input_file2 input_file3\n\tSimply combine 3 files");
|
println(" Example : inspector -c output_file input_file1 input_file2 input_file3\n\tSimply combine 3 files");
|
||||||
println(" Example : inspector -c output_file input_file1 input_file2 -4\n\tCombine all parts of 1st file and all parts excluding 4th part of 2nd file");
|
println(" Example : inspector -c output_file input_file1 input_file2 -4\n\tCombine all parts of 1st file and all parts excluding 4th part of 2nd file");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void println(String string) {
|
private static void println(String string) {
|
||||||
|
|
Loading…
Reference in a new issue