From c395d37cb2613349437feaeb5960149248b9aa88 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 1 Nov 2010 23:42:17 +0000 Subject: [PATCH] support binary address index git-svn-id: https://osmand.googlecode.com/svn/trunk@621 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- .../src/net/osmand/ToDoConstants.java | 1 + DataExtractionOSM/src/net/osmand/Version.java | 4 +- .../osmand/binary/BinaryMapIndexWriter.java | 131 +- .../src/net/osmand/binary/OsmandOdb.java | 1059 ++++++++++++++--- .../osmand/data/index/DataIndexReader.java | 102 +- .../osmand/data/index/IndexBatchCreator.java | 1 + .../osmand/data/preparation/IndexCreator.java | 111 +- DataExtractionOSM/src/osmand_odb.proto | 21 +- OsmAnd/AndroidManifest.xml | 2 +- 9 files changed, 1165 insertions(+), 267 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/ToDoConstants.java b/DataExtractionOSM/src/net/osmand/ToDoConstants.java index d16b567988..4d9b3150f3 100644 --- a/DataExtractionOSM/src/net/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/net/osmand/ToDoConstants.java @@ -9,6 +9,7 @@ public class ToDoConstants { // TODO max 101 + // !!! Fix progress in DataExtractionOsm // Outside base 0.4 release // 69. Add phone and site information to POI (enable call to POI and open site) diff --git a/DataExtractionOSM/src/net/osmand/Version.java b/DataExtractionOSM/src/net/osmand/Version.java index 1e68b16f2d..8ff8a7f900 100644 --- a/DataExtractionOSM/src/net/osmand/Version.java +++ b/DataExtractionOSM/src/net/osmand/Version.java @@ -2,9 +2,9 @@ package net.osmand; public class Version { - public static final String APP_VERSION = "0.4.3"; //$NON-NLS-1$ + public static final String APP_VERSION = "0.5.1"; //$NON-NLS-1$ public static final String APP_NAME = "OsmAnd"; //$NON-NLS-1$ - public static final String APP_DESCRIPTION = "beta (b2)"; //$NON-NLS-1$ + public static final String APP_DESCRIPTION = "beta (b1)"; //$NON-NLS-1$ public static final boolean VELCOM_EDITION = false; public static final String APP_NAME_VERSION = APP_NAME + " " + APP_VERSION; //$NON-NLS-1$ diff --git a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java index 4706069157..c3413415e9 100644 --- a/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java +++ b/DataExtractionOSM/src/net/osmand/binary/BinaryMapIndexWriter.java @@ -4,11 +4,15 @@ import java.io.IOException; import java.io.OutputStream; import java.io.RandomAccessFile; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; import java.util.Stack; import net.osmand.Algoritms; +import net.osmand.binary.OsmandOdb.CityIndex; +import net.osmand.binary.OsmandOdb.PostcodeIndex; import net.osmand.binary.OsmandOdb.StreetIndex; +import net.osmand.binary.OsmandOdb.CityIndex.Builder; import net.osmand.data.Building; import net.osmand.data.City; import net.osmand.data.MapObject; @@ -16,6 +20,7 @@ import net.osmand.data.Street; import net.osmand.data.index.IndexConstants; import net.osmand.osm.LatLon; import net.osmand.osm.MapUtils; +import net.sf.junidecode.Junidecode; import com.google.protobuf.CodedOutputStream; import com.google.protobuf.WireFormat; @@ -46,8 +51,6 @@ public class BinaryMapIndexWriter { private Stack stackBaseIds = new Stack(); private Stack> stackStringTable = new Stack>(); - // needed for address index - private MapObject cityOrPostcode = null; // internal constants to track state of index writing private Stack state = new Stack(); @@ -61,6 +64,7 @@ public class BinaryMapIndexWriter { private final static int ADDRESS_INDEX_INIT = 5; private final static int CITY_INDEX_INIT = 6; private final static int POSTCODES_INDEX_INIT = 7; + private final static int VILLAGES_INDEX_INIT = 8; public BinaryMapIndexWriter(final RandomAccessFile raf) throws IOException{ this.raf = raf; @@ -91,7 +95,7 @@ public class BinaryMapIndexWriter { codedOutStream.writeFixed32NoTag(0); } - private void writeInt32Size() throws IOException{ + private int writeInt32Size() throws IOException{ codedOutStream.flush(); long filePointer = raf.getFilePointer(); Long old = stackSizes.pop(); @@ -99,6 +103,7 @@ public class BinaryMapIndexWriter { raf.seek(old); raf.writeInt(length); raf.seek(filePointer); + return length; } public void startWriteMapIndex() throws IOException{ @@ -110,7 +115,8 @@ public class BinaryMapIndexWriter { public void endWriteMapIndex() throws IOException{ popState(MAP_INDEX_INIT); - writeInt32Size(); + int len = writeInt32Size(); + System.out.println("MAP INDEX SIZE : " + len); } public void startWriteMapLevelIndex(int minZoom, int maxZoom, int leftX, int rightX, int topY, int bottomY) throws IOException{ @@ -330,7 +336,7 @@ public class BinaryMapIndexWriter { } public void startWriteAddressIndex(String name) throws IOException { - pushState(OSMAND_STRUCTURE_INIT, ADDRESS_INDEX_INIT); + pushState(ADDRESS_INDEX_INIT, OSMAND_STRUCTURE_INIT); codedOutStream.writeTag(OsmandOdb.OsmAndStructure.ADDRESSINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); preserveInt32Size(); @@ -340,45 +346,104 @@ public class BinaryMapIndexWriter { public void endWriteAddressIndex() throws IOException { popState(ADDRESS_INDEX_INIT); + int len = writeInt32Size(); + System.out.println("ADDRESS INDEX SIZE : " + len); + } + + private boolean checkEnNameToWrite(MapObject obj){ + if(obj.getEnName() == null){ + return false; + } + return !obj.getEnName().equals(Junidecode.unidecode(obj.getName())); + } + + public void writeCityIndex(City city, List streets) throws IOException { + if(city.getType() == City.CityType.CITY || city.getType() == City.CityType.TOWN){ + checkPeekState(CITY_INDEX_INIT); + } else { + checkPeekState(VILLAGES_INDEX_INIT); + } + CityIndex.Builder cityInd = OsmandOdb.CityIndex.newBuilder(); + cityInd.setCityType(city.getType().ordinal()); + cityInd.setId(city.getId()); + + cityInd.setName(city.getName()); + if(checkEnNameToWrite(city)){ + cityInd.setNameEn(city.getEnName()); + } + cityInd.setX(MapUtils.get31TileNumberX(city.getLocation().getLongitude())); + cityInd.setY(MapUtils.get31TileNumberY(city.getLocation().getLatitude())); + + for(Street s : streets){ + StreetIndex streetInd = createStreetAndBuildings(s, city.getLocation(), null); + cityInd.addStreets(streetInd); + } + codedOutStream.writeMessage(OsmandOdb.CitiesIndex.CITIES_FIELD_NUMBER, cityInd.build()); + } + + public void startCityIndexes(boolean villages) throws IOException { + pushState(villages ? VILLAGES_INDEX_INIT : CITY_INDEX_INIT, ADDRESS_INDEX_INIT); + codedOutStream.writeTag(villages ? OsmandOdb.OsmAndAddressIndex.VILLAGES_FIELD_NUMBER + : OsmandOdb.OsmAndAddressIndex.CITIES_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); + preserveInt32Size(); + } + + public void endCityIndexes(boolean villages) throws IOException { + popState(villages ? VILLAGES_INDEX_INIT : CITY_INDEX_INIT); writeInt32Size(); } - public void startWriteCityIndex(City city) throws IOException { - pushState(CITY_INDEX_INIT, ADDRESS_INDEX_INIT); - codedOutStream.writeTag(OsmandOdb.OsmAndStructure.ADDRESSINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); + public void startPostcodes() throws IOException { + pushState(POSTCODES_INDEX_INIT, ADDRESS_INDEX_INIT); + codedOutStream.writeTag(OsmandOdb.OsmAndAddressIndex.POSTCODES_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); preserveInt32Size(); - - codedOutStream.writeUInt32(OsmandOdb.CityIndex.CITY_TYPE_FIELD_NUMBER, city.getType().ordinal()); - codedOutStream.writeUInt64(OsmandOdb.CityIndex.ID_FIELD_NUMBER, city.getId()); - codedOutStream.writeString(OsmandOdb.CityIndex.NAME_FIELD_NUMBER, city.getName()); - if(city.getEnName() != null){ - codedOutStream.writeString(OsmandOdb.CityIndex.NAME_EN_FIELD_NUMBER, city.getEnName()); - } - codedOutStream.writeFixed32(OsmandOdb.CityIndex.X_FIELD_NUMBER, MapUtils.get31TileNumberX(city.getLocation().getLongitude())); - codedOutStream.writeFixed32(OsmandOdb.CityIndex.Y_FIELD_NUMBER, MapUtils.get31TileNumberY(city.getLocation().getLatitude())); - cityOrPostcode = city; } - public void writeStreetAndBuildings(Street street) throws IOException { + public void endPostcodes() throws IOException { + popState(POSTCODES_INDEX_INIT); + writeInt32Size(); + } + + + + public void writePostcode(String postcode, List streets) throws IOException { + checkPeekState(POSTCODES_INDEX_INIT); + LatLon loc = streets.get(0).getLocation(); + PostcodeIndex.Builder post = OsmandOdb.PostcodeIndex.newBuilder(); + post.setPostcode(postcode); + + + for(Street s : streets){ + StreetIndex streetInd = createStreetAndBuildings(s, loc, postcode); + post.addStreets(streetInd); + } + codedOutStream.writeMessage(OsmandOdb.PostcodesIndex.POSTCODES_FIELD_NUMBER, post.build()); + } + + + protected StreetIndex createStreetAndBuildings(Street street, LatLon l, String postcodeFilter) throws IOException { checkPeekState(CITY_INDEX_INIT, POSTCODES_INDEX_INIT); + boolean inCity = state.peek() == CITY_INDEX_INIT; StreetIndex.Builder streetBuilder = OsmandOdb.StreetIndex.newBuilder(); streetBuilder.setName(street.getName()); - if(street.getEnName() != null){ + if(checkEnNameToWrite(street)){ streetBuilder.setNameEn(street.getEnName()); } streetBuilder.setId(street.getId()); - LatLon location = cityOrPostcode.getLocation(); - int cx = MapUtils.get31TileNumberX(location.getLongitude()); - int cy = MapUtils.get31TileNumberY(location.getLatitude()); + int cx = MapUtils.get31TileNumberX(l.getLongitude()); + int cy = MapUtils.get31TileNumberY(l.getLatitude()); int sx = MapUtils.get31TileNumberX(street.getLocation().getLongitude()); int sy = MapUtils.get31TileNumberY(street.getLocation().getLatitude()); streetBuilder.setX((sx - cx) >> 7); streetBuilder.setY((sy - cy) >> 7); for(Building b : street.getBuildings()){ + if(postcodeFilter != null && !postcodeFilter.equalsIgnoreCase(b.getPostcode())){ + continue; + } OsmandOdb.BuildingIndex.Builder bbuilder= OsmandOdb.BuildingIndex.newBuilder(); int bx = MapUtils.get31TileNumberX(b.getLocation().getLongitude()); int by = MapUtils.get31TileNumberY(b.getLocation().getLatitude()); @@ -386,28 +451,18 @@ public class BinaryMapIndexWriter { bbuilder.setY((by - sy) >> 7); bbuilder.setId(b.getId()); bbuilder.setName(b.getName()); - if(b.getEnName() != null){ + if(checkEnNameToWrite(b)){ bbuilder.setNameEn(b.getEnName()); } + if(inCity && b.getPostcode() != null){ + bbuilder.setPostcode(b.getPostcode()); + } streetBuilder.addBuildings(bbuilder.build()); } - - if(state.peek() == CITY_INDEX_INIT){ - codedOutStream.writeMessage(OsmandOdb.CityIndex.STREETS_FIELD_NUMBER, streetBuilder.build()); - } else { - throw new UnsupportedOperationException(); - } - - - + return streetBuilder.build(); } - public void endWriteCityIndex() throws IOException { - popState(CITY_INDEX_INIT); - writeInt32Size(); - cityOrPostcode = null; - } private void pushState(int push, int peek){ if(state.peek() != peek){ diff --git a/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java b/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java index 19275af1fe..a33ecb2602 100644 --- a/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java +++ b/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java @@ -2920,54 +2920,42 @@ public final class OsmandOdb { public boolean hasNameEn() { return hasNameEn; } public java.lang.String getNameEn() { return nameEn_; } - // repeated .CityIndex cityIndex = 5; - public static final int CITYINDEX_FIELD_NUMBER = 5; - private java.util.List cityIndex_ = - java.util.Collections.emptyList(); - public java.util.List getCityIndexList() { - return cityIndex_; - } - public int getCityIndexCount() { return cityIndex_.size(); } - public net.osmand.binary.OsmandOdb.CityIndex getCityIndex(int index) { - return cityIndex_.get(index); - } + // optional .CitiesIndex cities = 5; + public static final int CITIES_FIELD_NUMBER = 5; + private boolean hasCities; + private net.osmand.binary.OsmandOdb.CitiesIndex cities_; + public boolean hasCities() { return hasCities; } + public net.osmand.binary.OsmandOdb.CitiesIndex getCities() { return cities_; } - // repeated .PostcodeIndex postcodes = 6; + // optional .PostcodesIndex postcodes = 6; public static final int POSTCODES_FIELD_NUMBER = 6; - private java.util.List postcodes_ = - java.util.Collections.emptyList(); - public java.util.List getPostcodesList() { - return postcodes_; - } - public int getPostcodesCount() { return postcodes_.size(); } - public net.osmand.binary.OsmandOdb.PostcodeIndex getPostcodes(int index) { - return postcodes_.get(index); - } + private boolean hasPostcodes; + private net.osmand.binary.OsmandOdb.PostcodesIndex postcodes_; + public boolean hasPostcodes() { return hasPostcodes; } + public net.osmand.binary.OsmandOdb.PostcodesIndex getPostcodes() { return postcodes_; } - // repeated .CityIndex villages = 7; + // optional .CitiesIndex villages = 7; public static final int VILLAGES_FIELD_NUMBER = 7; - private java.util.List villages_ = - java.util.Collections.emptyList(); - public java.util.List getVillagesList() { - return villages_; - } - public int getVillagesCount() { return villages_.size(); } - public net.osmand.binary.OsmandOdb.CityIndex getVillages(int index) { - return villages_.get(index); - } + private boolean hasVillages; + private net.osmand.binary.OsmandOdb.CitiesIndex villages_; + public boolean hasVillages() { return hasVillages; } + public net.osmand.binary.OsmandOdb.CitiesIndex getVillages() { return villages_; } private void initFields() { + cities_ = net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance(); + postcodes_ = net.osmand.binary.OsmandOdb.PostcodesIndex.getDefaultInstance(); + villages_ = net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance(); } public final boolean isInitialized() { if (!hasName) return false; - for (net.osmand.binary.OsmandOdb.CityIndex element : getCityIndexList()) { - if (!element.isInitialized()) return false; + if (hasCities()) { + if (!getCities().isInitialized()) return false; } - for (net.osmand.binary.OsmandOdb.PostcodeIndex element : getPostcodesList()) { - if (!element.isInitialized()) return false; + if (hasPostcodes()) { + if (!getPostcodes().isInitialized()) return false; } - for (net.osmand.binary.OsmandOdb.CityIndex element : getVillagesList()) { - if (!element.isInitialized()) return false; + if (hasVillages()) { + if (!getVillages().isInitialized()) return false; } return true; } @@ -2981,14 +2969,14 @@ public final class OsmandOdb { if (hasNameEn()) { output.writeString(2, getNameEn()); } - for (net.osmand.binary.OsmandOdb.CityIndex element : getCityIndexList()) { - output.writeMessage(5, element); + if (hasCities()) { + output.writeMessage(5, getCities()); } - for (net.osmand.binary.OsmandOdb.PostcodeIndex element : getPostcodesList()) { - output.writeMessage(6, element); + if (hasPostcodes()) { + output.writeMessage(6, getPostcodes()); } - for (net.osmand.binary.OsmandOdb.CityIndex element : getVillagesList()) { - output.writeMessage(7, element); + if (hasVillages()) { + output.writeMessage(7, getVillages()); } getUnknownFields().writeTo(output); } @@ -3007,17 +2995,17 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeStringSize(2, getNameEn()); } - for (net.osmand.binary.OsmandOdb.CityIndex element : getCityIndexList()) { + if (hasCities()) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, element); + .computeMessageSize(5, getCities()); } - for (net.osmand.binary.OsmandOdb.PostcodeIndex element : getPostcodesList()) { + if (hasPostcodes()) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(6, element); + .computeMessageSize(6, getPostcodes()); } - for (net.osmand.binary.OsmandOdb.CityIndex element : getVillagesList()) { + if (hasVillages()) { size += com.google.protobuf.CodedOutputStream - .computeMessageSize(7, element); + .computeMessageSize(7, getVillages()); } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; @@ -3161,18 +3149,6 @@ public final class OsmandOdb { throw new IllegalStateException( "build() has already been called on this Builder."); } - if (result.cityIndex_ != java.util.Collections.EMPTY_LIST) { - result.cityIndex_ = - java.util.Collections.unmodifiableList(result.cityIndex_); - } - if (result.postcodes_ != java.util.Collections.EMPTY_LIST) { - result.postcodes_ = - java.util.Collections.unmodifiableList(result.postcodes_); - } - if (result.villages_ != java.util.Collections.EMPTY_LIST) { - result.villages_ = - java.util.Collections.unmodifiableList(result.villages_); - } net.osmand.binary.OsmandOdb.OsmAndAddressIndex returnMe = result; result = null; return returnMe; @@ -3195,23 +3171,14 @@ public final class OsmandOdb { if (other.hasNameEn()) { setNameEn(other.getNameEn()); } - if (!other.cityIndex_.isEmpty()) { - if (result.cityIndex_.isEmpty()) { - result.cityIndex_ = new java.util.ArrayList(); - } - result.cityIndex_.addAll(other.cityIndex_); + if (other.hasCities()) { + mergeCities(other.getCities()); } - if (!other.postcodes_.isEmpty()) { - if (result.postcodes_.isEmpty()) { - result.postcodes_ = new java.util.ArrayList(); - } - result.postcodes_.addAll(other.postcodes_); + if (other.hasPostcodes()) { + mergePostcodes(other.getPostcodes()); } - if (!other.villages_.isEmpty()) { - if (result.villages_.isEmpty()) { - result.villages_ = new java.util.ArrayList(); - } - result.villages_.addAll(other.villages_); + if (other.hasVillages()) { + mergeVillages(other.getVillages()); } this.mergeUnknownFields(other.getUnknownFields()); return this; @@ -3247,21 +3214,30 @@ public final class OsmandOdb { break; } case 42: { - net.osmand.binary.OsmandOdb.CityIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.CityIndex.newBuilder(); + net.osmand.binary.OsmandOdb.CitiesIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.CitiesIndex.newBuilder(); + if (hasCities()) { + subBuilder.mergeFrom(getCities()); + } input.readMessage(subBuilder, extensionRegistry); - addCityIndex(subBuilder.buildPartial()); + setCities(subBuilder.buildPartial()); break; } case 50: { - net.osmand.binary.OsmandOdb.PostcodeIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.PostcodeIndex.newBuilder(); + net.osmand.binary.OsmandOdb.PostcodesIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.PostcodesIndex.newBuilder(); + if (hasPostcodes()) { + subBuilder.mergeFrom(getPostcodes()); + } input.readMessage(subBuilder, extensionRegistry); - addPostcodes(subBuilder.buildPartial()); + setPostcodes(subBuilder.buildPartial()); break; } case 58: { - net.osmand.binary.OsmandOdb.CityIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.CityIndex.newBuilder(); + net.osmand.binary.OsmandOdb.CitiesIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.CitiesIndex.newBuilder(); + if (hasVillages()) { + subBuilder.mergeFrom(getVillages()); + } input.readMessage(subBuilder, extensionRegistry); - addVillages(subBuilder.buildPartial()); + setVillages(subBuilder.buildPartial()); break; } } @@ -3311,58 +3287,735 @@ public final class OsmandOdb { return this; } - // repeated .CityIndex cityIndex = 5; - public java.util.List getCityIndexList() { - return java.util.Collections.unmodifiableList(result.cityIndex_); + // optional .CitiesIndex cities = 5; + public boolean hasCities() { + return result.hasCities(); } - public int getCityIndexCount() { - return result.getCityIndexCount(); + public net.osmand.binary.OsmandOdb.CitiesIndex getCities() { + return result.getCities(); } - public net.osmand.binary.OsmandOdb.CityIndex getCityIndex(int index) { - return result.getCityIndex(index); - } - public Builder setCityIndex(int index, net.osmand.binary.OsmandOdb.CityIndex value) { + public Builder setCities(net.osmand.binary.OsmandOdb.CitiesIndex value) { if (value == null) { throw new NullPointerException(); } - result.cityIndex_.set(index, value); + result.hasCities = true; + result.cities_ = value; return this; } - public Builder setCityIndex(int index, net.osmand.binary.OsmandOdb.CityIndex.Builder builderForValue) { - result.cityIndex_.set(index, builderForValue.build()); + public Builder setCities(net.osmand.binary.OsmandOdb.CitiesIndex.Builder builderForValue) { + result.hasCities = true; + result.cities_ = builderForValue.build(); return this; } - public Builder addCityIndex(net.osmand.binary.OsmandOdb.CityIndex value) { - if (value == null) { - throw new NullPointerException(); + public Builder mergeCities(net.osmand.binary.OsmandOdb.CitiesIndex value) { + if (result.hasCities() && + result.cities_ != net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance()) { + result.cities_ = + net.osmand.binary.OsmandOdb.CitiesIndex.newBuilder(result.cities_).mergeFrom(value).buildPartial(); + } else { + result.cities_ = value; } - if (result.cityIndex_.isEmpty()) { - result.cityIndex_ = new java.util.ArrayList(); - } - result.cityIndex_.add(value); + result.hasCities = true; return this; } - public Builder addCityIndex(net.osmand.binary.OsmandOdb.CityIndex.Builder builderForValue) { - if (result.cityIndex_.isEmpty()) { - result.cityIndex_ = new java.util.ArrayList(); - } - result.cityIndex_.add(builderForValue.build()); - return this; - } - public Builder addAllCityIndex( - java.lang.Iterable values) { - if (result.cityIndex_.isEmpty()) { - result.cityIndex_ = new java.util.ArrayList(); - } - super.addAll(values, result.cityIndex_); - return this; - } - public Builder clearCityIndex() { - result.cityIndex_ = java.util.Collections.emptyList(); + public Builder clearCities() { + result.hasCities = false; + result.cities_ = net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance(); return this; } - // repeated .PostcodeIndex postcodes = 6; + // optional .PostcodesIndex postcodes = 6; + public boolean hasPostcodes() { + return result.hasPostcodes(); + } + public net.osmand.binary.OsmandOdb.PostcodesIndex getPostcodes() { + return result.getPostcodes(); + } + public Builder setPostcodes(net.osmand.binary.OsmandOdb.PostcodesIndex value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasPostcodes = true; + result.postcodes_ = value; + return this; + } + public Builder setPostcodes(net.osmand.binary.OsmandOdb.PostcodesIndex.Builder builderForValue) { + result.hasPostcodes = true; + result.postcodes_ = builderForValue.build(); + return this; + } + public Builder mergePostcodes(net.osmand.binary.OsmandOdb.PostcodesIndex value) { + if (result.hasPostcodes() && + result.postcodes_ != net.osmand.binary.OsmandOdb.PostcodesIndex.getDefaultInstance()) { + result.postcodes_ = + net.osmand.binary.OsmandOdb.PostcodesIndex.newBuilder(result.postcodes_).mergeFrom(value).buildPartial(); + } else { + result.postcodes_ = value; + } + result.hasPostcodes = true; + return this; + } + public Builder clearPostcodes() { + result.hasPostcodes = false; + result.postcodes_ = net.osmand.binary.OsmandOdb.PostcodesIndex.getDefaultInstance(); + return this; + } + + // optional .CitiesIndex villages = 7; + public boolean hasVillages() { + return result.hasVillages(); + } + public net.osmand.binary.OsmandOdb.CitiesIndex getVillages() { + return result.getVillages(); + } + public Builder setVillages(net.osmand.binary.OsmandOdb.CitiesIndex value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasVillages = true; + result.villages_ = value; + return this; + } + public Builder setVillages(net.osmand.binary.OsmandOdb.CitiesIndex.Builder builderForValue) { + result.hasVillages = true; + result.villages_ = builderForValue.build(); + return this; + } + public Builder mergeVillages(net.osmand.binary.OsmandOdb.CitiesIndex value) { + if (result.hasVillages() && + result.villages_ != net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance()) { + result.villages_ = + net.osmand.binary.OsmandOdb.CitiesIndex.newBuilder(result.villages_).mergeFrom(value).buildPartial(); + } else { + result.villages_ = value; + } + result.hasVillages = true; + return this; + } + public Builder clearVillages() { + result.hasVillages = false; + result.villages_ = net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance(); + return this; + } + + // @@protoc_insertion_point(builder_scope:OsmAndAddressIndex) + } + + static { + defaultInstance = new OsmAndAddressIndex(true); + net.osmand.binary.OsmandOdb.internalForceInit(); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:OsmAndAddressIndex) + } + + public static final class CitiesIndex extends + com.google.protobuf.GeneratedMessage { + // Use CitiesIndex.newBuilder() to construct. + private CitiesIndex() { + initFields(); + } + private CitiesIndex(boolean noInit) {} + + private static final CitiesIndex defaultInstance; + public static CitiesIndex getDefaultInstance() { + return defaultInstance; + } + + public CitiesIndex getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return net.osmand.binary.OsmandOdb.internal_static_CitiesIndex_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return net.osmand.binary.OsmandOdb.internal_static_CitiesIndex_fieldAccessorTable; + } + + // repeated .CityIndex cities = 1; + public static final int CITIES_FIELD_NUMBER = 1; + private java.util.List cities_ = + java.util.Collections.emptyList(); + public java.util.List getCitiesList() { + return cities_; + } + public int getCitiesCount() { return cities_.size(); } + public net.osmand.binary.OsmandOdb.CityIndex getCities(int index) { + return cities_.get(index); + } + + private void initFields() { + } + public final boolean isInitialized() { + for (net.osmand.binary.OsmandOdb.CityIndex element : getCitiesList()) { + if (!element.isInitialized()) return false; + } + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (net.osmand.binary.OsmandOdb.CityIndex element : getCitiesList()) { + output.writeMessage(1, element); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (net.osmand.binary.OsmandOdb.CityIndex element : getCitiesList()) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, element); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.CitiesIndex parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(net.osmand.binary.OsmandOdb.CitiesIndex prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder { + private net.osmand.binary.OsmandOdb.CitiesIndex result; + + // Construct using net.osmand.binary.OsmandOdb.CitiesIndex.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new net.osmand.binary.OsmandOdb.CitiesIndex(); + return builder; + } + + protected net.osmand.binary.OsmandOdb.CitiesIndex internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new net.osmand.binary.OsmandOdb.CitiesIndex(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return net.osmand.binary.OsmandOdb.CitiesIndex.getDescriptor(); + } + + public net.osmand.binary.OsmandOdb.CitiesIndex getDefaultInstanceForType() { + return net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public net.osmand.binary.OsmandOdb.CitiesIndex build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private net.osmand.binary.OsmandOdb.CitiesIndex buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public net.osmand.binary.OsmandOdb.CitiesIndex buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + if (result.cities_ != java.util.Collections.EMPTY_LIST) { + result.cities_ = + java.util.Collections.unmodifiableList(result.cities_); + } + net.osmand.binary.OsmandOdb.CitiesIndex returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof net.osmand.binary.OsmandOdb.CitiesIndex) { + return mergeFrom((net.osmand.binary.OsmandOdb.CitiesIndex)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(net.osmand.binary.OsmandOdb.CitiesIndex other) { + if (other == net.osmand.binary.OsmandOdb.CitiesIndex.getDefaultInstance()) return this; + if (!other.cities_.isEmpty()) { + if (result.cities_.isEmpty()) { + result.cities_ = new java.util.ArrayList(); + } + result.cities_.addAll(other.cities_); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder( + this.getUnknownFields()); + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + this.setUnknownFields(unknownFields.build()); + return this; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + this.setUnknownFields(unknownFields.build()); + return this; + } + break; + } + case 10: { + net.osmand.binary.OsmandOdb.CityIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.CityIndex.newBuilder(); + input.readMessage(subBuilder, extensionRegistry); + addCities(subBuilder.buildPartial()); + break; + } + } + } + } + + + // repeated .CityIndex cities = 1; + public java.util.List getCitiesList() { + return java.util.Collections.unmodifiableList(result.cities_); + } + public int getCitiesCount() { + return result.getCitiesCount(); + } + public net.osmand.binary.OsmandOdb.CityIndex getCities(int index) { + return result.getCities(index); + } + public Builder setCities(int index, net.osmand.binary.OsmandOdb.CityIndex value) { + if (value == null) { + throw new NullPointerException(); + } + result.cities_.set(index, value); + return this; + } + public Builder setCities(int index, net.osmand.binary.OsmandOdb.CityIndex.Builder builderForValue) { + result.cities_.set(index, builderForValue.build()); + return this; + } + public Builder addCities(net.osmand.binary.OsmandOdb.CityIndex value) { + if (value == null) { + throw new NullPointerException(); + } + if (result.cities_.isEmpty()) { + result.cities_ = new java.util.ArrayList(); + } + result.cities_.add(value); + return this; + } + public Builder addCities(net.osmand.binary.OsmandOdb.CityIndex.Builder builderForValue) { + if (result.cities_.isEmpty()) { + result.cities_ = new java.util.ArrayList(); + } + result.cities_.add(builderForValue.build()); + return this; + } + public Builder addAllCities( + java.lang.Iterable values) { + if (result.cities_.isEmpty()) { + result.cities_ = new java.util.ArrayList(); + } + super.addAll(values, result.cities_); + return this; + } + public Builder clearCities() { + result.cities_ = java.util.Collections.emptyList(); + return this; + } + + // @@protoc_insertion_point(builder_scope:CitiesIndex) + } + + static { + defaultInstance = new CitiesIndex(true); + net.osmand.binary.OsmandOdb.internalForceInit(); + defaultInstance.initFields(); + } + + // @@protoc_insertion_point(class_scope:CitiesIndex) + } + + public static final class PostcodesIndex extends + com.google.protobuf.GeneratedMessage { + // Use PostcodesIndex.newBuilder() to construct. + private PostcodesIndex() { + initFields(); + } + private PostcodesIndex(boolean noInit) {} + + private static final PostcodesIndex defaultInstance; + public static PostcodesIndex getDefaultInstance() { + return defaultInstance; + } + + public PostcodesIndex getDefaultInstanceForType() { + return defaultInstance; + } + + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return net.osmand.binary.OsmandOdb.internal_static_PostcodesIndex_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return net.osmand.binary.OsmandOdb.internal_static_PostcodesIndex_fieldAccessorTable; + } + + // repeated .PostcodeIndex postcodes = 1; + public static final int POSTCODES_FIELD_NUMBER = 1; + private java.util.List postcodes_ = + java.util.Collections.emptyList(); + public java.util.List getPostcodesList() { + return postcodes_; + } + public int getPostcodesCount() { return postcodes_.size(); } + public net.osmand.binary.OsmandOdb.PostcodeIndex getPostcodes(int index) { + return postcodes_.get(index); + } + + private void initFields() { + } + public final boolean isInitialized() { + for (net.osmand.binary.OsmandOdb.PostcodeIndex element : getPostcodesList()) { + if (!element.isInitialized()) return false; + } + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + for (net.osmand.binary.OsmandOdb.PostcodeIndex element : getPostcodesList()) { + output.writeMessage(1, element); + } + getUnknownFields().writeTo(output); + } + + private int memoizedSerializedSize = -1; + public int getSerializedSize() { + int size = memoizedSerializedSize; + if (size != -1) return size; + + size = 0; + for (net.osmand.binary.OsmandOdb.PostcodeIndex element : getPostcodesList()) { + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, element); + } + size += getUnknownFields().getSerializedSize(); + memoizedSerializedSize = size; + return size; + } + + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return newBuilder().mergeFrom(data, extensionRegistry) + .buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom(java.io.InputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + Builder builder = newBuilder(); + if (builder.mergeDelimitedFrom(input, extensionRegistry)) { + return builder.buildParsed(); + } else { + return null; + } + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return newBuilder().mergeFrom(input).buildParsed(); + } + public static net.osmand.binary.OsmandOdb.PostcodesIndex parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return newBuilder().mergeFrom(input, extensionRegistry) + .buildParsed(); + } + + public static Builder newBuilder() { return Builder.create(); } + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder(net.osmand.binary.OsmandOdb.PostcodesIndex prototype) { + return newBuilder().mergeFrom(prototype); + } + public Builder toBuilder() { return newBuilder(this); } + + public static final class Builder extends + com.google.protobuf.GeneratedMessage.Builder { + private net.osmand.binary.OsmandOdb.PostcodesIndex result; + + // Construct using net.osmand.binary.OsmandOdb.PostcodesIndex.newBuilder() + private Builder() {} + + private static Builder create() { + Builder builder = new Builder(); + builder.result = new net.osmand.binary.OsmandOdb.PostcodesIndex(); + return builder; + } + + protected net.osmand.binary.OsmandOdb.PostcodesIndex internalGetResult() { + return result; + } + + public Builder clear() { + if (result == null) { + throw new IllegalStateException( + "Cannot call clear() after build()."); + } + result = new net.osmand.binary.OsmandOdb.PostcodesIndex(); + return this; + } + + public Builder clone() { + return create().mergeFrom(result); + } + + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return net.osmand.binary.OsmandOdb.PostcodesIndex.getDescriptor(); + } + + public net.osmand.binary.OsmandOdb.PostcodesIndex getDefaultInstanceForType() { + return net.osmand.binary.OsmandOdb.PostcodesIndex.getDefaultInstance(); + } + + public boolean isInitialized() { + return result.isInitialized(); + } + public net.osmand.binary.OsmandOdb.PostcodesIndex build() { + if (result != null && !isInitialized()) { + throw newUninitializedMessageException(result); + } + return buildPartial(); + } + + private net.osmand.binary.OsmandOdb.PostcodesIndex buildParsed() + throws com.google.protobuf.InvalidProtocolBufferException { + if (!isInitialized()) { + throw newUninitializedMessageException( + result).asInvalidProtocolBufferException(); + } + return buildPartial(); + } + + public net.osmand.binary.OsmandOdb.PostcodesIndex buildPartial() { + if (result == null) { + throw new IllegalStateException( + "build() has already been called on this Builder."); + } + if (result.postcodes_ != java.util.Collections.EMPTY_LIST) { + result.postcodes_ = + java.util.Collections.unmodifiableList(result.postcodes_); + } + net.osmand.binary.OsmandOdb.PostcodesIndex returnMe = result; + result = null; + return returnMe; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof net.osmand.binary.OsmandOdb.PostcodesIndex) { + return mergeFrom((net.osmand.binary.OsmandOdb.PostcodesIndex)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(net.osmand.binary.OsmandOdb.PostcodesIndex other) { + if (other == net.osmand.binary.OsmandOdb.PostcodesIndex.getDefaultInstance()) return this; + if (!other.postcodes_.isEmpty()) { + if (result.postcodes_.isEmpty()) { + result.postcodes_ = new java.util.ArrayList(); + } + result.postcodes_.addAll(other.postcodes_); + } + this.mergeUnknownFields(other.getUnknownFields()); + return this; + } + + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder( + this.getUnknownFields()); + while (true) { + int tag = input.readTag(); + switch (tag) { + case 0: + this.setUnknownFields(unknownFields.build()); + return this; + default: { + if (!parseUnknownField(input, unknownFields, + extensionRegistry, tag)) { + this.setUnknownFields(unknownFields.build()); + return this; + } + break; + } + case 10: { + net.osmand.binary.OsmandOdb.PostcodeIndex.Builder subBuilder = net.osmand.binary.OsmandOdb.PostcodeIndex.newBuilder(); + input.readMessage(subBuilder, extensionRegistry); + addPostcodes(subBuilder.buildPartial()); + break; + } + } + } + } + + + // repeated .PostcodeIndex postcodes = 1; public java.util.List getPostcodesList() { return java.util.Collections.unmodifiableList(result.postcodes_); } @@ -3413,67 +4066,16 @@ public final class OsmandOdb { return this; } - // repeated .CityIndex villages = 7; - public java.util.List getVillagesList() { - return java.util.Collections.unmodifiableList(result.villages_); - } - public int getVillagesCount() { - return result.getVillagesCount(); - } - public net.osmand.binary.OsmandOdb.CityIndex getVillages(int index) { - return result.getVillages(index); - } - public Builder setVillages(int index, net.osmand.binary.OsmandOdb.CityIndex value) { - if (value == null) { - throw new NullPointerException(); - } - result.villages_.set(index, value); - return this; - } - public Builder setVillages(int index, net.osmand.binary.OsmandOdb.CityIndex.Builder builderForValue) { - result.villages_.set(index, builderForValue.build()); - return this; - } - public Builder addVillages(net.osmand.binary.OsmandOdb.CityIndex value) { - if (value == null) { - throw new NullPointerException(); - } - if (result.villages_.isEmpty()) { - result.villages_ = new java.util.ArrayList(); - } - result.villages_.add(value); - return this; - } - public Builder addVillages(net.osmand.binary.OsmandOdb.CityIndex.Builder builderForValue) { - if (result.villages_.isEmpty()) { - result.villages_ = new java.util.ArrayList(); - } - result.villages_.add(builderForValue.build()); - return this; - } - public Builder addAllVillages( - java.lang.Iterable values) { - if (result.villages_.isEmpty()) { - result.villages_ = new java.util.ArrayList(); - } - super.addAll(values, result.villages_); - return this; - } - public Builder clearVillages() { - result.villages_ = java.util.Collections.emptyList(); - return this; - } - - // @@protoc_insertion_point(builder_scope:OsmAndAddressIndex) + // @@protoc_insertion_point(builder_scope:PostcodesIndex) } static { - defaultInstance = new OsmAndAddressIndex(true); + defaultInstance = new PostcodesIndex(true); net.osmand.binary.OsmandOdb.internalForceInit(); defaultInstance.initFields(); } - // @@protoc_insertion_point(class_scope:OsmAndAddressIndex) + // @@protoc_insertion_point(class_scope:PostcodesIndex) } public static final class CityIndex extends @@ -5017,6 +5619,13 @@ public final class OsmandOdb { public boolean hasId() { return hasId; } public long getId() { return id_; } + // optional string postcode = 6; + public static final int POSTCODE_FIELD_NUMBER = 6; + private boolean hasPostcode; + private java.lang.String postcode_ = ""; + public boolean hasPostcode() { return hasPostcode; } + public java.lang.String getPostcode() { return postcode_; } + // required sint32 x = 3; public static final int X_FIELD_NUMBER = 3; private boolean hasX; @@ -5058,6 +5667,9 @@ public final class OsmandOdb { if (hasId()) { output.writeUInt64(5, getId()); } + if (hasPostcode()) { + output.writeString(6, getPostcode()); + } getUnknownFields().writeTo(output); } @@ -5087,6 +5699,10 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeUInt64Size(5, getId()); } + if (hasPostcode()) { + size += com.google.protobuf.CodedOutputStream + .computeStringSize(6, getPostcode()); + } size += getUnknownFields().getSerializedSize(); memoizedSerializedSize = size; return size; @@ -5254,6 +5870,9 @@ public final class OsmandOdb { if (other.hasId()) { setId(other.getId()); } + if (other.hasPostcode()) { + setPostcode(other.getPostcode()); + } if (other.hasX()) { setX(other.getX()); } @@ -5305,6 +5924,10 @@ public final class OsmandOdb { setId(input.readUInt64()); break; } + case 50: { + setPostcode(input.readString()); + break; + } } } } @@ -5370,6 +5993,27 @@ public final class OsmandOdb { return this; } + // optional string postcode = 6; + public boolean hasPostcode() { + return result.hasPostcode(); + } + public java.lang.String getPostcode() { + return result.getPostcode(); + } + public Builder setPostcode(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasPostcode = true; + result.postcode_ = value; + return this; + } + public Builder clearPostcode() { + result.hasPostcode = false; + result.postcode_ = getDefaultInstance().getPostcode(); + return this; + } + // required sint32 x = 3; public boolean hasX() { return result.hasX(); @@ -5453,6 +6097,16 @@ public final class OsmandOdb { private static com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_OsmAndAddressIndex_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_CitiesIndex_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_CitiesIndex_fieldAccessorTable; + private static com.google.protobuf.Descriptors.Descriptor + internal_static_PostcodesIndex_descriptor; + private static + com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_PostcodesIndex_fieldAccessorTable; private static com.google.protobuf.Descriptors.Descriptor internal_static_CityIndex_descriptor; private static @@ -5497,21 +6151,24 @@ public final class OsmandOdb { "(\0132\010.MapData\"\030\n\013StringTable\022\t\n\001s\030\001 \003(\t\"v" + "\n\007MapData\022\023\n\013coordinates\030\001 \002(\014\022\r\n\005types\030" + "\002 \002(\014\022\n\n\002id\030\003 \002(\022\022\020\n\010stringId\030\004 \001(\r\022\024\n\014r" + - "estrictions\030\005 \001(\014\022\023\n\013highwayMeta\030\006 \001(\005\"\223" + + "estrictions\030\005 \001(\014\022\023\n\013highwayMeta\030\006 \001(\005\"\225" + "\001\n\022OsmAndAddressIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007n" + - "ame_en\030\002 \001(\t\022\035\n\tcityIndex\030\005 \003(\0132\n.CityIn" + - "dex\022!\n\tpostcodes\030\006 \003(\0132\016.PostcodeIndex\022\034" + - "\n\010villages\030\007 \003(\0132\n.CityIndex\"~\n\tCityInde", - "x\022\021\n\tcity_type\030\001 \002(\r\022\014\n\004name\030\002 \002(\t\022\017\n\007na" + - "me_en\030\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001x\030\005 \002(\007\022\t\n\001y\030" + - "\006 \002(\007\022\035\n\007streets\030\007 \003(\0132\014.StreetIndex\"@\n\r" + - "PostcodeIndex\022\020\n\010postcode\030\001 \002(\t\022\035\n\007stree" + - "ts\030\005 \003(\0132\014.StreetIndex\"q\n\013StreetIndex\022\014\n" + - "\004name\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\n\n\002id\030\006 \001(\004" + - "\022\t\n\001x\030\003 \002(\021\022\t\n\001y\030\004 \002(\021\022!\n\tbuildings\030\005 \003(" + - "\0132\016.BuildingIndex\"P\n\rBuildingIndex\022\014\n\004na" + - "me\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\n\n\002id\030\005 \001(\004\022\t\n" + - "\001x\030\003 \002(\021\022\t\n\001y\030\004 \002(\021B\023\n\021net.osmand.binary" + "ame_en\030\002 \001(\t\022\034\n\006cities\030\005 \001(\0132\014.CitiesInd" + + "ex\022\"\n\tpostcodes\030\006 \001(\0132\017.PostcodesIndex\022\036" + + "\n\010villages\030\007 \001(\0132\014.CitiesIndex\")\n\013Cities", + "Index\022\032\n\006cities\030\001 \003(\0132\n.CityIndex\"3\n\016Pos" + + "tcodesIndex\022!\n\tpostcodes\030\001 \003(\0132\016.Postcod" + + "eIndex\"~\n\tCityIndex\022\021\n\tcity_type\030\001 \002(\r\022\014" + + "\n\004name\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\n\n\002id\030\004 \001(" + + "\004\022\t\n\001x\030\005 \002(\007\022\t\n\001y\030\006 \002(\007\022\035\n\007streets\030\007 \003(\013" + + "2\014.StreetIndex\"@\n\rPostcodeIndex\022\020\n\010postc" + + "ode\030\001 \002(\t\022\035\n\007streets\030\005 \003(\0132\014.StreetIndex" + + "\"q\n\013StreetIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en" + + "\030\002 \001(\t\022\n\n\002id\030\006 \001(\004\022\t\n\001x\030\003 \002(\021\022\t\n\001y\030\004 \002(\021" + + "\022!\n\tbuildings\030\005 \003(\0132\016.BuildingIndex\"b\n\rB", + "uildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 " + + "\001(\t\022\n\n\002id\030\005 \001(\004\022\020\n\010postcode\030\006 \001(\t\022\t\n\001x\030\003" + + " \002(\021\022\t\n\001y\030\004 \002(\021B\023\n\021net.osmand.binary" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -5571,11 +6228,27 @@ public final class OsmandOdb { internal_static_OsmAndAddressIndex_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_OsmAndAddressIndex_descriptor, - new java.lang.String[] { "Name", "NameEn", "CityIndex", "Postcodes", "Villages", }, + new java.lang.String[] { "Name", "NameEn", "Cities", "Postcodes", "Villages", }, net.osmand.binary.OsmandOdb.OsmAndAddressIndex.class, net.osmand.binary.OsmandOdb.OsmAndAddressIndex.Builder.class); - internal_static_CityIndex_descriptor = + internal_static_CitiesIndex_descriptor = getDescriptor().getMessageTypes().get(7); + internal_static_CitiesIndex_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_CitiesIndex_descriptor, + new java.lang.String[] { "Cities", }, + net.osmand.binary.OsmandOdb.CitiesIndex.class, + net.osmand.binary.OsmandOdb.CitiesIndex.Builder.class); + internal_static_PostcodesIndex_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_PostcodesIndex_fieldAccessorTable = new + com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_PostcodesIndex_descriptor, + new java.lang.String[] { "Postcodes", }, + net.osmand.binary.OsmandOdb.PostcodesIndex.class, + net.osmand.binary.OsmandOdb.PostcodesIndex.Builder.class); + internal_static_CityIndex_descriptor = + getDescriptor().getMessageTypes().get(9); internal_static_CityIndex_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_CityIndex_descriptor, @@ -5583,7 +6256,7 @@ public final class OsmandOdb { net.osmand.binary.OsmandOdb.CityIndex.class, net.osmand.binary.OsmandOdb.CityIndex.Builder.class); internal_static_PostcodeIndex_descriptor = - getDescriptor().getMessageTypes().get(8); + getDescriptor().getMessageTypes().get(10); internal_static_PostcodeIndex_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_PostcodeIndex_descriptor, @@ -5591,7 +6264,7 @@ public final class OsmandOdb { net.osmand.binary.OsmandOdb.PostcodeIndex.class, net.osmand.binary.OsmandOdb.PostcodeIndex.Builder.class); internal_static_StreetIndex_descriptor = - getDescriptor().getMessageTypes().get(9); + getDescriptor().getMessageTypes().get(11); internal_static_StreetIndex_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_StreetIndex_descriptor, @@ -5599,11 +6272,11 @@ public final class OsmandOdb { net.osmand.binary.OsmandOdb.StreetIndex.class, net.osmand.binary.OsmandOdb.StreetIndex.Builder.class); internal_static_BuildingIndex_descriptor = - getDescriptor().getMessageTypes().get(10); + getDescriptor().getMessageTypes().get(12); internal_static_BuildingIndex_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_BuildingIndex_descriptor, - new java.lang.String[] { "Name", "NameEn", "Id", "X", "Y", }, + new java.lang.String[] { "Name", "NameEn", "Id", "Postcode", "X", "Y", }, net.osmand.binary.OsmandOdb.BuildingIndex.class, net.osmand.binary.OsmandOdb.BuildingIndex.Builder.class); return null; diff --git a/DataExtractionOSM/src/net/osmand/data/index/DataIndexReader.java b/DataExtractionOSM/src/net/osmand/data/index/DataIndexReader.java index a3a7f1087c..ae691f059e 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/DataIndexReader.java +++ b/DataExtractionOSM/src/net/osmand/data/index/DataIndexReader.java @@ -3,11 +3,14 @@ package net.osmand.data.index; import java.io.File; import java.sql.Connection; import java.sql.DriverManager; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.ArrayList; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import net.osmand.LogUtil; import net.osmand.data.Building; @@ -54,11 +57,49 @@ public class DataIndexReader { return cities; } - public List readStreets(Connection c, City city) throws SQLException{ - List streets = new ArrayList(); - Statement stat = c.createStatement(); - ResultSet set = stat.executeQuery(IndexConstants.generateSelectSQL(IndexStreetTable.values(), - IndexStreetTable.CITY.toString() +" = " + city.getId())); //$NON-NLS-1$ + public PreparedStatement getStreetsPreparedStatement(Connection c) throws SQLException{ + return c.prepareStatement(IndexConstants.generateSelectSQL(IndexStreetTable.values(), + IndexStreetTable.CITY.toString() +" = ? ")); //$NON-NLS-1$ + } + + public PreparedStatement getStreetsBuildingPreparedStatement(Connection c) throws SQLException{ + return c.prepareStatement("SELECT A.id, A.name, A.name_en, A.latitude, A.longitude, "+ + "B.id, B.name, B.name_en, B.latitude, B.longitude, B.postcode "+ + "FROM street A INNER JOIN building B ON B.street = A.id WHERE A.city = ? "); //$NON-NLS-1$ + } + + public List readStreetsBuildings(PreparedStatement streetBuildingsStat, City city, List streets) throws SQLException{ + Map visitedStreets = new LinkedHashMap(); + streetBuildingsStat.setLong(1, city.getId()); + ResultSet set = streetBuildingsStat.executeQuery(); + while(set.next()){ + long streetId = set.getLong(1); + if(!visitedStreets.containsKey(streetId)){ + Street street = new Street(null); + street.setName(set.getString(2)); + street.setEnName(set.getString(3)); + street.setLocation(set.getDouble(4),set.getDouble(5)); + street.setId(streetId); + streets.add(street); + visitedStreets.put(streetId, street); + } + Street s = visitedStreets.get(streetId); + Building b = new Building(); + b.setId(set.getLong(6)); + b.setName(set.getString(7)); + b.setEnName(set.getString(8)); + b.setLocation(set.getDouble(9),set.getDouble(10)); + b.setPostcode(set.getString(11)); + s.registerBuilding(b); + } + + set.close(); + return streets; + } + + public List readStreets(PreparedStatement streetsStat, City city, List streets) throws SQLException{ + streetsStat.setLong(1, city.getId()); + ResultSet set = streetsStat.executeQuery(); while(set.next()){ Street street = new Street(city); street.setName(set.getString(IndexStreetTable.NAME.ordinal() + 1)); @@ -69,15 +110,18 @@ public class DataIndexReader { streets.add(street); } set.close(); - stat.close(); return streets; } - public List readBuildings(Connection c, Street street) throws SQLException{ - List buildings = new ArrayList(); - Statement stat = c.createStatement(); - ResultSet set = stat.executeQuery(IndexConstants.generateSelectSQL(IndexBuildingTable.values(), - IndexBuildingTable.STREET.toString() +" = " + street.getId())); //$NON-NLS-1$ + public PreparedStatement getBuildingsPreparedStatement(Connection c) throws SQLException{ + return c.prepareStatement(IndexConstants.generateSelectSQL(IndexBuildingTable.values(), + IndexBuildingTable.STREET.toString() +" = ? ")); + } + + + public List readBuildings(PreparedStatement buildingStat, Street street, List buildings) throws SQLException{ + buildingStat.setLong(1, street.getId()); + ResultSet set = buildingStat.executeQuery(); while(set.next()){ Building building = new Building(); building.setName(set.getString(IndexBuildingTable.NAME.ordinal() + 1)); @@ -88,23 +132,45 @@ public class DataIndexReader { buildings.add(building); } set.close(); - stat.close(); return buildings; } public void testIndex(File f) throws SQLException { Connection c = getConnection(f); try { - for (City city : readCities(c)) { - System.out.println("CITY " + city.getName()); //$NON-NLS-1$ - for (Street s : readStreets(c, city)) { - System.out.println("\tSTREET " + s.getName()); //$NON-NLS-1$ - for (Building b : readBuildings(c, s)) { - System.out.println("\t\tBULDING " + b.getName()); //$NON-NLS-1$ + ArrayList streets = new ArrayList(); + ArrayList buildings = new ArrayList(); + PreparedStatement streetstat = getStreetsBuildingPreparedStatement(c); + int countCity = 0; + int countStreets = 0; + int countBuildings = 0; + List cities = readCities(c); + for (City city : cities) { + countCity ++; +// System.out.println("CITY " + city.getName()); //$NON-NLS-1$ + if(city.getType() != CityType.CITY){ + continue; + } + streets.clear(); + long time = System.currentTimeMillis(); + readStreetsBuildings(streetstat, city, streets); + if(!streets.isEmpty()){ + System.out.println(city.getName()); + } else { + System.out.print("."); + } + for (Street s : streets) { + countStreets ++; +// System.out.println("\tSTREET " + s.getName()); //$NON-NLS-1$ +// buildings.clear(); + for (Building b : s.getBuildings()) { + countBuildings ++; +// System.out.println("\t\tBULDING " + b.getName()); //$NON-NLS-1$ } } } + System.out.println(countCity + " " + countStreets + " " + countBuildings); } finally { c.close(); } diff --git a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java index 9f118fe556..1e48047594 100644 --- a/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/index/IndexBatchCreator.java @@ -285,6 +285,7 @@ public class IndexBatchCreator { String addressFileName = regionName + "_" + IndexConstants.ADDRESS_TABLE_VERSION + IndexConstants.ADDRESS_INDEX_EXT; indexCreator.setAddressFileName(addressFileName); + indexCreator.setSupportOdbAddressFile(true); String transportFileName = regionName + "_" + IndexConstants.TRANSPORT_TABLE_VERSION + IndexConstants.TRANSPORT_INDEX_EXT; indexCreator.setTransportFileName(transportFileName); String poiFileName = regionName + "_" + IndexConstants.POI_TABLE_VERSION + IndexConstants.POI_INDEX_EXT; diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index ac236aec7c..be581fd0b3 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -13,6 +13,7 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.text.Collator; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -23,6 +24,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import java.util.Map.Entry; import net.osmand.Algoritms; @@ -33,9 +35,11 @@ import net.osmand.data.Building; import net.osmand.data.City; import net.osmand.data.DataTileManager; import net.osmand.data.MapObject; +import net.osmand.data.Street; import net.osmand.data.TransportRoute; import net.osmand.data.TransportStop; import net.osmand.data.City.CityType; +import net.osmand.data.index.DataIndexReader; import net.osmand.data.index.DataIndexWriter; import net.osmand.data.index.IndexConstants; import net.osmand.data.index.IndexConstants.IndexBinaryMapRenderObject; @@ -105,6 +109,7 @@ public class IndexCreator { private boolean indexTransport; private boolean indexAddress; + private boolean supportOdbAddressFile; private boolean normalizeStreets; private boolean saveAddressWays; @@ -203,6 +208,10 @@ public class IndexCreator { this.indexAddress = indexAddress; } + public void setSupportOdbAddressFile(boolean supportOdbAddressFile) { + this.supportOdbAddressFile = supportOdbAddressFile; + } + public void setIndexMap(boolean indexMap) { this.indexMap = indexMap; } @@ -1484,10 +1493,68 @@ public class IndexCreator { } + public void writeBinaryAddressIndex(BinaryMapIndexWriter writer) throws IOException, SQLException { + writer.startWriteAddressIndex(getRegionName()); + DataIndexReader reader = new DataIndexReader(); + List cities = reader.readCities(addressConnection); + List streets = new ArrayList(); + Collections.sort(cities, new Comparator(){ + + @Override + public int compare(City o1, City o2) { + if (o1.getType() != o2.getType()) { + return -(o1.getType().ordinal() - o2.getType().ordinal()); + } + return Collator.getInstance().compare(o1.getName(), o2.getName()); + } + }); + PreparedStatement streetstat = reader.getStreetsBuildingPreparedStatement(addressConnection); + + Map> postcodes = new TreeMap>(); + boolean writeCities = true; + // write cities and after villages + writer.startCityIndexes(false); + for(int i =0; i< cities.size(); i++ ) { + City c = cities.get(i); + if(writeCities && c.getType() != CityType.CITY && c.getType() != CityType.TOWN){ + writer.endCityIndexes(false); + writer.startCityIndexes(true); + writeCities = false; + } + + streets.clear(); + reader.readStreetsBuildings(streetstat, c, streets); + writer.writeCityIndex(c, streets); + for(Street s : streets){ + for(Building b : s.getBuildings()){ + if(b.getPostcode() != null){ + if(!postcodes.containsKey(b.getPostcode())){ + postcodes.put(b.getPostcode(), new ArrayList(3)); + } + postcodes.get(b.getPostcode()).add(s); + } + } + } + } + writer.endCityIndexes(!writeCities); + + + // write postcodes + writer.startPostcodes(); + for(String s : postcodes.keySet()){ + writer.writePostcode(s, postcodes.get(s)); + } + writer.endPostcodes(); + + + + + writer.endWriteAddressIndex(); } - + + public void writeBinaryMapIndex(BinaryMapIndexWriter writer) throws IOException, SQLException { try { assert IndexConstants.IndexBinaryMapRenderObject.values().length == 6; @@ -1863,6 +1930,11 @@ public class IndexCreator { DataIndexWriter.addBatch(pStatements, pstat, BATCH_SIZE); } } + if(pStatements.get(pstat) > 0){ + pstat.executeBatch(); + } + pStatements.remove(pstat); + } @@ -1901,17 +1973,24 @@ public class IndexCreator { log.info("Finish packing RTree files"); } - if(indexMap || indexAddress){ + if(indexMap || (indexAddress && !supportOdbAddressFile)){ if(mapFile.exists()){ mapFile.delete(); } mapRAFile = new RandomAccessFile(mapFile, "rw"); BinaryMapIndexWriter writer = new BinaryMapIndexWriter(mapRAFile); if(indexMap){ + log.info("Writing binary map data..."); writeBinaryMapIndex(writer); } - if(indexAddress){ + + if(indexAddress && !supportOdbAddressFile){ + log.info("Writing binary address data..."); + closePreparedStatements(addressCityStat, addressStreetStat, addressStreetNodeStat, addressBuildingStat); + addressConnection.commit(); writeBinaryAddressIndex(writer); + addressConnection.close(); + addressConnection = null; } log.info("Finish writing binary file"); } @@ -1999,10 +2078,20 @@ public class IndexCreator { } dbConn.close(); } catch (SQLException e) { + e.printStackTrace(); } } } + protected void closePreparedStatements(PreparedStatement... preparedStatements) throws SQLException{ + for(PreparedStatement p : preparedStatements){ + p.executeBatch(); + p.close(); + pStatements.remove(p); + } + } + + public static void removeWayNodes(File sqlitedb) throws SQLException{ Connection dbConn = DriverManager.getConnection("jdbc:sqlite:" + sqlitedb.getAbsolutePath()); dbConn.setAutoCommit(false); @@ -2018,25 +2107,22 @@ public class IndexCreator { } public static void main(String[] args) throws IOException, SAXException, SQLException { - + long time = System.currentTimeMillis(); IndexCreator creator = new IndexCreator(new File("e:/Information/OSM maps/osmand/")); creator.setIndexMap(true); + creator.setIndexAddress(true); // creator.setIndexPOI(true); // creator.setIndexTransport(true); -// creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/minsk.tmp.odb")); -// creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/minsk.osm"), new ConsoleProgressImplementation(3), null); + creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/minsk.tmp.odb")); + creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/minsk.osm"), new ConsoleProgressImplementation(3), null); // creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/belarus_nodes.tmp.odb")); // creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/belarus.osm.bz2"), new ConsoleProgressImplementation(3), null); - - +// // creator.generateIndexes(new File("e:/Information/OSM maps/belarus osm/forest.osm"), new ConsoleProgressImplementation(3), null); -// double dist = MapUtils.getDistance(50, MapUtils.getLongitudeFromTile(25, 0), 50, MapUtils.getLongitudeFromTile(25, 1)); -// System.out.println(dist); -// System.out.println(-5 << 2); // creator.setNodesDBFile(new File("e:/Information/OSM maps/osmand/ams.tmp.odb")); @@ -2050,7 +2136,8 @@ public class IndexCreator { // creator.generateIndexes(new File("e:/Information/OSM maps/osm_map/forest_complex.osm"), new ConsoleProgressImplementation(25), null); - + new DataIndexReader().testIndex(new File("e:\\Information\\OSM maps\\osmand\\Address\\Belarus.addr.odb")); + System.out.println(System.currentTimeMillis() - time); System.out.println("COORDINATES_SIZE " + BinaryMapIndexWriter.COORDINATES_SIZE + " count " + BinaryMapIndexWriter.COORDINATES_COUNT); System.out.println("TYPES_SIZE " + BinaryMapIndexWriter.TYPES_SIZE); System.out.println("ID_SIZE " + BinaryMapIndexWriter.ID_SIZE); diff --git a/DataExtractionOSM/src/osmand_odb.proto b/DataExtractionOSM/src/osmand_odb.proto index dfc7e41734..6c16634d90 100644 --- a/DataExtractionOSM/src/osmand_odb.proto +++ b/DataExtractionOSM/src/osmand_odb.proto @@ -82,11 +82,23 @@ message OsmAndAddressIndex { optional string name_en = 2; // encoded as fixed32 length delimited - repeated CityIndex cityIndex= 5; // cities and towns + optional CitiesIndex cities = 5; // cities and towns - repeated PostcodeIndex postcodes= 6; + // encoded as fixed32 length delimited + optional PostcodesIndex postcodes = 6; - repeated CityIndex villages = 7; // suburbs and villages + // encoded as fixed32 length delimited + optional CitiesIndex villages = 7; // suburbs and villages +} + +message CitiesIndex { + // encoded as fixed32 length delimited + repeated CityIndex cities = 1; +} + +message PostcodesIndex { + // encoded as fixed32 length delimited + repeated PostcodeIndex postcodes = 1; } message CityIndex { @@ -101,6 +113,8 @@ message CityIndex { repeated StreetIndex streets = 7; } + + message PostcodeIndex { required string postcode = 1; repeated StreetIndex streets = 5; @@ -122,6 +136,7 @@ message BuildingIndex { required string name = 1; optional string name_en = 2; optional uint64 id = 5; + optional string postcode = 6; required sint32 x = 3; // delta encoded to street 24 zoom required sint32 y = 4; // delta encoded to street 24 zoom diff --git a/OsmAnd/AndroidManifest.xml b/OsmAnd/AndroidManifest.xml index aff443c760..11d4118fbb 100644 --- a/OsmAnd/AndroidManifest.xml +++ b/OsmAnd/AndroidManifest.xml @@ -1,6 +1,6 @@ + package="net.osmand" android:versionName="0.5.1" android:versionCode="20" android:installLocation="auto">