Merge pull request #8381 from osmandapp/poi_search_fix

fix for #6497
This commit is contained in:
vshcherb 2020-02-03 15:24:30 +01:00 committed by GitHub
commit 911f4788b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 10 deletions

View file

@ -364,6 +364,8 @@ public class NativeLibrary {
private int order;
private boolean visible;
private LatLon labelLatLon;
private int labelX = 0;
private int labelY = 0;
public Map<String, String> getTags() {
return tags;
@ -433,7 +435,22 @@ public class NativeLibrary {
public void putTag(String t, String v) {
tags.put(t, v);
}
public int getLabelX() {
return labelX;
}
public int getLabelY() {
return labelY;
}
public void setLabelX(int labelX) {
this.labelX = labelX;
}
public void setLabelY(int labelY) {
this.labelY = labelY;
}
}
}

View file

@ -48,6 +48,7 @@ import net.osmand.data.TransportStop;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiFilter;
import net.osmand.osm.PoiType;
import net.osmand.osm.edit.OsmMapUtils;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.OsmandApplication;
@ -686,15 +687,19 @@ public class ContextMenuLayer extends OsmandMapLayer {
double cosRotateTileSize = Math.cos(Math.toRadians(rc.rotate)) * TILE_SIZE;
double sinRotateTileSize = Math.sin(Math.toRadians(rc.rotate)) * TILE_SIZE;
for (RenderedObject r : renderedObjects) {
double cx = r.getBbox().centerX();
double cy = r.getBbox().centerY();
double dTileX = (cx * cosRotateTileSize + cy * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
double dTileY = (cy * cosRotateTileSize - cx * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
int x31 = (int) ((dTileX + rc.leftX) * rc.tileDivisor);
int y31 = (int) ((dTileY + rc.topY) * rc.tileDivisor);
double lat = MapUtils.get31LatitudeY(y31);
double lon = MapUtils.get31LongitudeX(x31);
r.setLabelLatLon(new LatLon(lat, lon));
if (r.getLabelX() != 0 && r.getLabelY() != 0) {
r.setLabelLatLon(new LatLon(MapUtils.get31LatitudeY(r.getLabelY()), MapUtils.get31LongitudeX(r.getLabelX())));
} else {
double cx = r.getBbox().centerX();
double cy = r.getBbox().centerY();
double dTileX = (cx * cosRotateTileSize + cy * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
double dTileY = (cy * cosRotateTileSize - cx * sinRotateTileSize) / (TILE_SIZE * TILE_SIZE);
int x31 = (int) ((dTileX + rc.leftX) * rc.tileDivisor);
int y31 = (int) ((dTileY + rc.topY) * rc.tileDivisor);
double lat = MapUtils.get31LatitudeY(y31);
double lon = MapUtils.get31LongitudeX(x31);
r.setLabelLatLon(new LatLon(lat, lon));
}
}
for (RenderedObject renderedObject : renderedObjects) {
if (renderedObject.getX() != null && renderedObject.getX().size() == 1