Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-05-17 19:08:11 +02:00
commit 6e29b5d51f
4 changed files with 40 additions and 29 deletions

View file

@ -123,6 +123,7 @@ public class BinaryInspector {
double latbottom = -85;
double lonleft = -180;
double lonright = 180;
String lang = null;
int zoom = -1;
public boolean isVaddress() {
@ -186,6 +187,8 @@ public class BinaryInspector {
}
} else if (params[i].equals("-vtransport")) {
vtransport = true;
} else if (params[i].startsWith("-lang=")) {
lang = params[i].substring("-lang=".length());
} else if (params[i].startsWith("-zoom=")) {
zoom = Integer.parseInt(params[i].substring("-zoom=".length()));
} else if (params[i].startsWith("-bbox=")) {
@ -603,24 +606,17 @@ public class BinaryInspector {
println("\tTotal map objects: " + mapObjectsCounter.value);
}
private void printAddressDetailedInfo(VerboseInfo verbose, BinaryMapIndexReader index, AddressRegion region) throws IOException {
String[] cityType_String = new String[] {
"Cities/Towns section",
"Villages section",
"Postcodes section",
};
int[] cityType = new int[] {
BinaryMapAddressReaderAdapter.CITY_TOWN_TYPE,
BinaryMapAddressReaderAdapter.VILLAGES_TYPE,
BinaryMapAddressReaderAdapter.POSTCODES_TYPE
private void printAddressDetailedInfo(VerboseInfo verbose, BinaryMapIndexReader index, AddressRegion region) throws IOException {
String[] cityType_String = new String[]{
"Cities/Towns section",
"Villages section",
"Postcodes section",
};
String lang = "en";
for (int j = 0; j < cityType.length; j++) {
int type = cityType[j];
for (int j = 0; j < BinaryMapAddressReaderAdapter.CITY_TYPES.length; j++) {
int type = BinaryMapAddressReaderAdapter.CITY_TYPES[j];
final List<City> cities = index.getCities(region, null, type);
print(MessageFormat.format("\t{0}, {1,number,#} group(s)", new Object[]{cityType_String[j], cities.size()}));
print(MessageFormat.format("\t{0}, {1,number,#} group(s)", cityType_String[j], cities.size()));
if (BinaryMapAddressReaderAdapter.CITY_TOWN_TYPE == type) {
if (!verbose.vstreetgroups && !verbose.vcities) {
println("");
@ -635,10 +631,11 @@ public class BinaryInspector {
for (City c : cities) {
int size = index.preloadStreets(c, null);
List<Street> streets = new ArrayList<Street>(c.getStreets());
print(MessageFormat.format("\t\t''{0}'' [{1,number,#}], {2,number,#} street(s) size {3,number,#} bytes",
new Object[]{c.getName(lang), c.getId(), streets.size(), size}));
if(!verbose.vstreets)
{
String cityDescription = (j == BinaryMapAddressReaderAdapter.POSTCODES_TYPE ?
MessageFormat.format("\t\t''{0}'' {1,number,#} street(s) size {2,number,#} bytes", c.getName(verbose.lang), streets.size(), size) :
MessageFormat.format("\t\t''{0}'' [{1,number,#}], {2,number,#} street(s) size {3,number,#} bytes", c.getName(verbose.lang), c.getId(), streets.size(), size));
print(cityDescription);
if (!verbose.vstreets) {
println("");
continue;
}
@ -654,20 +651,19 @@ public class BinaryInspector {
final List<Street> intersections = t.getIntersectedStreets();
println(MessageFormat.format("\t\t\t''{0}'' [{1,number,#}], {2,number,#} building(s), {3,number,#} intersections(s)",
new Object[]{t.getName(lang), t.getId(), buildings.size(), intersections.size()}));
new Object[]{t.getName(verbose.lang), t.getId(), buildings.size(), intersections.size()}));
if (buildings != null && !buildings.isEmpty() && verbose.vbuildings) {
println("\t\t\t\tBuildings:");
for (Building b : buildings) {
println(MessageFormat.format("\t\t\t\t{0} [{1,number,#}]",
new Object[]{b.getName(lang), b.getId()}));
new Object[]{b.getName(verbose.lang), b.getId()}));
}
}
if (intersections != null && !intersections.isEmpty() && verbose.vintersections) {
print("\t\t\t\tIntersects with:");
for (Street s : intersections) {
println("\t\t\t\t\t" + s.getName(lang));
println("\t\t\t\t\t" + s.getName(verbose.lang));
}
}
}

View file

@ -593,7 +593,12 @@ public class BinaryMapIndexReader {
}
public int preloadStreets(City c, SearchRequest<Street> resultMatcher) throws IOException {
AddressRegion reg = checkAddressIndex(c.getFileOffset());
AddressRegion reg;
try {
reg = checkAddressIndex(c.getFileOffset());
} catch (IllegalArgumentException e) {
throw new IOException(e.getMessage() + " while reading " + c + " (id: " + c.getId() + ")");
}
codedIS.seek(c.getFileOffset());
int size = codedIS.readRawVarint32();
int old = codedIS.pushLimit(size);
@ -1737,9 +1742,6 @@ public class BinaryMapIndexReader {
public static class MapIndex extends BinaryIndexPart {
public String getPartName() { return "Map"; }
public int getFieldNumber() { return OsmandOdb.OsmAndStructure.MAPINDEX_FIELD_NUMBER; }
List<MapRoot> roots = new ArrayList<MapRoot>();
Map<String, Map<String, Integer>> encodingRules = new HashMap<String, Map<String, Integer>>();

View file

@ -58,6 +58,13 @@ public class City extends MapObject {
return new City(postcode, POSTCODE_INTERNAL_ID--);
}
public City(City city) {
this.type = city.type;
this.listOfStreets = new ArrayList<>(city.listOfStreets);
this.postcode = city.postcode;
this.closestCity = city.closestCity;
}
public City(CityType type) {
if (type == null) {
throw new NullPointerException();

View file

@ -23,6 +23,7 @@ public abstract class MapObject implements Comparable<MapObject> {
protected LatLon location = null;
protected int fileOffset = 0;
protected Long id = null;
public static final Comparator<MapObject> comparator = new MapObjectComparator();
public void setId(Long id) {
this.id = id;
@ -207,7 +208,12 @@ public abstract class MapObject implements Comparable<MapObject> {
public static class MapObjectComparator implements Comparator<MapObject> {
private final String l;
Collator collator = OsmAndCollator.primaryCollator();
public MapObjectComparator(String lang){
public MapObjectComparator() {
this.l = null;
}
public MapObjectComparator(String lang) {
this.l = lang;
}