From 0ad56fe24b8251d43fde5b78579369402b6c1bd6 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Mon, 5 Mar 2012 00:55:51 +0100 Subject: [PATCH] Fixing errors --- .../src/net/osmand/binary/OsmandOdb.java | 252 ++++++++++++------ .../src/net/osmand/data/Building.java | 46 ++++ .../preparation/BinaryMapIndexWriter.java | 49 ++-- .../osmand/data/preparation/DBStreetDAO.java | 23 +- .../data/preparation/IndexAddressCreator.java | 92 ++++++- .../osmand/data/preparation/IndexCreator.java | 13 +- .../preparation/IndexVectorMapCreator.java | 79 +++--- .../src/net/osmand/osm/MapRenderingTypes.java | 14 +- .../src/net/osmand/osm/OSMSettings.java | 2 +- .../src/net/osmand/osm/rendering_types.xml | 7 - DataExtractionOSM/src/osmand_odb.proto | 6 + 11 files changed, 412 insertions(+), 171 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java b/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java index b58f4806c1..8a6d8cd863 100644 --- a/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java +++ b/DataExtractionOSM/src/net/osmand/binary/OsmandOdb.java @@ -4669,6 +4669,20 @@ public final class OsmandOdb { return dataObjects_.get(index); } + // optional uint32 rasterType = 13; + public static final int RASTERTYPE_FIELD_NUMBER = 13; + private boolean hasRasterType; + private int rasterType_ = 0; + public boolean hasRasterType() { return hasRasterType; } + public int getRasterType() { return rasterType_; } + + // optional bytes rasterImage = 14; + public static final int RASTERIMAGE_FIELD_NUMBER = 14; + private boolean hasRasterImage; + private com.google.protobuf.ByteString rasterImage_ = com.google.protobuf.ByteString.EMPTY; + public boolean hasRasterImage() { return hasRasterImage; } + public com.google.protobuf.ByteString getRasterImage() { return rasterImage_; } + // optional .StringTable stringTable = 15; public static final int STRINGTABLE_FIELD_NUMBER = 15; private boolean hasStringTable; @@ -4697,6 +4711,12 @@ public final class OsmandOdb { for (net.osmand.binary.OsmandOdb.MapData element : getDataObjectsList()) { output.writeMessage(12, element); } + if (hasRasterType()) { + output.writeUInt32(13, getRasterType()); + } + if (hasRasterImage()) { + output.writeBytes(14, getRasterImage()); + } if (hasStringTable()) { output.writeMessage(15, getStringTable()); } @@ -4718,6 +4738,14 @@ public final class OsmandOdb { size += com.google.protobuf.CodedOutputStream .computeMessageSize(12, element); } + if (hasRasterType()) { + size += com.google.protobuf.CodedOutputStream + .computeUInt32Size(13, getRasterType()); + } + if (hasRasterImage()) { + size += com.google.protobuf.CodedOutputStream + .computeBytesSize(14, getRasterImage()); + } if (hasStringTable()) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(15, getStringTable()); @@ -4904,6 +4932,12 @@ public final class OsmandOdb { } result.dataObjects_.addAll(other.dataObjects_); } + if (other.hasRasterType()) { + setRasterType(other.getRasterType()); + } + if (other.hasRasterImage()) { + setRasterImage(other.getRasterImage()); + } if (other.hasStringTable()) { mergeStringTable(other.getStringTable()); } @@ -4943,6 +4977,14 @@ public final class OsmandOdb { addDataObjects(subBuilder.buildPartial()); break; } + case 104: { + setRasterType(input.readUInt32()); + break; + } + case 114: { + setRasterImage(input.readBytes()); + break; + } case 122: { net.osmand.binary.OsmandOdb.StringTable.Builder subBuilder = net.osmand.binary.OsmandOdb.StringTable.newBuilder(); if (hasStringTable()) { @@ -5026,6 +5068,45 @@ public final class OsmandOdb { return this; } + // optional uint32 rasterType = 13; + public boolean hasRasterType() { + return result.hasRasterType(); + } + public int getRasterType() { + return result.getRasterType(); + } + public Builder setRasterType(int value) { + result.hasRasterType = true; + result.rasterType_ = value; + return this; + } + public Builder clearRasterType() { + result.hasRasterType = false; + result.rasterType_ = 0; + return this; + } + + // optional bytes rasterImage = 14; + public boolean hasRasterImage() { + return result.hasRasterImage(); + } + public com.google.protobuf.ByteString getRasterImage() { + return result.getRasterImage(); + } + public Builder setRasterImage(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + result.hasRasterImage = true; + result.rasterImage_ = value; + return this; + } + public Builder clearRasterImage() { + result.hasRasterImage = false; + result.rasterImage_ = getDefaultInstance().getRasterImage(); + return this; + } + // optional .StringTable stringTable = 15; public boolean hasStringTable() { return result.hasStringTable(); @@ -18624,90 +18705,91 @@ public final class OsmandOdb { "\n\016shiftToMapData\030\005 \001(\007\022\r\n\005ocean\030\006 \001(\010\022)\n" + "\005boxes\030\007 \003(\0132\032.OsmAndMapIndex.MapDataBox" + "\032-\n\rMapDataBlocks\022\034\n\005block\030\006 \003(\0132\r.MapDa" + - "taBlock\"`\n\014MapDataBlock\022\016\n\006baseId\030\n \001(\004\022" + - "\035\n\013dataObjects\030\014 \003(\0132\010.MapData\022!\n\013string" + - "Table\030\017 \001(\0132\014.StringTable\"\241\001\n\007MapData\022\023\n", - "\013coordinates\030\001 \001(\014\022\027\n\017areaCoordinates\030\002 " + - "\001(\014\022\037\n\027polygonInnerCoordinates\030\004 \003(\014\022\027\n\017" + - "additionalTypes\030\006 \001(\014\022\r\n\005types\030\007 \002(\014\022\023\n\013" + - "stringNames\030\n \001(\014\022\n\n\002id\030\014 \002(\022\"\222\002\n\022OsmAnd" + - "AddressIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 " + - "\001(\t\022\"\n\nboundaries\030\003 \001(\0132\016.OsmAndTileBox\022" + - "/\n\006cities\030\006 \003(\0132\037.OsmAndAddressIndex.Cit" + - "iesIndex\022.\n\tnameIndex\030\007 \001(\0132\033.OsmAndAddr" + - "essNameIndexData\032X\n\013CitiesIndex\022\014\n\004type\030" + - "\002 \002(\r\022\032\n\006cities\030\005 \003(\0132\n.CityIndex\022\037\n\006blo", - "cks\030\007 \003(\0132\017.CityBlockIndex\"\301\001\n\032OsmAndAdd" + - "ressNameIndexData\022\"\n\005table\030\004 \002(\0132\023.Index" + - "edStringTable\022>\n\004atom\030\007 \003(\01320.OsmAndAddr" + - "essNameIndexData.AddressNameIndexData\032?\n" + - "\024AddressNameIndexData\022\'\n\004atom\030\004 \003(\0132\031.Ad" + - "dressNameIndexDataAtom\"v\n\030AddressNameInd" + - "exDataAtom\022\014\n\004name\030\001 \002(\t\022\016\n\006nameEn\030\002 \001(\t" + - "\022\014\n\004type\030\003 \002(\r\022\024\n\014shiftToIndex\030\005 \003(\007\022\030\n\020" + - "shiftToCityIndex\030\006 \003(\007\"~\n\tCityIndex\022\021\n\tc" + - "ity_type\030\001 \001(\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(\r\022\t\n\001y\030\006 \002(\r\022" + - "\035\n\025shiftToCityBlockIndex\030\n \001(\007\"l\n\016CityBl" + - "ockIndex\022\030\n\020shiftToCityIndex\030\004 \001(\007\022!\n\tbu" + - "ildings\030\020 \003(\0132\016.BuildingIndex\022\035\n\007streets" + - "\030\022 \003(\0132\014.StreetIndex\"\235\001\n\013StreetIndex\022\014\n\004" + - "name\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\t\n\001x\030\003 \002(\021\022\t" + - "\n\001y\030\004 \002(\021\022\n\n\002id\030\006 \001(\004\022!\n\tbuildings\030\014 \003(\013" + - "2\016.BuildingIndex\022*\n\rintersections\030\005 \003(\0132" + - "\023.StreetIntersection\"_\n\022StreetIntersecti" + - "on\022\014\n\004name\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\024\n\014int", - "ersectedX\030\004 \002(\021\022\024\n\014intersectedY\030\005 \002(\021\"\262\001" + - "\n\rBuildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en" + - "\030\002 \001(\t\022\r\n\005name2\030\003 \001(\t\022\020\n\010name_en2\030\004 \001(\t\022" + - "\025\n\rinterpolation\030\005 \001(\021\022\t\n\001x\030\007 \002(\021\022\t\n\001y\030\010" + - " \002(\021\022\n\n\002x2\030\t \001(\021\022\n\n\002y2\030\n \001(\021\022\n\n\002id\030\r \001(\004" + - "\022\020\n\010postcode\030\016 \001(\t\"2\n\017TransportRoutes\022\037\n" + - "\006routes\030\006 \003(\0132\017.TransportRoute\"\317\001\n\016Trans" + - "portRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(\r\022\020\n\010o" + - "perator\030\004 \001(\r\022\013\n\003ref\030\005 \001(\t\022\014\n\004name\030\006 \001(\r" + - "\022\017\n\007name_en\030\007 \001(\r\022\020\n\010distance\030\010 \001(\r\022(\n\013d", - "irectStops\030\017 \003(\0132\023.TransportRouteStop\022)\n" + - "\014reverseStops\030\020 \003(\0132\023.TransportRouteStop" + - "\"W\n\022TransportRouteStop\022\n\n\002id\030\001 \002(\022\022\n\n\002dx" + - "\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017\n\007name" + - "_en\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002dx\030\001 \002(\021\022\n" + - "\n\002dy\030\002 \002(\021\022\n\n\002id\030\005 \002(\022\022\014\n\004name\030\006 \002(\r\022\017\n\007" + - "name_en\030\007 \001(\r\022\016\n\006routes\030\020 \003(\r\"\244\001\n\022Transp" + - "ortStopsTree\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 \002(" + - "\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022%\n\010subtre" + - "es\030\007 \003(\0132\023.TransportStopsTree\022\035\n\005leafs\030\010", - " \003(\0132\016.TransportStop\022\016\n\006baseId\030\020 \001(\004\"\215\001\n" + - "\024OsmAndTransportIndex\022\014\n\004name\030\001 \001(\t\022 \n\006r" + - "outes\030\003 \001(\0132\020.TransportRoutes\022\"\n\005stops\030\006" + - " \001(\0132\023.TransportStopsTree\022!\n\013stringTable" + - "\030\t \002(\0132\014.StringTable\"\333\001\n\016OsmAndPoiIndex\022" + - "\014\n\004name\030\001 \002(\t\022\"\n\nboundaries\030\002 \002(\0132\016.OsmA" + - "ndTileBox\022-\n\017categoriesTable\030\003 \003(\0132\024.Osm" + - "AndCategoryTable\022&\n\tnameIndex\030\004 \001(\0132\023.Os" + - "mAndPoiNameIndex\022\034\n\005boxes\030\006 \003(\0132\r.OsmAnd" + - "PoiBox\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBoxDa", - "ta\"\270\001\n\022OsmAndPoiNameIndex\022\"\n\005table\030\003 \002(\013" + - "2\023.IndexedStringTable\0228\n\004data\030\005 \003(\0132*.Os" + - "mAndPoiNameIndex.OsmAndPoiNameIndexData\032" + - "D\n\026OsmAndPoiNameIndexData\022*\n\005atoms\030\003 \003(\013" + - "2\033.OsmAndPoiNameIndexDataAtom\"Q\n\032OsmAndP" + - "oiNameIndexDataAtom\022\014\n\004zoom\030\002 \001(\r\022\t\n\001x\030\003" + - " \001(\r\022\t\n\001y\030\004 \001(\r\022\017\n\007shiftTo\030\016 \001(\007\">\n\023OsmA" + - "ndCategoryTable\022\020\n\010category\030\001 \002(\t\022\025\n\rsub" + - "categories\030\003 \003(\t\"\227\001\n\014OsmAndPoiBox\022\014\n\004zoo" + - "m\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022(\n\nca", - "tegories\030\004 \001(\0132\024.OsmAndPoiCategories\022\037\n\010" + - "subBoxes\030\n \003(\0132\r.OsmAndPoiBox\022\023\n\013shiftTo" + - "Data\030\016 \001(\007\")\n\023OsmAndPoiCategories\022\022\n\ncat" + - "egories\030\003 \003(\r\"^\n\020OsmAndPoiBoxData\022\014\n\004zoo" + - "m\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\022&\n\007poiData" + - "\030\005 \003(\0132\025.OsmAndPoiBoxDataAtom\"\255\001\n\024OsmAnd" + - "PoiBoxDataAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\022" + - "\n\ncategories\030\004 \003(\r\022\014\n\004name\030\006 \001(\t\022\016\n\006name" + - "En\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024\n\014openingHours\030\n \001" + - "(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005phone\030\014 \001(\t\022\014\n\004note\030", - "\r \001(\tB\023\n\021net.osmand.binary" + "taBlock\"\211\001\n\014MapDataBlock\022\016\n\006baseId\030\n \001(\004" + + "\022\035\n\013dataObjects\030\014 \003(\0132\010.MapData\022\022\n\nraste" + + "rType\030\r \001(\r\022\023\n\013rasterImage\030\016 \001(\014\022!\n\013stri", + "ngTable\030\017 \001(\0132\014.StringTable\"\241\001\n\007MapData\022" + + "\023\n\013coordinates\030\001 \001(\014\022\027\n\017areaCoordinates\030" + + "\002 \001(\014\022\037\n\027polygonInnerCoordinates\030\004 \003(\014\022\027" + + "\n\017additionalTypes\030\006 \001(\014\022\r\n\005types\030\007 \002(\014\022\023" + + "\n\013stringNames\030\n \001(\014\022\n\n\002id\030\014 \002(\022\"\222\002\n\022OsmA" + + "ndAddressIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_en\030" + + "\002 \001(\t\022\"\n\nboundaries\030\003 \001(\0132\016.OsmAndTileBo" + + "x\022/\n\006cities\030\006 \003(\0132\037.OsmAndAddressIndex.C" + + "itiesIndex\022.\n\tnameIndex\030\007 \001(\0132\033.OsmAndAd" + + "dressNameIndexData\032X\n\013CitiesIndex\022\014\n\004typ", + "e\030\002 \002(\r\022\032\n\006cities\030\005 \003(\0132\n.CityIndex\022\037\n\006b" + + "locks\030\007 \003(\0132\017.CityBlockIndex\"\301\001\n\032OsmAndA" + + "ddressNameIndexData\022\"\n\005table\030\004 \002(\0132\023.Ind" + + "exedStringTable\022>\n\004atom\030\007 \003(\01320.OsmAndAd" + + "dressNameIndexData.AddressNameIndexData\032" + + "?\n\024AddressNameIndexData\022\'\n\004atom\030\004 \003(\0132\031." + + "AddressNameIndexDataAtom\"v\n\030AddressNameI" + + "ndexDataAtom\022\014\n\004name\030\001 \002(\t\022\016\n\006nameEn\030\002 \001" + + "(\t\022\014\n\004type\030\003 \002(\r\022\024\n\014shiftToIndex\030\005 \003(\007\022\030" + + "\n\020shiftToCityIndex\030\006 \003(\007\"~\n\tCityIndex\022\021\n", + "\tcity_type\030\001 \001(\r\022\014\n\004name\030\002 \002(\t\022\017\n\007name_e" + + "n\030\003 \001(\t\022\n\n\002id\030\004 \001(\004\022\t\n\001x\030\005 \002(\r\022\t\n\001y\030\006 \002(" + + "\r\022\035\n\025shiftToCityBlockIndex\030\n \001(\007\"l\n\016City" + + "BlockIndex\022\030\n\020shiftToCityIndex\030\004 \001(\007\022!\n\t" + + "buildings\030\020 \003(\0132\016.BuildingIndex\022\035\n\007stree" + + "ts\030\022 \003(\0132\014.StreetIndex\"\235\001\n\013StreetIndex\022\014" + + "\n\004name\030\001 \002(\t\022\017\n\007name_en\030\002 \001(\t\022\t\n\001x\030\003 \002(\021" + + "\022\t\n\001y\030\004 \002(\021\022\n\n\002id\030\006 \001(\004\022!\n\tbuildings\030\014 \003" + + "(\0132\016.BuildingIndex\022*\n\rintersections\030\005 \003(" + + "\0132\023.StreetIntersection\"_\n\022StreetIntersec", + "tion\022\014\n\004name\030\002 \002(\t\022\017\n\007name_en\030\003 \001(\t\022\024\n\014i" + + "ntersectedX\030\004 \002(\021\022\024\n\014intersectedY\030\005 \002(\021\"" + + "\262\001\n\rBuildingIndex\022\014\n\004name\030\001 \002(\t\022\017\n\007name_" + + "en\030\002 \001(\t\022\r\n\005name2\030\003 \001(\t\022\020\n\010name_en2\030\004 \001(" + + "\t\022\025\n\rinterpolation\030\005 \001(\021\022\t\n\001x\030\007 \002(\021\022\t\n\001y" + + "\030\010 \002(\021\022\n\n\002x2\030\t \001(\021\022\n\n\002y2\030\n \001(\021\022\n\n\002id\030\r \001" + + "(\004\022\020\n\010postcode\030\016 \001(\t\"2\n\017TransportRoutes\022" + + "\037\n\006routes\030\006 \003(\0132\017.TransportRoute\"\317\001\n\016Tra" + + "nsportRoute\022\n\n\002id\030\001 \002(\004\022\014\n\004type\030\003 \001(\r\022\020\n" + + "\010operator\030\004 \001(\r\022\013\n\003ref\030\005 \001(\t\022\014\n\004name\030\006 \001", + "(\r\022\017\n\007name_en\030\007 \001(\r\022\020\n\010distance\030\010 \001(\r\022(\n" + + "\013directStops\030\017 \003(\0132\023.TransportRouteStop\022" + + ")\n\014reverseStops\030\020 \003(\0132\023.TransportRouteSt" + + "op\"W\n\022TransportRouteStop\022\n\n\002id\030\001 \002(\022\022\n\n\002" + + "dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021\022\014\n\004name\030\006 \002(\r\022\017\n\007na" + + "me_en\030\007 \001(\r\"b\n\rTransportStop\022\n\n\002dx\030\001 \002(\021" + + "\022\n\n\002dy\030\002 \002(\021\022\n\n\002id\030\005 \002(\022\022\014\n\004name\030\006 \002(\r\022\017" + + "\n\007name_en\030\007 \001(\r\022\016\n\006routes\030\020 \003(\r\"\244\001\n\022Tran" + + "sportStopsTree\022\014\n\004left\030\001 \002(\021\022\r\n\005right\030\002 " + + "\002(\021\022\013\n\003top\030\003 \002(\021\022\016\n\006bottom\030\004 \002(\021\022%\n\010subt", + "rees\030\007 \003(\0132\023.TransportStopsTree\022\035\n\005leafs" + + "\030\010 \003(\0132\016.TransportStop\022\016\n\006baseId\030\020 \001(\004\"\215" + + "\001\n\024OsmAndTransportIndex\022\014\n\004name\030\001 \001(\t\022 \n" + + "\006routes\030\003 \001(\0132\020.TransportRoutes\022\"\n\005stops" + + "\030\006 \001(\0132\023.TransportStopsTree\022!\n\013stringTab" + + "le\030\t \002(\0132\014.StringTable\"\333\001\n\016OsmAndPoiInde" + + "x\022\014\n\004name\030\001 \002(\t\022\"\n\nboundaries\030\002 \002(\0132\016.Os" + + "mAndTileBox\022-\n\017categoriesTable\030\003 \003(\0132\024.O" + + "smAndCategoryTable\022&\n\tnameIndex\030\004 \001(\0132\023." + + "OsmAndPoiNameIndex\022\034\n\005boxes\030\006 \003(\0132\r.OsmA", + "ndPoiBox\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBox" + + "Data\"\270\001\n\022OsmAndPoiNameIndex\022\"\n\005table\030\003 \002" + + "(\0132\023.IndexedStringTable\0228\n\004data\030\005 \003(\0132*." + + "OsmAndPoiNameIndex.OsmAndPoiNameIndexDat" + + "a\032D\n\026OsmAndPoiNameIndexData\022*\n\005atoms\030\003 \003" + + "(\0132\033.OsmAndPoiNameIndexDataAtom\"Q\n\032OsmAn" + + "dPoiNameIndexDataAtom\022\014\n\004zoom\030\002 \001(\r\022\t\n\001x" + + "\030\003 \001(\r\022\t\n\001y\030\004 \001(\r\022\017\n\007shiftTo\030\016 \001(\007\">\n\023Os" + + "mAndCategoryTable\022\020\n\010category\030\001 \002(\t\022\025\n\rs" + + "ubcategories\030\003 \003(\t\"\227\001\n\014OsmAndPoiBox\022\014\n\004z", + "oom\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022(\n\n" + + "categories\030\004 \001(\0132\024.OsmAndPoiCategories\022\037" + + "\n\010subBoxes\030\n \003(\0132\r.OsmAndPoiBox\022\023\n\013shift" + + "ToData\030\016 \001(\007\")\n\023OsmAndPoiCategories\022\022\n\nc" + + "ategories\030\003 \003(\r\"^\n\020OsmAndPoiBoxData\022\014\n\004z" + + "oom\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\022&\n\007poiDa" + + "ta\030\005 \003(\0132\025.OsmAndPoiBoxDataAtom\"\255\001\n\024OsmA" + + "ndPoiBoxDataAtom\022\n\n\002dx\030\002 \002(\021\022\n\n\002dy\030\003 \002(\021" + + "\022\022\n\ncategories\030\004 \003(\r\022\014\n\004name\030\006 \001(\t\022\016\n\006na" + + "meEn\030\007 \001(\t\022\n\n\002id\030\010 \001(\004\022\024\n\014openingHours\030\n", + " \001(\t\022\014\n\004site\030\013 \001(\t\022\r\n\005phone\030\014 \001(\t\022\014\n\004not" + + "e\030\r \001(\tB\023\n\021net.osmand.binary" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { @@ -18792,7 +18874,7 @@ public final class OsmandOdb { internal_static_MapDataBlock_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_MapDataBlock_descriptor, - new java.lang.String[] { "BaseId", "DataObjects", "StringTable", }, + new java.lang.String[] { "BaseId", "DataObjects", "RasterType", "RasterImage", "StringTable", }, net.osmand.binary.OsmandOdb.MapDataBlock.class, net.osmand.binary.OsmandOdb.MapDataBlock.Builder.class); internal_static_MapData_descriptor = diff --git a/DataExtractionOSM/src/net/osmand/data/Building.java b/DataExtractionOSM/src/net/osmand/data/Building.java index 78ff15ebde..5b28eee198 100644 --- a/DataExtractionOSM/src/net/osmand/data/Building.java +++ b/DataExtractionOSM/src/net/osmand/data/Building.java @@ -1,11 +1,28 @@ package net.osmand.data; import net.osmand.osm.Entity; +import net.osmand.osm.LatLon; import net.osmand.osm.OSMSettings.OSMTagKey; public class Building extends MapObject { private String postcode; + private LatLon latLon2; + private BuildingInterpolation interpolationType; + private int interpolationInterval; + private String name2; + + public enum BuildingInterpolation { + ALL(-1), EVEN(-2), ODD(-3), ALPHABETIC(-4); + private final int val; + + BuildingInterpolation(int val) { + this.val = val; + } + public int getValue() { + return val; + } + } public Building(Entity e){ super(e); @@ -19,6 +36,35 @@ public class Building extends MapObject { return postcode; } + public int getInterpolationInterval() { + return interpolationInterval; + } + public void setInterpolationInterval(int interpolationNumber) { + this.interpolationInterval = interpolationNumber; + } + + public BuildingInterpolation getInterpolationType() { + return interpolationType; + } + + public void setInterpolationType(BuildingInterpolation interpolationType) { + this.interpolationType = interpolationType; + } + + public LatLon getLatLon2() { + return latLon2; + } + public void setLatLon2(LatLon latlon2) { + this.latLon2 = latlon2; + } + public String getName2() { + return name2; + } + + public void setName2(String name2) { + this.name2 = name2; + } + public void setPostcode(String postcode) { this.postcode = postcode; } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java index 0f8588b393..6ea1cde63c 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/BinaryMapIndexWriter.java @@ -1,15 +1,11 @@ package net.osmand.data.preparation; -import gnu.trove.TByteCollection; -import gnu.trove.list.TLongList; import gnu.trove.list.array.TByteArrayList; import gnu.trove.list.array.TIntArrayList; -import gnu.trove.list.array.TLongArrayList; import java.io.IOException; import java.io.OutputStream; import java.io.RandomAccessFile; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -41,7 +37,6 @@ import net.osmand.binary.OsmandOdb.OsmAndAddressNameIndexData; import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapDataBox; import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapEncodingRule; import net.osmand.binary.OsmandOdb.OsmAndMapIndex.MapRootLevel; -import net.osmand.binary.OsmandOdb.IndexedStringTable; import net.osmand.binary.OsmandOdb.OsmAndMapIndex; import net.osmand.binary.OsmandOdb.OsmAndPoiBoxDataAtom; import net.osmand.binary.OsmandOdb.OsmAndPoiNameIndex; @@ -70,7 +65,6 @@ import net.sf.junidecode.Junidecode; import com.google.protobuf.ByteString; import com.google.protobuf.CodedOutputStream; -import com.google.protobuf.MessageLite; import com.google.protobuf.WireFormat; import com.google.protobuf.WireFormat.FieldType; @@ -162,11 +156,11 @@ public class BinaryMapIndexWriter { return codedOutStream.getWrittenBytes(); } - private void writeFixed32(long posToWrite, int value, long currentPosition) throws IOException { - raf.seek(posToWrite); - raf.writeInt(value); - raf.seek(currentPosition); - } +// private void writeFixed32(long posToWrite, int value, long currentPosition) throws IOException { +// raf.seek(posToWrite); +// raf.writeInt(value); +// raf.seek(currentPosition); +// } private int writeInt32Size() throws IOException { long filePointer = getFilePointer(); @@ -368,13 +362,13 @@ public class BinaryMapIndexWriter { data.setCoordinates(ByteString.copyFrom(mapDataBuf.toArray())); } - if (innerPolygonTypes.length > 0) { + if (innerPolygonTypes != null && innerPolygonTypes.length > 0) { mapDataBuf.clear(); pcalcx = pleft; pcalcy = ptop; for (int i = 0; i < innerPolygonTypes.length / 8; i++) { - int x = Algoritms.parseIntFromBytes(coordinates, i * 8); - int y = Algoritms.parseIntFromBytes(coordinates, i * 8 + 4); + int x = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8); + int y = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8 + 4); if (x == 0 && y == 0) { if (mapDataBuf.size() > 0) { data.addPolygonInnerCoordinates(ByteString.copyFrom(mapDataBuf.toArray())); @@ -398,7 +392,7 @@ public class BinaryMapIndexWriter { data.setTypes(ByteString.copyFrom(types)); TYPES_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapData.TYPES_FIELD_NUMBER) + CodedOutputStream.computeRawVarint32Size(types.length) + types.length; - if (additionalTypes.length > 0) { + if (additionalTypes != null && additionalTypes.length > 0) { data.setAdditionalTypes(ByteString.copyFrom(additionalTypes)); TYPES_SIZE += CodedOutputStream.computeTagSize(OsmandOdb.MapData.ADDITIONALTYPES_FIELD_NUMBER) + CodedOutputStream.computeRawVarint32Size(additionalTypes.length) + additionalTypes.length; @@ -441,7 +435,7 @@ public class BinaryMapIndexWriter { public void writeAddressNameIndex(Map> namesIndex) throws IOException { - checkPeekState(CITY_INDEX_INIT); + checkPeekState(ADDRESS_INDEX_INIT); codedOutStream.writeTag(OsmAndAddressIndex.NAMEINDEX_FIELD_NUMBER, WireFormat.WIRETYPE_FIXED32_LENGTH_DELIMITED); preserveInt32Size(); @@ -597,7 +591,28 @@ public class BinaryMapIndexWriter { int by = MapUtils.get31TileNumberY(b.getLocation().getLatitude()); bbuilder.setX((bx - sx) >> 7); bbuilder.setY((by - sy) >> 7); - TODO; + + String number2 = b.getName2(); + if(!Algoritms.isEmpty(number2)){ + LatLon loc = b.getLatLon2(); + if(loc == null) { + bbuilder.setX((bx - sx) >> 7); + bbuilder.setY((by - sy) >> 7); + } else { + int bcx = MapUtils.get31TileNumberX(loc.getLongitude()); + int bcy = MapUtils.get31TileNumberY(loc.getLatitude()); + bbuilder.setX((bcx - sx) >> 7); + bbuilder.setY((bcy - sy) >> 7); + } + bbuilder.setName2(number2); + if(b.getInterpolationType() != null) { + bbuilder.setInterpolation(b.getInterpolationType().getValue()); + } else if(b.getInterpolationInterval() > 0) { + bbuilder.setInterpolation(b.getInterpolationInterval()); + } else { + bbuilder.setInterpolation(1); + } + } bbuilder.setId(b.getId()); bbuilder.setName(b.getName()); if (checkEnNameToWrite(b)) { diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/DBStreetDAO.java b/DataExtractionOSM/src/net/osmand/data/preparation/DBStreetDAO.java index b7d566751d..d5de726c96 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/DBStreetDAO.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/DBStreetDAO.java @@ -51,6 +51,7 @@ public class DBStreetDAO extends AbstractIndexPartCreator private PreparedStatement addressBuildingStat; private PreparedStatement addressSearchStreetStat; private PreparedStatement addressSearchBuildingStat; + private PreparedStatement addressRemoveBuildingStat; private PreparedStatement addressSearchStreetNodeStat; private PreparedStatement addressSearchStreetStatWithoutCityPart; @@ -68,6 +69,7 @@ public class DBStreetDAO extends AbstractIndexPartCreator // create index on name ? stat.executeUpdate("create table building (id bigint, latitude double, longitude double, " + + "name2 varchar(1024), name_en2 varchar(1024), lat2 double, lon2 double, interval int, interpolateType varchar(50), " + "name varchar(1024), name_en varchar(1024), street bigint, postcode varchar(1024), primary key(street, id))"); stat.executeUpdate("create index building_postcode on building (postcode)"); stat.executeUpdate("create index building_street on building (street)"); @@ -81,11 +83,12 @@ public class DBStreetDAO extends AbstractIndexPartCreator addressStreetStat = createPrepareStatement(mapConnection,"insert into street (id, latitude, longitude, name, name_en, city, citypart) values (?, ?, ?, ?, ?, ?, ?)"); addressStreetNodeStat = createPrepareStatement(mapConnection,"insert into street_node (id, latitude, longitude, street, way) values (?, ?, ?, ?, ?)"); - addressBuildingStat = createPrepareStatement(mapConnection,"insert into building (id, latitude, longitude, name, name_en, street, postcode) values (?, ?, ?, ?, ?, ?, ?)"); + addressBuildingStat = createPrepareStatement(mapConnection,"insert into building (id, latitude, longitude, name, name_en, street, postcode, name2, name_en2, lat2, lon2, interval, interpolateType) values (?, ?, ?, ?, ?, ?, ?, ?, ? ,? ,? ,? ,?)"); addressSearchStreetStat = createPrepareStatement(mapConnection,"SELECT id,latitude,longitude FROM street WHERE ? = city AND ? = citypart AND ? = name"); addressSearchStreetStatWithoutCityPart = createPrepareStatement(mapConnection,"SELECT id,name,citypart,latitude,longitude FROM street WHERE ? = city AND ? = name"); addressStreetUpdateCityPart = createPrepareStatement(mapConnection,"UPDATE street SET citypart = ? WHERE id = ?"); addressSearchBuildingStat = createPrepareStatement(mapConnection,"SELECT id FROM building where ? = id"); + addressRemoveBuildingStat = createPrepareStatement(mapConnection,"DELETE FROM building where ? = id"); addressSearchStreetNodeStat = createPrepareStatement(mapConnection,"SELECT way FROM street_node WHERE ? = way"); } @@ -114,6 +117,17 @@ public class DBStreetDAO extends AbstractIndexPartCreator addressBuildingStat.setString(5, building.getEnName()); addressBuildingStat.setLong(6, streetId); addressBuildingStat.setString(7, building.getPostcode() == null ? null : building.getPostcode().toUpperCase()); + addressBuildingStat.setString(8, building.getName2()); + addressBuildingStat.setString(9, building.getName2()); + LatLon l = building.getLatLon2() ; + addressBuildingStat.setDouble(10, l == null? 0 : l.getLatitude()); + addressBuildingStat.setDouble(11, l == null? 0 : l.getLongitude()); + addressBuildingStat.setInt(12, building.getInterpolationInterval()); + if(building.getInterpolationType() == null) { + addressBuildingStat.setString(13, null); + } else { + addressBuildingStat.setString(13, building.getInterpolationType().toString()); + } addBatch(addressBuildingStat); } } @@ -178,6 +192,13 @@ public class DBStreetDAO extends AbstractIndexPartCreator rs.close(); return exist; } + + public boolean removeBuilding(Entity e) throws SQLException { + addressRemoveBuildingStat.setLong(1, e.getId()); + boolean res = addressRemoveBuildingStat.execute(); + commit(); + return res; + } public boolean findStreetNode(Entity e) throws SQLException { commit(); //we are doing batch adds, to search, we must commit diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexAddressCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexAddressCreator.java index 2ea379cb9b..1392e9ddaa 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexAddressCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexAddressCreator.java @@ -27,6 +27,7 @@ import net.osmand.Algoritms; import net.osmand.IProgress; import net.osmand.data.Boundary; import net.osmand.data.Building; +import net.osmand.data.Building.BuildingInterpolation; import net.osmand.data.City; import net.osmand.data.City.CityType; import net.osmand.data.DataTileManager; @@ -654,6 +655,50 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{ public void iterateMainEntity(Entity e, OsmDbAccessorContext ctx) throws SQLException { // index not only buildings but also nodes that belongs to addr:interpolation ways + // currently not supported because nodes are indexed first with buildings + if (e instanceof Way && e.getTag(OSMTagKey.ADDR_INTERPOLATION) != null ){ + BuildingInterpolation type = null; + int interpolationInterval = 0; + if(e.getTag(OSMTagKey.ADDR_INTERPOLATION) != null) { + try { + type = BuildingInterpolation.valueOf(e.getTag(OSMTagKey.ADDR_INTERPOLATION).toUpperCase()); + } catch (RuntimeException ex) { + try { + interpolationInterval = Integer.parseInt(e.getTag(OSMTagKey.ADDR_INTERPOLATION)); + } catch(NumberFormatException ex2) { + } + } + } + if (type != null && interpolationInterval > 0) { + List nodesWithHno = new ArrayList(); + for (Node n : ((Way) e).getNodes()) { + if (n.getTag(OSMTagKey.ADDR_HOUSE_NUMBER) != null && n.getTag(OSMTagKey.ADDR_STREET) != null) { + nodesWithHno.add(n); + } + } + if (nodesWithHno.size() > 1) { + for (int i = 1; i < nodesWithHno.size(); i++) { + Node first = nodesWithHno.get(i - 1); + Node second = nodesWithHno.get(i); + boolean exist = streetDAO.findBuilding(first); + if (exist) { + streetDAO.removeBuilding(first); + } + LatLon l = e.getLatLon(); + Set idsOfStreet = getStreetInCity(first.getIsInNames(), first.getTag(OSMTagKey.ADDR_STREET), null, l); + if (!idsOfStreet.isEmpty()) { + Building building = new Building(first); + building.setInterpolationInterval(interpolationInterval); + building.setInterpolationType(type); + building.setName(first.getTag(OSMTagKey.ADDR_HOUSE_NUMBER)); + building.setName2(second.getTag(OSMTagKey.ADDR_HOUSE_NUMBER)); + building.setLatLon2(second.getLatLon()); + streetDAO.writeBuilding(idsOfStreet, building); + } + } + } + } + } if (e.getTag(OSMTagKey.ADDR_HOUSE_NUMBER) != null && e.getTag(OSMTagKey.ADDR_STREET) != null) { boolean exist = streetDAO.findBuilding(e); if (!exist) { @@ -662,7 +707,26 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{ Set idsOfStreet = getStreetInCity(e.getIsInNames(), e.getTag(OSMTagKey.ADDR_STREET), null, l); if (!idsOfStreet.isEmpty()) { Building building = new Building(e); - building.setName(e.getTag(OSMTagKey.ADDR_HOUSE_NUMBER)); + String hno = e.getTag(OSMTagKey.ADDR_HOUSE_NUMBER); + int i = hno.indexOf('-'); + if(i != -1) { + building.setInterpolationInterval(1); + if(e.getTag(OSMTagKey.ADDR_INTERPOLATION) != null) { + try { + building.setInterpolationType(BuildingInterpolation.valueOf(e.getTag(OSMTagKey.ADDR_INTERPOLATION).toUpperCase())); + } catch (RuntimeException ex) { + try { + building.setInterpolationInterval(Integer.parseInt(e.getTag(OSMTagKey.ADDR_INTERPOLATION))); + } catch(NumberFormatException ex2) { + } + } + } + building.setName(hno.substring(0, i)); + building.setName2(hno.substring(i + 1)); + } else { + building.setName(hno); + } + streetDAO.writeBuilding(idsOfStreet, building); } } @@ -751,10 +815,10 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{ Map> cities = readCities(mapConnection); PreparedStatement streetstat = mapConnection.prepareStatement(// "SELECT A.id, A.name, A.name_en, A.latitude, A.longitude, "+ //$NON-NLS-1$ - "B.id, B.name, B.name_en, B.latitude, B.longitude, B.postcode, A.cityPart "+ //$NON-NLS-1$ + "B.id, B.name, B.name_en, B.latitude, B.longitude, B.postcode, A.cityPart, "+ //$NON-NLS-1$ + " B.name2, B.name_en2, B.lat2, B.lon2, B.interval, B.interpolateType " + "FROM street A left JOIN building B ON B.street = A.id JOIN city C ON A.city = C.id " + //$NON-NLS-1$ //with this order by we get the streets directly in city to not have the suffix if duplication - //TODO this order by might slow the query a little bit "WHERE A.city = ? ORDER BY C.name == A.cityPart DESC"); //$NON-NLS-1$ PreparedStatement waynodesStat = null; if (saveAddressWays) { @@ -772,7 +836,11 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{ villages.addAll(cities.get(t)); } if(t == CityType.SUBURB){ - suburbs.addAll(cities.get(t)); + for(City c : cities.get(t)){ + if(c.getIsInValue() != null) { + suburbs.add(c); + } + } } } @@ -949,7 +1017,7 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{ while (set.next()) { long streetId = set.getLong(1); if (!visitedStreets.containsKey(streetId)) { - Street street = new Street(null); + Street street = new Street(city); String streetName = set.getString(2); street.setLocation(set.getDouble(4), set.getDouble(5)); street.setId(streetId); @@ -982,6 +1050,20 @@ public class IndexAddressCreator extends AbstractIndexPartCreator{ b.setEnName(set.getString(8)); b.setLocation(set.getDouble(9), set.getDouble(10)); b.setPostcode(set.getString(11)); + b.setName2(set.getString(13)); + // no en name2 for now + b.setName2(set.getString(14)); + double lat2 = set.getDouble(15); + double lon2 = set.getDouble(16); + if(lat2 != 0 || lon2 != 0) { + b.setLatLon2(new LatLon(lat2, lon2)); + } + b.setInterpolationInterval(set.getInt(17)); + String type = set.getString(18); + if(type != null){ + b.setInterpolationType(BuildingInterpolation.valueOf(type)); + } + s.registerBuilding(b); } } diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java index 2fdd3773f8..e956691bc1 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexCreator.java @@ -629,8 +629,6 @@ public class IndexCreator { creator.setIndexAddress(true); creator.setIndexPOI(true); creator.setIndexTransport(true); - // for NL -// creator.setCityAdminLevel("10"); creator.recreateOnlyBinaryFile = false; creator.deleteDatabaseIndexes = true; @@ -640,18 +638,9 @@ public class IndexCreator { MapRenderingTypes rt = MapRenderingTypes.getDefault();// new MapRenderingTypes("/home/victor/projects/OsmAnd/data/testdata/roads_rendering_types.xml"); MapZooms zooms = MapZooms.getDefault(); // MapZooms.parseZooms("15-"); creator.setNodesDBFile(new File("/home/victor/projects/OsmAnd/data/osm-gen/nodes.tmp.odb")); -// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/mecklenburg-vorpommern.osm.pbf"), -// new ConsoleProgressImplementation(1), null, zooms, rt, log); - creator.generateIndexes(new File("/home/victor/projects/OsmAnd/download/RU-MOW.osm.bz2"), + creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/luxembourg.osm.pbf"), new ConsoleProgressImplementation(1), null, zooms, rt, log); -// creator.setNodesDBFile(new File("/home/victor/projects/OsmAnd/data/osm-gen/nodes3.tmp.odb")); -// creator.generateIndexes(new File("/home/victor/projects/OsmAnd/data/osm-maps/stadion-dynamo.osm"), -// new ConsoleProgressImplementation(1), null, MapZooms.getDefault(), log); - - - - // world generation // MapZooms mapZooms = new MapZooms(); diff --git a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java index 5819272b21..746eca76a1 100644 --- a/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java +++ b/DataExtractionOSM/src/net/osmand/data/preparation/IndexVectorMapCreator.java @@ -73,6 +73,8 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { private int zoomWaySmothness = 0; private final Log logMapDataWarn; + + private static long notUsedId = 1 << 40; // million million public IndexVectorMapCreator(Log logMapDataWarn, MapZooms mapZooms, MapRenderingTypes renderingTypes, int zoomWaySmothness) { this.logMapDataWarn = logMapDataWarn; @@ -84,7 +86,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } public void indexMapRelationsAndMultiPolygons(Entity e, OsmDbAccessorContext ctx) throws SQLException { - indexHighwayRestrictions(e, ctx); +// indexHighwayRestrictions(e, ctx); indexMultiPolygon(e, ctx); } @@ -152,14 +154,14 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { "Multipolygon id : " + e.getId() + ", inner node out id : " + nodeOut.getId()); //$NON-NLS-1$ } - List outerWay = new ArrayList(); + List outerWaySrc = new ArrayList(); List> innerWays = new ArrayList>(); TIntArrayList typeToSave = new TIntArrayList(typeUse); - long baseId = e.getId(); + long baseId = 0; for (List l : completedRings) { boolean innerType = "inner".equals(entities.get(l.get(0))); //$NON-NLS-1$ - if (!innerType && !outerWay.isEmpty()) { + if (!innerType && !outerWaySrc.isEmpty()) { logMapDataWarn.warn("Map bug: Multipoligon contains many 'outer' borders.\n" + //$NON-NLS-1$ "Multipolygon id : " + e.getId() + ", outer way id : " + l.get(0).getId()); //$NON-NLS-1$ return; @@ -169,17 +171,23 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { toCollect = new ArrayList(); innerWays.add(toCollect); } else { - toCollect = outerWay; + toCollect = outerWaySrc; } for (Way way : l) { toCollect.addAll(way.getNodes()); if (!innerType) { - baseId = way.getId(); + TIntArrayList out = multiPolygonsWays.put(way.getId(), typeToSave); + if(out == null){ + baseId = way.getId(); + } } - multiPolygonsWays.put(way.getId(), typeToSave); } } + if(baseId == 0){ + // use base id as well? + baseId = notUsedId ++; + } nextZoom: for (int level = 0; level < mapZooms.size(); level++) { renderingTypes.encodeEntityWithType(e, mapZooms.getLevel(level).getMaxZoom(), typeUse, addtypeUse, namesUse, tempNameUse); @@ -188,6 +196,7 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } long id = convertBaseIdToGeneratedId(baseId, level); // simplify route + List outerWay = outerWaySrc; int zoomToSimplify = mapZooms.getLevel(level).getMaxZoom() - 1; if (zoomToSimplify < 15) { outerWay = simplifyCycleWay(outerWay, zoomToSimplify); @@ -487,8 +496,10 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } boolean hasMulti = e instanceof Way && multiPolygonsWays.containsKey(e.getId()); if (hasMulti) { - TIntArrayList set = multiPolygonsWays.get(e.getId()); - typeUse.removeAll(set); + // avoid duplicate ids? +// TIntArrayList set = multiPolygonsWays.get(e.getId()); +// typeUse.removeAll(set); + continue; } if (typeUse.isEmpty()) { continue; @@ -538,18 +549,9 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { rtree.Node root = rtree.getReadNode(rootIndex); Rect rootBounds = calcBounds(root); if (rootBounds != null) { - boolean last = nodeIsLastSubTree(rtree, rootIndex); writer.startWriteMapLevelIndex(mapZooms.getLevel(i).getMinZoom(), mapZooms.getLevel(i).getMaxZoom(), rootBounds.getMinX(), rootBounds.getMaxX(), rootBounds.getMinY(), rootBounds.getMaxY()); - if (last) { - BinaryFileReference ref = writer.startMapTreeElement(rootBounds.getMinX(), rootBounds.getMaxX(), - rootBounds.getMinY(), rootBounds.getMaxY(), true); - bounds.put(rootIndex, ref); - } - writeBinaryMapTree(root, rtree, writer, bounds); - if (last) { - writer.endWriteMapTreeElement(); - } + writeBinaryMapTree(root, rootBounds, rtree, writer, bounds); writer.endWriteMapLevelIndex(); } @@ -655,12 +657,11 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { long ptr = ((NonLeafElement) e[i]).getPtr(); rtree.Node ns = r.getReadNode(ptr); writeBinaryMapBlock(ns, r, writer, selectData, bounds, tempStringTable, tempNames); - writer.endWriteMapTreeElement(); } } } - public void writeBinaryMapTree(rtree.Node parent, RTree r, BinaryMapIndexWriter writer, TLongObjectHashMap bounds) + public void writeBinaryMapTree(rtree.Node parent, Rect re, RTree r, BinaryMapIndexWriter writer, TLongObjectHashMap bounds) throws IOException, RTreeException { Element[] e = parent.getAllElements(); boolean containsLeaf = false; @@ -669,19 +670,17 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { containsLeaf = true; } } + BinaryFileReference ref = writer.startMapTreeElement(re.getMinX(), re.getMaxX(), re.getMinY(), re.getMaxY(), containsLeaf); + if (ref != null) { + bounds.put(parent.getNodeIndex(), ref); + } for (int i = 0; i < parent.getTotalElements(); i++) { - Rect re = e[i].getRect(); if (e[i].getElementType() != rtree.Node.LEAF_NODE) { - long ptr = ((NonLeafElement) e[i]).getPtr(); - rtree.Node ns = r.getReadNode(ptr); - BinaryFileReference ref = writer.startMapTreeElement(re.getMinX(), re.getMaxX(), re.getMinY(), re.getMaxY(), containsLeaf); - if (ref != null) { - bounds.put(ns.getNodeIndex(), ref); - } - writeBinaryMapTree(ns, r, writer, bounds); - writer.endWriteMapTreeElement(); + rtree.Node chNode = r.getReadNode(((NonLeafElement) e[i]).getPtr()); + writeBinaryMapTree(chNode, e[i].getRect(), r, writer, bounds); } } + writer.endWriteMapTreeElement(); } public Rect calcBounds(rtree.Node n) { @@ -757,9 +756,9 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { boolean first = true; long firstId = -1; long lastId = -1; - ByteArrayOutputStream bnodes = new ByteArrayOutputStream(); - ByteArrayOutputStream btypes = new ByteArrayOutputStream(); - ByteArrayOutputStream baddtypes = new ByteArrayOutputStream(); + ByteArrayOutputStream bNodes = new ByteArrayOutputStream(); + ByteArrayOutputStream bTypes = new ByteArrayOutputStream(); + ByteArrayOutputStream bAddtTypes = new ByteArrayOutputStream(); try { for (Node n : nodes) { if (n != null) { @@ -768,8 +767,8 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { first = false; } lastId = n.getId(); - Algoritms.writeInt(bnodes, Float.floatToRawIntBits((float) n.getLatitude())); - Algoritms.writeInt(bnodes, Float.floatToRawIntBits((float) n.getLongitude())); + Algoritms.writeInt(bNodes, Float.floatToRawIntBits((float) n.getLatitude())); + Algoritms.writeInt(bNodes, Float.floatToRawIntBits((float) n.getLongitude())); } } } catch (IOException e) { @@ -780,13 +779,13 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { } for (int j = 0; j < types.size(); j++) { try { - Algoritms.writeInt(btypes, types.get(j)); + Algoritms.writeInt(bTypes, types.get(j)); } catch (IOException e) { } } for (int j = 0; j < addTypes.size(); j++) { try { - Algoritms.writeInt(baddtypes, types.get(j)); + Algoritms.writeInt(bAddtTypes, addTypes.get(j)); } catch (IOException e) { } } @@ -794,9 +793,9 @@ public class IndexVectorMapCreator extends AbstractIndexPartCreator { mapLowLevelBinaryStat.setLong(2, firstId); mapLowLevelBinaryStat.setLong(3, lastId); mapLowLevelBinaryStat.setString(4, name); - mapLowLevelBinaryStat.setBytes(5, bnodes.toByteArray()); - mapLowLevelBinaryStat.setBytes(6, btypes.toByteArray()); - mapLowLevelBinaryStat.setBytes(7, baddtypes.toByteArray()); + mapLowLevelBinaryStat.setBytes(5, bNodes.toByteArray()); + mapLowLevelBinaryStat.setBytes(6, bTypes.toByteArray()); + mapLowLevelBinaryStat.setBytes(7, bAddtTypes.toByteArray()); mapLowLevelBinaryStat.setShort(8, (short) level); addBatch(mapLowLevelBinaryStat); diff --git a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java index 0fe2abc960..73140fdc50 100644 --- a/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java +++ b/DataExtractionOSM/src/net/osmand/osm/MapRenderingTypes.java @@ -101,10 +101,16 @@ public class MapRenderingTypes { rt.id = types.size(); String keyVal = constructRuleKey(tag, val); if(types.containsKey(keyVal)){ - throw new RuntimeException("Duplicate " + keyVal); + if(types.get(keyVal).nameCreated ) { + rt.id = types.get(keyVal).id; + types.put(keyVal, rt); + } else { + throw new RuntimeException("Duplicate " + keyVal); + } + } else { + types.put(keyVal, rt); + typeList.add(rt); } - types.put(keyVal, rt); - typeList.add(rt); } public MapRulType getNameRuleType() { @@ -282,6 +288,7 @@ public class MapRenderingTypes { mt = new MapRulType(); mt.tag = names[i]; mt.additional = true; + mt.nameCreated = true; registerRuleType(names[i], null, mt); } rtype.names[i] = mt; @@ -411,6 +418,7 @@ public class MapRenderingTypes { int minzoom; boolean additional; MapRulType targetTagValue; + boolean nameCreated; // inner id private int id; diff --git a/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java b/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java index 163236fe41..674b17ab28 100644 --- a/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java +++ b/DataExtractionOSM/src/net/osmand/osm/OSMSettings.java @@ -31,7 +31,7 @@ public class OSMSettings { ADDR_STREET("addr:street"), //$NON-NLS-1$ ADDR_CITY("addr:city"), //$NON-NLS-1$ ADDR_POSTCODE("addr:postcode"), //$NON-NLS-1$ - + ADDR_INTERPOLATION("addr:interpolation"), //$NON-NLS-1$ ADDRESS_TYPE("address:type"), //$NON-NLS-1$ ADDRESS_HOUSE("address:house"), //$NON-NLS-1$ TYPE("type"), //$NON-NLS-1$ diff --git a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml index 3be3835e93..379d165fa2 100644 --- a/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml +++ b/DataExtractionOSM/src/net/osmand/osm/rendering_types.xml @@ -537,13 +537,6 @@ - - - - - - - diff --git a/DataExtractionOSM/src/osmand_odb.proto b/DataExtractionOSM/src/osmand_odb.proto index 5580f94de3..b467c1e33a 100644 --- a/DataExtractionOSM/src/osmand_odb.proto +++ b/DataExtractionOSM/src/osmand_odb.proto @@ -132,7 +132,13 @@ message MapDataBlock { // in future here can be optional raster tile repeated MapData dataObjects = 12; + optional uint32 rasterType = 13; + + optional bytes rasterImage = 14; + optional StringTable stringTable = 15; + + }