use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class PlanRouteFragment method showRouteOnMap.
private void showRouteOnMap(List<WptPt> points) {
MapActivity mapActivity = getMapActivity();
if (points.size() > 0 && mapActivity != null) {
OsmandMapTileView mapView = mapActivity.getMapView();
double left = 0, right = 0;
double top = 0, bottom = 0;
Location myLocation = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
if (mapActivity.getMyApplication().getMapMarkersHelper().isStartFromMyLocation() && myLocation != null) {
left = myLocation.getLongitude();
right = myLocation.getLongitude();
top = myLocation.getLatitude();
bottom = myLocation.getLatitude();
}
for (WptPt pt : points) {
if (left == 0) {
left = pt.getLongitude();
right = pt.getLongitude();
top = pt.getLatitude();
bottom = pt.getLatitude();
} else {
left = Math.min(left, pt.getLongitude());
right = Math.max(right, pt.getLongitude());
top = Math.max(top, pt.getLatitude());
bottom = Math.min(bottom, pt.getLatitude());
}
}
RotatedTileBox tb = mapView.getCurrentRotatedTileBox().copy();
int tileBoxWidthPx = 0;
int tileBoxHeightPx = 0;
if (portrait) {
tileBoxHeightPx = 3 * (tb.getPixHeight() - toolbarHeight) / 4;
} else {
tileBoxWidthPx = tb.getPixWidth() - mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
}
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
}
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class MeasurementToolLayer method getMovedPointToApply.
WptPt getMovedPointToApply() {
RotatedTileBox tb = view.getCurrentRotatedTileBox();
LatLon latLon = tb.getCenterLatLon();
WptPt pt = new WptPt(editingCtx.getOriginalPointToMove());
pt.lat = latLon.getLatitude();
pt.lon = latLon.getLongitude();
return pt;
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class MeasurementToolLayer method selectPoint.
private void selectPoint(double x, double y, boolean singleTap) {
RotatedTileBox tb = view.getCurrentRotatedTileBox();
double lowestDistance = view.getResources().getDimension(R.dimen.measurement_tool_select_radius);
for (int i = 0; i < editingCtx.getPointsCount(); i++) {
WptPt pt = editingCtx.getPoints().get(i);
if (tb.containsLatLon(pt.getLatitude(), pt.getLongitude())) {
double xDiff = tb.getPixXFromLonNoRot(pt.getLongitude()) - x;
double yDiff = tb.getPixYFromLatNoRot(pt.getLatitude()) - y;
double distToPoint = Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));
if (distToPoint < lowestDistance) {
lowestDistance = distToPoint;
editingCtx.setSelectedPointPosition(i);
}
}
}
if (singleTap && singleTapListener != null) {
singleTapListener.onSelectPoint(editingCtx.getSelectedPointPosition());
}
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class OsmBugsLayer method initLayer.
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;
paintIcon = new Paint();
resolvedNote = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_resolved);
unresolvedNote = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_unresolved);
resolvedNoteSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_resolved_small);
unresolvedNoteSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_unresolved_small);
data = new OsmandMapLayer.MapLayerData<List<OpenStreetNote>>() {
{
ZOOM_THRESHOLD = 1;
}
@Override
protected List<OpenStreetNote> calculateResult(RotatedTileBox tileBox) {
QuadRect bounds = tileBox.getLatLonBounds();
return loadingBugs(bounds.top, bounds.left, bounds.bottom, bounds.right);
}
};
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class MainActivity method getBox.
public RotatedTileBox getBox() {
RotatedTileBox.RotatedTileBoxBuilder boxBuilder = new RotatedTileBox.RotatedTileBoxBuilder();
LatLon screenCenter = getScreenCenter();
boxBuilder.setLocation(screenCenter.getLatitude(), screenCenter.getLongitude());
boxBuilder.setPixelDimensions(mapView.getWidth(), mapView.getHeight(), 0.5f, 0.5f);
boxBuilder.setZoom((int) getZoom());
boxBuilder.setRotate(mapView.getRotation());
return boxBuilder.build();
}
Aggregations