Preserve space for name indexes
This commit is contained in:
parent
c5179ada99
commit
068a15d7cc
4 changed files with 299 additions and 103 deletions
|
@ -806,6 +806,27 @@ public class BinaryMapIndexWriter {
|
|||
codedOutStream.writeMessage(OsmandOdb.OsmAndPoiBox.CATEGORIES_FIELD_NUMBER, builder.build());
|
||||
}
|
||||
|
||||
public void writePoiIncludedStrings(Set<String> includes) throws IOException {
|
||||
checkPeekState(POI_BOX);
|
||||
OsmandOdb.IndexedStringTable.Builder builder = OsmandOdb.IndexedStringTable.newBuilder();
|
||||
for(String s : includes){
|
||||
builder.addKey(s);
|
||||
}
|
||||
codedOutStream.writeMessage(OsmandOdb.OsmAndPoiBox.INCLUDENAMESLIST_FIELD_NUMBER, builder.build());
|
||||
}
|
||||
|
||||
public void writePoiExcludedStrings(Set<String> parentNames, Set<String> includes) throws IOException {
|
||||
checkPeekState(POI_BOX);
|
||||
OsmandOdb.IndexedStringTable.Builder builder = OsmandOdb.IndexedStringTable.newBuilder();
|
||||
for(String s : parentNames){
|
||||
if(!includes.contains(s)){
|
||||
builder.addKey(s);
|
||||
}
|
||||
}
|
||||
codedOutStream.writeMessage(OsmandOdb.OsmAndPoiBox.EXCLUDENAMESLIST_FIELD_NUMBER, builder.build());
|
||||
|
||||
}
|
||||
|
||||
public void writePoiDataAtom(long id, int x24shift, int y24shift, String nameEn, String name, TIntArrayList types, String openingHours,
|
||||
String site, String phone) throws IOException {
|
||||
checkPeekState(POI_DATA);
|
||||
|
@ -931,5 +952,7 @@ public class BinaryMapIndexWriter {
|
|||
codedOutStream.flush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12020,20 +12020,32 @@ public final class OsmandOdb {
|
|||
public boolean hasPrefix() { return hasPrefix; }
|
||||
public java.lang.String getPrefix() { return prefix_; }
|
||||
|
||||
// repeated string s = 3;
|
||||
public static final int S_FIELD_NUMBER = 3;
|
||||
private java.util.List<java.lang.String> s_ =
|
||||
// repeated string key = 3;
|
||||
public static final int KEY_FIELD_NUMBER = 3;
|
||||
private java.util.List<java.lang.String> key_ =
|
||||
java.util.Collections.emptyList();
|
||||
public java.util.List<java.lang.String> getSList() {
|
||||
return s_;
|
||||
public java.util.List<java.lang.String> getKeyList() {
|
||||
return key_;
|
||||
}
|
||||
public int getSCount() { return s_.size(); }
|
||||
public java.lang.String getS(int index) {
|
||||
return s_.get(index);
|
||||
public int getKeyCount() { return key_.size(); }
|
||||
public java.lang.String getKey(int index) {
|
||||
return key_.get(index);
|
||||
}
|
||||
|
||||
// repeated .IndexedStringTable subtables = 6;
|
||||
public static final int SUBTABLES_FIELD_NUMBER = 6;
|
||||
// repeated uint32 val = 4;
|
||||
public static final int VAL_FIELD_NUMBER = 4;
|
||||
private java.util.List<java.lang.Integer> val_ =
|
||||
java.util.Collections.emptyList();
|
||||
public java.util.List<java.lang.Integer> getValList() {
|
||||
return val_;
|
||||
}
|
||||
public int getValCount() { return val_.size(); }
|
||||
public int getVal(int index) {
|
||||
return val_.get(index);
|
||||
}
|
||||
|
||||
// repeated .IndexedStringTable subtables = 5;
|
||||
public static final int SUBTABLES_FIELD_NUMBER = 5;
|
||||
private java.util.List<net.osmand.binary.OsmandOdb.IndexedStringTable> subtables_ =
|
||||
java.util.Collections.emptyList();
|
||||
public java.util.List<net.osmand.binary.OsmandOdb.IndexedStringTable> getSubtablesList() {
|
||||
|
@ -12056,11 +12068,14 @@ public final class OsmandOdb {
|
|||
if (hasPrefix()) {
|
||||
output.writeString(1, getPrefix());
|
||||
}
|
||||
for (java.lang.String element : getSList()) {
|
||||
for (java.lang.String element : getKeyList()) {
|
||||
output.writeString(3, element);
|
||||
}
|
||||
for (int element : getValList()) {
|
||||
output.writeUInt32(4, element);
|
||||
}
|
||||
for (net.osmand.binary.OsmandOdb.IndexedStringTable element : getSubtablesList()) {
|
||||
output.writeMessage(6, element);
|
||||
output.writeMessage(5, element);
|
||||
}
|
||||
getUnknownFields().writeTo(output);
|
||||
}
|
||||
|
@ -12077,16 +12092,25 @@ public final class OsmandOdb {
|
|||
}
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (java.lang.String element : getSList()) {
|
||||
for (java.lang.String element : getKeyList()) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream
|
||||
.computeStringSizeNoTag(element);
|
||||
}
|
||||
size += dataSize;
|
||||
size += 1 * getSList().size();
|
||||
size += 1 * getKeyList().size();
|
||||
}
|
||||
{
|
||||
int dataSize = 0;
|
||||
for (int element : getValList()) {
|
||||
dataSize += com.google.protobuf.CodedOutputStream
|
||||
.computeUInt32SizeNoTag(element);
|
||||
}
|
||||
size += dataSize;
|
||||
size += 1 * getValList().size();
|
||||
}
|
||||
for (net.osmand.binary.OsmandOdb.IndexedStringTable element : getSubtablesList()) {
|
||||
size += com.google.protobuf.CodedOutputStream
|
||||
.computeMessageSize(6, element);
|
||||
.computeMessageSize(5, element);
|
||||
}
|
||||
size += getUnknownFields().getSerializedSize();
|
||||
memoizedSerializedSize = size;
|
||||
|
@ -12230,9 +12254,13 @@ public final class OsmandOdb {
|
|||
throw new IllegalStateException(
|
||||
"build() has already been called on this Builder.");
|
||||
}
|
||||
if (result.s_ != java.util.Collections.EMPTY_LIST) {
|
||||
result.s_ =
|
||||
java.util.Collections.unmodifiableList(result.s_);
|
||||
if (result.key_ != java.util.Collections.EMPTY_LIST) {
|
||||
result.key_ =
|
||||
java.util.Collections.unmodifiableList(result.key_);
|
||||
}
|
||||
if (result.val_ != java.util.Collections.EMPTY_LIST) {
|
||||
result.val_ =
|
||||
java.util.Collections.unmodifiableList(result.val_);
|
||||
}
|
||||
if (result.subtables_ != java.util.Collections.EMPTY_LIST) {
|
||||
result.subtables_ =
|
||||
|
@ -12257,11 +12285,17 @@ public final class OsmandOdb {
|
|||
if (other.hasPrefix()) {
|
||||
setPrefix(other.getPrefix());
|
||||
}
|
||||
if (!other.s_.isEmpty()) {
|
||||
if (result.s_.isEmpty()) {
|
||||
result.s_ = new java.util.ArrayList<java.lang.String>();
|
||||
if (!other.key_.isEmpty()) {
|
||||
if (result.key_.isEmpty()) {
|
||||
result.key_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
result.s_.addAll(other.s_);
|
||||
result.key_.addAll(other.key_);
|
||||
}
|
||||
if (!other.val_.isEmpty()) {
|
||||
if (result.val_.isEmpty()) {
|
||||
result.val_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
}
|
||||
result.val_.addAll(other.val_);
|
||||
}
|
||||
if (!other.subtables_.isEmpty()) {
|
||||
if (result.subtables_.isEmpty()) {
|
||||
|
@ -12299,10 +12333,23 @@ public final class OsmandOdb {
|
|||
break;
|
||||
}
|
||||
case 26: {
|
||||
addS(input.readString());
|
||||
addKey(input.readString());
|
||||
break;
|
||||
}
|
||||
case 50: {
|
||||
case 32: {
|
||||
addVal(input.readUInt32());
|
||||
break;
|
||||
}
|
||||
case 34: {
|
||||
int length = input.readRawVarint32();
|
||||
int limit = input.pushLimit(length);
|
||||
while (input.getBytesUntilLimit() > 0) {
|
||||
addVal(input.readUInt32());
|
||||
}
|
||||
input.popLimit(limit);
|
||||
break;
|
||||
}
|
||||
case 42: {
|
||||
net.osmand.binary.OsmandOdb.IndexedStringTable.Builder subBuilder = net.osmand.binary.OsmandOdb.IndexedStringTable.newBuilder();
|
||||
input.readMessage(subBuilder, extensionRegistry);
|
||||
addSubtables(subBuilder.buildPartial());
|
||||
|
@ -12334,47 +12381,81 @@ public final class OsmandOdb {
|
|||
return this;
|
||||
}
|
||||
|
||||
// repeated string s = 3;
|
||||
public java.util.List<java.lang.String> getSList() {
|
||||
return java.util.Collections.unmodifiableList(result.s_);
|
||||
// repeated string key = 3;
|
||||
public java.util.List<java.lang.String> getKeyList() {
|
||||
return java.util.Collections.unmodifiableList(result.key_);
|
||||
}
|
||||
public int getSCount() {
|
||||
return result.getSCount();
|
||||
public int getKeyCount() {
|
||||
return result.getKeyCount();
|
||||
}
|
||||
public java.lang.String getS(int index) {
|
||||
return result.getS(index);
|
||||
public java.lang.String getKey(int index) {
|
||||
return result.getKey(index);
|
||||
}
|
||||
public Builder setS(int index, java.lang.String value) {
|
||||
public Builder setKey(int index, java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
result.s_.set(index, value);
|
||||
result.key_.set(index, value);
|
||||
return this;
|
||||
}
|
||||
public Builder addS(java.lang.String value) {
|
||||
public Builder addKey(java.lang.String value) {
|
||||
if (value == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if (result.s_.isEmpty()) {
|
||||
result.s_ = new java.util.ArrayList<java.lang.String>();
|
||||
if (result.key_.isEmpty()) {
|
||||
result.key_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
result.s_.add(value);
|
||||
result.key_.add(value);
|
||||
return this;
|
||||
}
|
||||
public Builder addAllS(
|
||||
public Builder addAllKey(
|
||||
java.lang.Iterable<? extends java.lang.String> values) {
|
||||
if (result.s_.isEmpty()) {
|
||||
result.s_ = new java.util.ArrayList<java.lang.String>();
|
||||
if (result.key_.isEmpty()) {
|
||||
result.key_ = new java.util.ArrayList<java.lang.String>();
|
||||
}
|
||||
super.addAll(values, result.s_);
|
||||
super.addAll(values, result.key_);
|
||||
return this;
|
||||
}
|
||||
public Builder clearS() {
|
||||
result.s_ = java.util.Collections.emptyList();
|
||||
public Builder clearKey() {
|
||||
result.key_ = java.util.Collections.emptyList();
|
||||
return this;
|
||||
}
|
||||
|
||||
// repeated .IndexedStringTable subtables = 6;
|
||||
// repeated uint32 val = 4;
|
||||
public java.util.List<java.lang.Integer> getValList() {
|
||||
return java.util.Collections.unmodifiableList(result.val_);
|
||||
}
|
||||
public int getValCount() {
|
||||
return result.getValCount();
|
||||
}
|
||||
public int getVal(int index) {
|
||||
return result.getVal(index);
|
||||
}
|
||||
public Builder setVal(int index, int value) {
|
||||
result.val_.set(index, value);
|
||||
return this;
|
||||
}
|
||||
public Builder addVal(int value) {
|
||||
if (result.val_.isEmpty()) {
|
||||
result.val_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
}
|
||||
result.val_.add(value);
|
||||
return this;
|
||||
}
|
||||
public Builder addAllVal(
|
||||
java.lang.Iterable<? extends java.lang.Integer> values) {
|
||||
if (result.val_.isEmpty()) {
|
||||
result.val_ = new java.util.ArrayList<java.lang.Integer>();
|
||||
}
|
||||
super.addAll(values, result.val_);
|
||||
return this;
|
||||
}
|
||||
public Builder clearVal() {
|
||||
result.val_ = java.util.Collections.emptyList();
|
||||
return this;
|
||||
}
|
||||
|
||||
// repeated .IndexedStringTable subtables = 5;
|
||||
public java.util.List<net.osmand.binary.OsmandOdb.IndexedStringTable> getSubtablesList() {
|
||||
return java.util.Collections.unmodifiableList(result.subtables_);
|
||||
}
|
||||
|
@ -15192,26 +15273,26 @@ public final class OsmandOdb {
|
|||
"me\030\001 \002(\t\022\"\n\nboundaries\030\002 \002(\0132\016.OsmAndTil" +
|
||||
"eBox\022-\n\017categoriesTable\030\003 \003(\0132\024.OsmAndCa",
|
||||
"tegoryTable\022\034\n\005boxes\030\006 \003(\0132\r.OsmAndPoiBo" +
|
||||
"x\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBoxData\"W\n" +
|
||||
"\022IndexedStringTable\022\016\n\006prefix\030\001 \001(\t\022\t\n\001s" +
|
||||
"\030\003 \003(\t\022&\n\tsubtables\030\006 \003(\0132\023.IndexedStrin" +
|
||||
"gTable\">\n\023OsmAndCategoryTable\022\020\n\010categor" +
|
||||
"y\030\001 \002(\t\022\025\n\rsubcategories\030\003 \003(\t\"\365\001\n\014OsmAn" +
|
||||
"dPoiBox\022\014\n\004zoom\030\001 \002(\r\022\014\n\004left\030\002 \002(\021\022\013\n\003t" +
|
||||
"op\030\003 \002(\021\022(\n\ncategories\030\004 \001(\0132\024.OsmAndPoi" +
|
||||
"Categories\022-\n\020includeNamesList\030\005 \001(\0132\023.I" +
|
||||
"ndexedStringTable\022-\n\020excludeNamesList\030\006 ",
|
||||
"\001(\0132\023.IndexedStringTable\022\037\n\010subBoxes\030\n \003" +
|
||||
"(\0132\r.OsmAndPoiBox\022\023\n\013shiftToData\030\016 \001(\007\")" +
|
||||
"\n\023OsmAndPoiCategories\022\022\n\ncategories\030\003 \003(" +
|
||||
"\r\"^\n\020OsmAndPoiBoxData\022\014\n\004zoom\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.Osm" +
|
||||
"AndPoiBoxDataAtom\"\255\001\n\024OsmAndPoiBoxDataAt" +
|
||||
"om\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\006nameEn\030\007 \001(\t\022\n\n\002" +
|
||||
"id\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"
|
||||
"x\022\"\n\007poiData\030\t \003(\0132\021.OsmAndPoiBoxData\"f\n" +
|
||||
"\022IndexedStringTable\022\016\n\006prefix\030\001 \001(\t\022\013\n\003k" +
|
||||
"ey\030\003 \003(\t\022\013\n\003val\030\004 \003(\r\022&\n\tsubtables\030\005 \003(\013" +
|
||||
"2\023.IndexedStringTable\">\n\023OsmAndCategoryT" +
|
||||
"able\022\020\n\010category\030\001 \002(\t\022\025\n\rsubcategories\030" +
|
||||
"\003 \003(\t\"\365\001\n\014OsmAndPoiBox\022\014\n\004zoom\030\001 \002(\r\022\014\n\004" +
|
||||
"left\030\002 \002(\021\022\013\n\003top\030\003 \002(\021\022(\n\ncategories\030\004 " +
|
||||
"\001(\0132\024.OsmAndPoiCategories\022-\n\020includeName" +
|
||||
"sList\030\005 \001(\0132\023.IndexedStringTable\022-\n\020excl",
|
||||
"udeNamesList\030\006 \001(\0132\023.IndexedStringTable\022" +
|
||||
"\037\n\010subBoxes\030\n \003(\0132\r.OsmAndPoiBox\022\023\n\013shif" +
|
||||
"tToData\030\016 \001(\007\")\n\023OsmAndPoiCategories\022\022\n\n" +
|
||||
"categories\030\003 \003(\r\"^\n\020OsmAndPoiBoxData\022\014\n\004" +
|
||||
"zoom\030\001 \001(\r\022\t\n\001x\030\002 \001(\r\022\t\n\001y\030\003 \001(\r\022&\n\007poiD" +
|
||||
"ata\030\005 \003(\0132\025.OsmAndPoiBoxDataAtom\"\255\001\n\024Osm" +
|
||||
"AndPoiBoxDataAtom\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\006n" +
|
||||
"ameEn\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\004no",
|
||||
"te\030\r \001(\tB\023\n\021net.osmand.binary"
|
||||
};
|
||||
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
|
||||
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
|
||||
|
@ -15415,7 +15496,7 @@ public final class OsmandOdb {
|
|||
internal_static_IndexedStringTable_fieldAccessorTable = new
|
||||
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
|
||||
internal_static_IndexedStringTable_descriptor,
|
||||
new java.lang.String[] { "Prefix", "S", "Subtables", },
|
||||
new java.lang.String[] { "Prefix", "Key", "Val", "Subtables", },
|
||||
net.osmand.binary.OsmandOdb.IndexedStringTable.class,
|
||||
net.osmand.binary.OsmandOdb.IndexedStringTable.Builder.class);
|
||||
internal_static_OsmAndCategoryTable_descriptor =
|
||||
|
|
|
@ -49,6 +49,9 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
private static final int ZOOM_TO_SAVE_START = 6;
|
||||
private static final int ZOOM_TO_WRITE_CATEGORIES_START = 12;
|
||||
private static final int ZOOM_TO_WRITE_CATEGORIES_END = 16;
|
||||
private static final int ZOOM_TO_WRITE_NAME_START = 9;
|
||||
private static final int ZOOM_TO_WRITE_NAME_END = 11;
|
||||
private boolean useInMemoryCreator = true;
|
||||
|
||||
|
||||
private List<Amenity> tempAmenityList = new ArrayList<Amenity>();
|
||||
|
@ -193,7 +196,12 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
collator.setStrength(Collator.PRIMARY);
|
||||
|
||||
// 0. process all entities
|
||||
ResultSet rs = poiConnection.createStatement().executeQuery("SELECT x,y,name,name_en,type,subtype from poi");
|
||||
ResultSet rs;
|
||||
if(useInMemoryCreator) {
|
||||
rs = poiConnection.createStatement().executeQuery("SELECT x,y,name,name_en,type,subtype, id, opening_hours, site, phone from poi");
|
||||
} else {
|
||||
rs = poiConnection.createStatement().executeQuery("SELECT x,y,name,name_en,type,subtype from poi");
|
||||
}
|
||||
int zoomToStart = ZOOM_TO_SAVE_START;
|
||||
Tree<PoiBox> rootZoomsTree = new Tree<PoiBox>();
|
||||
rootZoomsTree.setNode(new PoiBox());
|
||||
|
@ -247,6 +255,24 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
|
||||
prevTree = subtree;
|
||||
}
|
||||
if (useInMemoryCreator) {
|
||||
if (prevTree.getNode().poiData == null) {
|
||||
prevTree.getNode().poiData = new ArrayList<PoiData>();
|
||||
}
|
||||
PoiData poiData = new PoiData();
|
||||
poiData.x = x;
|
||||
poiData.y = y;
|
||||
poiData.name = name;
|
||||
poiData.nameEn = nameEn;
|
||||
poiData.type = type;
|
||||
poiData.subtype = subtype;
|
||||
poiData.id = rs.getLong(7);
|
||||
poiData.openingHours = rs.getString(8);
|
||||
poiData.site = rs.getString(9);
|
||||
poiData.phone = rs.getString(10);
|
||||
prevTree.getNode().poiData.add(poiData);
|
||||
|
||||
}
|
||||
}
|
||||
log.info("Poi processing finishied");
|
||||
// Finish process all entities
|
||||
|
@ -280,7 +306,7 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
// 3.2 write tree using stack
|
||||
Map<PoiBox, Long> fpToWriteSeeks = new LinkedHashMap<PoiBox, Long>();
|
||||
for (Tree<PoiBox> subs : rootZoomsTree.getSubtrees()) {
|
||||
writePoiBoxes(writer, subs, fpToWriteSeeks, categories, catIndexes);
|
||||
writePoiBoxes(writer, subs, fpToWriteSeeks, categories, catIndexes, rootZoomsTree.getNode().startsName);
|
||||
}
|
||||
|
||||
// 4. write poi data
|
||||
|
@ -295,34 +321,50 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
int y = entry.getKey().y;
|
||||
writer.startWritePoiData(z, x, y, startFpPoiIndex, entry.getValue());
|
||||
|
||||
prepareStatement.setInt(1, x << (31 - z));
|
||||
prepareStatement.setInt(2, (x + 1) << (31 - z));
|
||||
prepareStatement.setInt(3, y << (31 - z));
|
||||
prepareStatement.setInt(4, (y + 1) << (31 - z));
|
||||
rs = prepareStatement.executeQuery();
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
int x31 = rs.getInt(2);
|
||||
int y31 = rs.getInt(3);
|
||||
int x24shift = (x31 >> 7) - (x << (24 - z));
|
||||
int y24shift = (y31 >> 7) - (y << (24 - z));
|
||||
String nameEn = rs.getString(4);
|
||||
String name = rs.getString(5);
|
||||
String type = rs.getString(6);
|
||||
String subtype = rs.getString(7);
|
||||
types.clear();
|
||||
buildTypeIds(type, subtype, categories, catIndexes, types);
|
||||
if(useInMemoryCreator){
|
||||
List<PoiData> poiData = entry.getKey().poiData;
|
||||
|
||||
for(PoiData poi : poiData){
|
||||
int x31 = poi.x;
|
||||
int y31 = poi.y;
|
||||
String type = poi.type;
|
||||
String subtype = poi.subtype;
|
||||
types.clear();
|
||||
buildTypeIds(type, subtype, categories, catIndexes, types);
|
||||
int x24shift = (x31 >> 7) - (x << (24 - z));
|
||||
int y24shift = (y31 >> 7) - (y << (24 - z));
|
||||
writer.writePoiDataAtom(poi.id, x24shift, y24shift, poi.nameEn, poi.name, types, poi.openingHours, poi.site, poi.phone);
|
||||
}
|
||||
|
||||
} else {
|
||||
prepareStatement.setInt(1, x << (31 - z));
|
||||
prepareStatement.setInt(2, (x + 1) << (31 - z));
|
||||
prepareStatement.setInt(3, y << (31 - z));
|
||||
prepareStatement.setInt(4, (y + 1) << (31 - z));
|
||||
ResultSet rset = prepareStatement.executeQuery();
|
||||
while (rset.next()) {
|
||||
long id = rset.getLong(1);
|
||||
int x31 = rset.getInt(2);
|
||||
int y31 = rset.getInt(3);
|
||||
int x24shift = (x31 >> 7) - (x << (24 - z));
|
||||
int y24shift = (y31 >> 7) - (y << (24 - z));
|
||||
String nameEn = rset.getString(4);
|
||||
String name = rset.getString(5);
|
||||
String type = rset.getString(6);
|
||||
String subtype = rset.getString(7);
|
||||
|
||||
String openingHours = rs.getString(8);
|
||||
String site = rs.getString(9);
|
||||
String phone = rs.getString(10);
|
||||
types.clear();
|
||||
buildTypeIds(type, subtype, categories, catIndexes, types);
|
||||
|
||||
writer.writePoiDataAtom(id, x24shift, y24shift, nameEn, name, types, openingHours, site, phone);
|
||||
String openingHours = rset.getString(8);
|
||||
String site = rset.getString(9);
|
||||
String phone = rset.getString(10);
|
||||
|
||||
writer.writePoiDataAtom(id, x24shift, y24shift, nameEn, name, types, openingHours, site, phone);
|
||||
}
|
||||
rset.close();
|
||||
}
|
||||
writer.endWritePoiData();
|
||||
rs.close();
|
||||
|
||||
}
|
||||
|
||||
prepareStatement.close();
|
||||
|
@ -332,7 +374,8 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
}
|
||||
|
||||
private void writePoiBoxes(BinaryMapIndexWriter writer, Tree<PoiBox> tree, Map<PoiBox, Long> fpToWriteSeeks,
|
||||
Map<String, Map<String, Integer>> categories, Map<String, Integer> catIndexes) throws IOException, SQLException {
|
||||
Map<String, Map<String, Integer>> categories, Map<String, Integer> catIndexes,
|
||||
Set<String> parentNames) throws IOException, SQLException {
|
||||
int x = tree.getNode().x;
|
||||
int y = tree.getNode().y;
|
||||
int zoom = tree.getNode().zoom;
|
||||
|
@ -348,10 +391,22 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
}
|
||||
writer.writePOICategories(types);
|
||||
}
|
||||
if(zoom >= ZOOM_TO_WRITE_NAME_START && zoom <= ZOOM_TO_WRITE_NAME_END){
|
||||
Set<String> names = tree.getNode().startsName;
|
||||
if (names.size() > 0) {
|
||||
if (zoom == ZOOM_TO_WRITE_NAME_START || parentNames.size() - names.size() > names.size()) {
|
||||
System.out.println("I" + names.size() + " " + zoom);
|
||||
writer.writePoiIncludedStrings(names);
|
||||
} else {
|
||||
System.out.println("E" + (parentNames.size() - names.size()) + " " + zoom);
|
||||
writer.writePoiExcludedStrings(parentNames, names);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!end) {
|
||||
for (Tree<PoiBox> subTree : tree.getSubtrees()) {
|
||||
writePoiBoxes(writer, subTree, fpToWriteSeeks, categories, catIndexes);
|
||||
writePoiBoxes(writer, subTree, fpToWriteSeeks, categories, catIndexes, tree.getNode().startsName);
|
||||
}
|
||||
} else {
|
||||
fpToWriteSeeks.put(tree.getNode(), fp);
|
||||
|
@ -359,12 +414,26 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
writer.endWritePoiBox();
|
||||
}
|
||||
|
||||
private static class PoiData {
|
||||
int x;
|
||||
int y;
|
||||
String name;
|
||||
String nameEn;
|
||||
String type;
|
||||
String subtype;
|
||||
long id;
|
||||
String openingHours;
|
||||
String phone;
|
||||
String site;
|
||||
}
|
||||
|
||||
private static class PoiBox {
|
||||
int x;
|
||||
int y;
|
||||
int zoom;
|
||||
Map<String, Map<String, Integer>> categories = new LinkedHashMap<String, Map<String, Integer>>();
|
||||
Set<String> startsName = new TreeSet<String>();
|
||||
List<PoiData> poiData = null;
|
||||
|
||||
private void addCategory(String cat, String subCat){
|
||||
if(!categories.containsKey(cat)){
|
||||
|
@ -385,8 +454,29 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
if(Algoritms.isEmpty(nameEn)){
|
||||
nameEn = Junidecode.unidecode(name);
|
||||
}
|
||||
// TODO split by 3 characters and save here
|
||||
|
||||
parsePrefix(name);
|
||||
parsePrefix(nameEn);
|
||||
}
|
||||
|
||||
private void parsePrefix(String name) {
|
||||
int prev = -1;
|
||||
for (int i = 0; i <= name.length(); i++) {
|
||||
if (i == name.length() || (!Character.isLetter(name.charAt(i)) &&
|
||||
!Character.isDigit(name.charAt(i)))) {
|
||||
if (prev != -1) {
|
||||
String substr = name.substring(prev, i);
|
||||
if (substr.length() > 3) {
|
||||
substr = substr.substring(0, 3);
|
||||
}
|
||||
startsName.add(substr.toLowerCase());
|
||||
prev = -1;
|
||||
}
|
||||
} else {
|
||||
if(prev == -1){
|
||||
prev = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -460,10 +550,10 @@ public class IndexPoiCreator extends AbstractIndexPartCreator {
|
|||
// TODO support cancelling poi search request! Do it in another thread
|
||||
long time = System.currentTimeMillis();
|
||||
IndexPoiCreator poiCreator = new IndexPoiCreator();
|
||||
// String fileSqlte = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Ru-mow.poi.odb";
|
||||
// String outFile = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Ru-mow.poi.obf";
|
||||
String fileSqlte = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Netherlands_europe.poi.odb";
|
||||
String outFile = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Netherlands.poi.obf";
|
||||
String fileSqlte = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Ru-mow.poi.odb";
|
||||
String outFile = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Ru-mow.poi.obf";
|
||||
// String fileSqlte = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Netherlands_europe.poi.odb";
|
||||
// String outFile = "/home/victor/projects/OsmAnd/data/osm-gen/POI/Netherlands.poi.obf";
|
||||
|
||||
poiCreator.poiConnection = (Connection) DBDialect.SQLITE.getDatabaseConnection(
|
||||
fileSqlte, log);
|
||||
|
|
|
@ -288,12 +288,14 @@ message IndexedStringTable {
|
|||
// common prefix for all strings inside
|
||||
optional string prefix = 1;
|
||||
|
||||
repeated string s = 3;
|
||||
|
||||
// subtables are supposed to make search faster
|
||||
// instead of searching through all strings
|
||||
// key, val and subtables are mixed and order is preserved by key (ascending)
|
||||
// so that's example of data : key1,val1,subtables1,key2,val2,key3,val3,subtables3,subtables3
|
||||
repeated string key = 3;
|
||||
// the shift to the data or one uint data itself
|
||||
repeated uint32 val = 4;
|
||||
// subtables are supposed to make search faster instead of searching through all strings
|
||||
// it's enought to read prefix in the header
|
||||
repeated IndexedStringTable subtables = 6;
|
||||
repeated IndexedStringTable subtables = 5;
|
||||
}
|
||||
|
||||
message OsmAndCategoryTable {
|
||||
|
|
Loading…
Reference in a new issue