Fix labelx, labely
This commit is contained in:
parent
8c8f83c5d0
commit
6f48ca6cbb
2 changed files with 46 additions and 66 deletions
|
@ -19,7 +19,8 @@ public class BinaryMapDataObject {
|
||||||
protected int[] types = null;
|
protected int[] types = null;
|
||||||
protected int[] additionalTypes = null;
|
protected int[] additionalTypes = null;
|
||||||
protected int objectType = RenderingRulesStorage.POINT_RULES;
|
protected int objectType = RenderingRulesStorage.POINT_RULES;
|
||||||
protected int[] labelCoordinates = null;
|
protected int labelX;
|
||||||
|
protected int labelY;
|
||||||
|
|
||||||
protected TIntObjectHashMap<String> objectNames = null;
|
protected TIntObjectHashMap<String> objectNames = null;
|
||||||
protected TIntArrayList namesOrder = null;
|
protected TIntArrayList namesOrder = null;
|
||||||
|
@ -34,7 +35,7 @@ public class BinaryMapDataObject {
|
||||||
|
|
||||||
|
|
||||||
public BinaryMapDataObject(long id, int[] coordinates, int[][] polygonInnerCoordinates, int objectType, boolean area,
|
public BinaryMapDataObject(long id, int[] coordinates, int[][] polygonInnerCoordinates, int objectType, boolean area,
|
||||||
int[] types, int[] additionalTypes, int[] labelCoordinates){
|
int[] types, int[] additionalTypes, int labelX, int labelY){
|
||||||
this.polygonInnerCoordinates = polygonInnerCoordinates;
|
this.polygonInnerCoordinates = polygonInnerCoordinates;
|
||||||
this.coordinates = coordinates;
|
this.coordinates = coordinates;
|
||||||
this.additionalTypes = additionalTypes;
|
this.additionalTypes = additionalTypes;
|
||||||
|
@ -42,7 +43,8 @@ public class BinaryMapDataObject {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.objectType = objectType;
|
this.objectType = objectType;
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.labelCoordinates = labelCoordinates;
|
this.labelX = labelX;
|
||||||
|
this.labelY = labelY;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setCoordinates(int[] coordinates) {
|
protected void setCoordinates(int[] coordinates) {
|
||||||
|
@ -204,79 +206,80 @@ public class BinaryMapDataObject {
|
||||||
&& this.id == thatObj.id
|
&& this.id == thatObj.id
|
||||||
&& this.area == thatObj.area
|
&& this.area == thatObj.area
|
||||||
&& compareCoordinates(this.coordinates, thatObj.coordinates, coordinatesPrecision) ) {
|
&& compareCoordinates(this.coordinates, thatObj.coordinates, coordinatesPrecision) ) {
|
||||||
if(mapIndex == null) {
|
if (mapIndex == null) {
|
||||||
throw new IllegalStateException("Illegal binary object: " + id);
|
throw new IllegalStateException("Illegal binary object: " + id);
|
||||||
}
|
}
|
||||||
if(thatObj.mapIndex == null) {
|
if (thatObj.mapIndex == null) {
|
||||||
throw new IllegalStateException("Illegal binary object: " + thatObj.id);
|
throw new IllegalStateException("Illegal binary object: " + thatObj.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean equals = true;
|
boolean equals = true;
|
||||||
if(equals) {
|
if (equals) {
|
||||||
if(polygonInnerCoordinates == null || thatObj.polygonInnerCoordinates == null) {
|
if (polygonInnerCoordinates == null || thatObj.polygonInnerCoordinates == null) {
|
||||||
equals = polygonInnerCoordinates == thatObj.polygonInnerCoordinates;
|
equals = polygonInnerCoordinates == thatObj.polygonInnerCoordinates;
|
||||||
} else if(polygonInnerCoordinates.length != thatObj.polygonInnerCoordinates.length){
|
} else if (polygonInnerCoordinates.length != thatObj.polygonInnerCoordinates.length) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < polygonInnerCoordinates.length && equals; i++) {
|
for (int i = 0; i < polygonInnerCoordinates.length && equals; i++) {
|
||||||
if(polygonInnerCoordinates[i] == null || thatObj.polygonInnerCoordinates[i] == null) {
|
if (polygonInnerCoordinates[i] == null || thatObj.polygonInnerCoordinates[i] == null) {
|
||||||
equals = polygonInnerCoordinates[i] == thatObj.polygonInnerCoordinates[i];
|
equals = polygonInnerCoordinates[i] == thatObj.polygonInnerCoordinates[i];
|
||||||
} else if(polygonInnerCoordinates[i].length != thatObj.polygonInnerCoordinates[i].length){
|
} else if (polygonInnerCoordinates[i].length != thatObj.polygonInnerCoordinates[i].length) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
equals = compareCoordinates(polygonInnerCoordinates[i], thatObj.polygonInnerCoordinates[i], coordinatesPrecision);
|
equals = compareCoordinates(polygonInnerCoordinates[i], thatObj.polygonInnerCoordinates[i],
|
||||||
|
coordinatesPrecision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(equals) {
|
if (equals) {
|
||||||
if(types == null || thatObj.types == null) {
|
if (types == null || thatObj.types == null) {
|
||||||
equals = types == thatObj.types;
|
equals = types == thatObj.types;
|
||||||
} else if(types.length != thatObj.types.length){
|
} else if (types.length != thatObj.types.length) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < types.length && equals; i++) {
|
for (int i = 0; i < types.length && equals; i++) {
|
||||||
TagValuePair o = mapIndex.decodeType(types[i]);
|
TagValuePair o = mapIndex.decodeType(types[i]);
|
||||||
TagValuePair s = thatObj.mapIndex.decodeType(thatObj.types[i]);
|
TagValuePair s = thatObj.mapIndex.decodeType(thatObj.types[i]);
|
||||||
equals = o.equals(s) && equals;
|
equals = o.equals(s) && equals;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(equals) {
|
if (equals) {
|
||||||
if(additionalTypes == null || thatObj.additionalTypes == null) {
|
if (additionalTypes == null || thatObj.additionalTypes == null) {
|
||||||
equals = additionalTypes == thatObj.additionalTypes;
|
equals = additionalTypes == thatObj.additionalTypes;
|
||||||
} else if(additionalTypes.length != thatObj.additionalTypes.length){
|
} else if (additionalTypes.length != thatObj.additionalTypes.length) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < additionalTypes.length && equals; i++) {
|
for (int i = 0; i < additionalTypes.length && equals; i++) {
|
||||||
TagValuePair o = mapIndex.decodeType(additionalTypes[i]);
|
TagValuePair o = mapIndex.decodeType(additionalTypes[i]);
|
||||||
TagValuePair s = thatObj.mapIndex.decodeType(thatObj.additionalTypes[i]);
|
TagValuePair s = thatObj.mapIndex.decodeType(thatObj.additionalTypes[i]);
|
||||||
equals = o.equals(s);
|
equals = o.equals(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(equals) {
|
if (equals) {
|
||||||
if(namesOrder == null || thatObj.namesOrder == null) {
|
if (namesOrder == null || thatObj.namesOrder == null) {
|
||||||
equals = namesOrder == thatObj.namesOrder;
|
equals = namesOrder == thatObj.namesOrder;
|
||||||
} else if(namesOrder.size() != thatObj.namesOrder.size()){
|
} else if (namesOrder.size() != thatObj.namesOrder.size()) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < namesOrder.size() && equals; i++) {
|
for (int i = 0; i < namesOrder.size() && equals; i++) {
|
||||||
TagValuePair o = mapIndex.decodeType(namesOrder.get(i));
|
TagValuePair o = mapIndex.decodeType(namesOrder.get(i));
|
||||||
TagValuePair s = thatObj.mapIndex.decodeType(thatObj.namesOrder.get(i));
|
TagValuePair s = thatObj.mapIndex.decodeType(thatObj.namesOrder.get(i));
|
||||||
equals = o.equals(s);
|
equals = o.equals(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(equals) {
|
if (equals) {
|
||||||
// here we know that name indexes are equal & it is enough to check the value sets
|
// here we know that name indexes are equal & it is enough to check the value sets
|
||||||
if(objectNames == null || thatObj.objectNames == null) {
|
if (objectNames == null || thatObj.objectNames == null) {
|
||||||
equals = objectNames == thatObj.objectNames;
|
equals = objectNames == thatObj.objectNames;
|
||||||
} else if(objectNames.size() != thatObj.objectNames.size()){
|
} else if (objectNames.size() != thatObj.objectNames.size()) {
|
||||||
equals = false;
|
equals = false;
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < namesOrder.size() && equals; i++) {
|
for (int i = 0; i < namesOrder.size() && equals; i++) {
|
||||||
String o = objectNames.get(namesOrder.get(i));
|
String o = objectNames.get(namesOrder.get(i));
|
||||||
String s = thatObj.objectNames.get(thatObj.namesOrder.get(i));
|
String s = thatObj.objectNames.get(thatObj.namesOrder.get(i));
|
||||||
equals = Algorithms.objectEquals(o, s);
|
equals = Algorithms.objectEquals(o, s);
|
||||||
|
@ -284,18 +287,6 @@ public class BinaryMapDataObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//do we need it? use precision?
|
|
||||||
if (equals) {
|
|
||||||
if (labelCoordinates == null || thatObj.labelCoordinates == null) {
|
|
||||||
equals = labelCoordinates == thatObj.labelCoordinates;
|
|
||||||
//do we need it? precision?
|
|
||||||
// } else {
|
|
||||||
// for(int i = 0; i < labelCoordinates.length && equals; i++) {
|
|
||||||
// equals = labelCoordinates[i] == thatObj.labelCoordinates[i];
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return equals;
|
return equals;
|
||||||
}
|
}
|
||||||
// thatObj.mapIndex.decodeType(thatObj.types[0])
|
// thatObj.mapIndex.decodeType(thatObj.types[0])
|
||||||
|
|
|
@ -76,7 +76,6 @@ import gnu.trove.map.TIntObjectMap;
|
||||||
import gnu.trove.map.hash.TIntObjectHashMap;
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
import gnu.trove.set.hash.TIntHashSet;
|
import gnu.trove.set.hash.TIntHashSet;
|
||||||
import gnu.trove.set.hash.TLongHashSet;
|
|
||||||
|
|
||||||
public class BinaryMapIndexReader {
|
public class BinaryMapIndexReader {
|
||||||
|
|
||||||
|
@ -1135,8 +1134,8 @@ public class BinaryMapIndexReader {
|
||||||
TIntArrayList additionalTypes = null;
|
TIntArrayList additionalTypes = null;
|
||||||
TIntObjectHashMap<String> stringNames = null;
|
TIntObjectHashMap<String> stringNames = null;
|
||||||
TIntArrayList stringOrder = null;
|
TIntArrayList stringOrder = null;
|
||||||
TIntArrayList labelCoordinates = null;
|
|
||||||
long id = 0;
|
long id = 0;
|
||||||
|
int labelX = 0, labelY = 0;
|
||||||
|
|
||||||
boolean loop = true;
|
boolean loop = true;
|
||||||
while (loop) {
|
while (loop) {
|
||||||
|
@ -1234,18 +1233,13 @@ public class BinaryMapIndexReader {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.MapData.LABELCOORDINATES_FIELD_NUMBER:
|
case OsmandOdb.MapData.LABELCOORDINATES_FIELD_NUMBER:
|
||||||
System.out.println("label coords");
|
labelX = codedIS.readRawVarint32();
|
||||||
labelCoordinates = new TIntArrayList();
|
labelY = codedIS.readRawVarint32();
|
||||||
sizeL = codedIS.readRawVarint32();
|
|
||||||
old = codedIS.pushLimit(sizeL);
|
|
||||||
if (READ_STATS) {
|
if (READ_STATS) {
|
||||||
req.stat.addTagHeader(OsmandOdb.MapData.LABELCOORDINATES_FIELD_NUMBER, sizeL);
|
req.stat.addTagHeader(OsmandOdb.MapData.LABELCOORDINATES_FIELD_NUMBER, 0);
|
||||||
req.stat.lastObjectLabelCoordinates += sizeL;
|
req.stat.lastObjectLabelCoordinates += CodedOutputStream.computeRawVarint32Size(labelX);
|
||||||
|
req.stat.lastObjectLabelCoordinates += CodedOutputStream.computeRawVarint32Size(labelY);
|
||||||
}
|
}
|
||||||
while (codedIS.getBytesUntilLimit() > 0) {
|
|
||||||
labelCoordinates.add(codedIS.readRawVarint32());
|
|
||||||
}
|
|
||||||
codedIS.popLimit(old);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
skipUnknownField(t);
|
skipUnknownField(t);
|
||||||
|
@ -1274,11 +1268,8 @@ public class BinaryMapIndexReader {
|
||||||
dataObject.id = id;
|
dataObject.id = id;
|
||||||
dataObject.area = area;
|
dataObject.area = area;
|
||||||
dataObject.mapIndex = root;
|
dataObject.mapIndex = root;
|
||||||
if (labelCoordinates != null) {
|
dataObject.labelX = labelX;
|
||||||
dataObject.labelCoordinates = labelCoordinates.toArray();
|
dataObject.labelY = labelY;
|
||||||
} else {
|
|
||||||
dataObject.labelCoordinates = new int[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return dataObject;
|
return dataObject;
|
||||||
}
|
}
|
||||||
|
@ -1941,7 +1932,7 @@ public class BinaryMapIndexReader {
|
||||||
BinaryMapDataObject bm =
|
BinaryMapDataObject bm =
|
||||||
new BinaryMapDataObject(o.id, o.coordinates, o.polygonInnerCoordinates, o.objectType, o.area,
|
new BinaryMapDataObject(o.id, o.coordinates, o.polygonInnerCoordinates, o.objectType, o.area,
|
||||||
types.toArray(), additionalTypes.isEmpty() ? null : additionalTypes.toArray(),
|
types.toArray(), additionalTypes.isEmpty() ? null : additionalTypes.toArray(),
|
||||||
o.labelCoordinates);
|
o.labelX, o.labelY);
|
||||||
if (o.namesOrder != null) {
|
if (o.namesOrder != null) {
|
||||||
bm.objectNames = new TIntObjectHashMap<>();
|
bm.objectNames = new TIntObjectHashMap<>();
|
||||||
bm.namesOrder = new TIntArrayList();
|
bm.namesOrder = new TIntArrayList();
|
||||||
|
@ -2225,7 +2216,6 @@ public class BinaryMapIndexReader {
|
||||||
private static List<Location> readGPX(File f) {
|
private static List<Location> readGPX(File f) {
|
||||||
List<Location> res = new ArrayList<Location>();
|
List<Location> res = new ArrayList<Location>();
|
||||||
try {
|
try {
|
||||||
StringBuilder content = new StringBuilder();
|
|
||||||
BufferedReader reader = new BufferedReader(getUTF8Reader(new FileInputStream(f)));
|
BufferedReader reader = new BufferedReader(getUTF8Reader(new FileInputStream(f)));
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder dom = factory.newDocumentBuilder();
|
DocumentBuilder dom = factory.newDocumentBuilder();
|
||||||
|
@ -2242,7 +2232,6 @@ public class BinaryMapIndexReader {
|
||||||
// Document doc = dom.parse(new InputSource(new StringReader(content.toString())));
|
// Document doc = dom.parse(new InputSource(new StringReader(content.toString())));
|
||||||
Document doc = dom.parse(new InputSource(reader));
|
Document doc = dom.parse(new InputSource(reader));
|
||||||
NodeList list = doc.getElementsByTagName("trkpt");
|
NodeList list = doc.getElementsByTagName("trkpt");
|
||||||
Way w = new Way(-1);
|
|
||||||
for (int i = 0; i < list.getLength(); i++) {
|
for (int i = 0; i < list.getLength(); i++) {
|
||||||
Element item = (Element) list.item(i);
|
Element item = (Element) list.item(i);
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue