Fix labelx, labely

This commit is contained in:
Victor Shcherb 2020-01-28 19:44:51 +01:00
parent 6778ebda7c
commit ac11868e2a
2 changed files with 30 additions and 1 deletions

View file

@ -362,7 +362,35 @@ public class BinaryMapDataObject {
}
public boolean isLabelSpecified() {
return (labelX != 0 || labelY != 0) && coordinates.length > 0;
}
public int getLabelX() {
long sum = 0;
int LABEL_SHIFT = 31 - BinaryMapIndexReader.LABEL_ZOOM_ENCODE;
int len = coordinates.length / 2;
for(int i = 0; i < len; i++) {
sum += coordinates[2 * i];
}
int average = ((int) (sum >> BinaryMapIndexReader.SHIFT_COORDINATES)/ len)
<< (BinaryMapIndexReader.SHIFT_COORDINATES - LABEL_SHIFT);
int label31X = (average + this.labelX) << LABEL_SHIFT;
return label31X;
}
public int getLabelY() {
long sum = 0;
int LABEL_SHIFT = 31 - BinaryMapIndexReader.LABEL_ZOOM_ENCODE;
int len = coordinates.length / 2;
for(int i = 0; i < len; i++) {
sum += coordinates[2 * i + 1];
}
int average = ((int) (sum >> BinaryMapIndexReader.SHIFT_COORDINATES)/ len)
<< (BinaryMapIndexReader.SHIFT_COORDINATES - LABEL_SHIFT);
int label31Y = (average + this.labelY) << LABEL_SHIFT;
return label31Y;
}
public int[] getCoordinates() {
return coordinates;

View file

@ -81,6 +81,7 @@ public class BinaryMapIndexReader {
public final static int TRANSPORT_STOP_ZOOM = 24;
public static final int SHIFT_COORDINATES = 5;
public static final int LABEL_ZOOM_ENCODE = 31;
private final static Log log = PlatformUtil.getLog(BinaryMapIndexReader.class);
public static boolean READ_STATS = false;
public static final SearchPoiTypeFilter ACCEPT_ALL_POI_TYPE_FILTER = new SearchPoiTypeFilter() {
@ -2119,7 +2120,7 @@ public class BinaryMapIndexReader {
public static void main(String[] args) throws IOException {
File fl = new File(System.getProperty("maps") + "/Synthetic_test_rendering.obf");
fl = new File("/home/madwasp79/OsmAnd-maps/_Creator/Poly_center.obf");
fl = new File(System.getProperty("maps") + "/Belarus_europe_2.obf");
RandomAccessFile raf = new RandomAccessFile(fl, "r");