use of net.osmand.core.jni.PointI in project Osmand by osmandapp.
the class MapContextMenuFragment method adjustMapPosition.
private void adjustMapPosition(int y, boolean animated, boolean center) {
// map.getAnimatedDraggingThread().stopAnimatingSync(); todo animation
LatLon latlon = getAdjustedMarkerLocation(y, menu.getLatLon(), center, getZoom());
LatLon mapLatLon = getMainActivity().getScreenCenter();
if (mapLatLon.getLatitude() == latlon.getLatitude() && mapLatLon.getLongitude() == latlon.getLongitude()) {
return;
}
if (animated) {
showOnMap(latlon, false, true, true);
} else {
PointI targetI = Utilities.convertLatLonTo31(new net.osmand.core.jni.LatLon(latlon.getLatitude(), latlon.getLongitude()));
getMainActivity().setTarget(targetI);
}
}
use of net.osmand.core.jni.PointI in project Osmand by osmandapp.
the class MapContextMenuFragment method showOnMap.
private void showOnMap(LatLon latLon, boolean updateCoords, boolean needMove, boolean alreadyAdjusted) {
// AnimateDraggingMapThread thread = map.getAnimatedDraggingThread(); todo amimation
int fZoom = getZoom();
double flat = latLon.getLatitude();
double flon = latLon.getLongitude();
RotatedTileBox cp = getBox();
// cp.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
cp.setLatLonCenter(flat, flon);
cp.setZoom(fZoom);
flat = cp.getLatFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
flon = cp.getLonFromPixel(cp.getPixWidth() / 2, cp.getPixHeight() / 2);
if (updateCoords) {
mapCenter = new LatLon(flat, flon);
menu.setMapCenter(mapCenter);
origMarkerX = cp.getCenterPixelX();
origMarkerY = cp.getCenterPixelY();
}
if (!alreadyAdjusted) {
LatLon adjustedLatLon = getAdjustedMarkerLocation(getPosY(), new LatLon(flat, flon), true, fZoom);
flat = adjustedLatLon.getLatitude();
flon = adjustedLatLon.getLongitude();
}
if (needMove) {
// thread.startMoving(flat, flon, fZoom, true); todo animation
PointI targetI = Utilities.convertLatLonTo31(new net.osmand.core.jni.LatLon(flat, flon));
getMainActivity().setTarget(targetI);
getMainActivity().setZoom(fZoom);
}
}
use of net.osmand.core.jni.PointI in project Osmand by osmandapp.
the class MapContextMenuFragment method onDestroyView.
@Override
public void onDestroyView() {
super.onDestroyView();
if (mapCenter != null) {
PointI centerI = Utilities.convertLatLonTo31(new net.osmand.core.jni.LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));
getMainActivity().setTarget(centerI);
}
menu.setMapCenter(null);
menu.setMapZoom(0);
}
use of net.osmand.core.jni.PointI in project OsmAnd-tools by osmandapp.
the class QtCorePanel method reshape.
@Override
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
mapRenderer.setViewport(new AreaI(0, 0, height, width));
mapRenderer.setWindowSize(new PointI(width, height));
if (!mapRenderer.isRenderingInitialized()) {
if (!mapRenderer.initializeRendering())
System.err.println("Failed to initialize rendering");
}
}
use of net.osmand.core.jni.PointI in project Osmand by osmandapp.
the class MapVectorLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tilesRect, DrawSettings drawSettings) {
if (!visible) {
return;
}
// if (!isVectorDataVisible() && tileLayer != null) {
// tileLayer.drawTileMap(canvas, tilesRect);
// resourceManager.getRenderer().interruptLoadingMap();
// } else {
final MapRendererView mapRenderer = view.getMapRenderer();
if (mapRenderer != null && !oldRender) {
NativeCoreContext.getMapRendererContext().setNightMode(drawSettings.isNightMode());
OsmandSettings st = view.getApplication().getSettings();
if (!Algorithms.objectEquals(st.MAP_UNDERLAY.get(), cachedUnderlay)) {
cachedUnderlay = st.MAP_UNDERLAY.get();
ITileSource tileSource = st.getTileSourceByName(cachedUnderlay, false);
if (tileSource != null) {
TileSourceProxyProvider prov = new TileSourceProxyProvider(view.getApplication(), tileSource);
mapRenderer.setMapLayerProvider(-1, prov.instantiateProxy(true));
prov.swigReleaseOwnership();
// mapRenderer.setMapLayerProvider(-1,
// net.osmand.core.jni.OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"));
} else {
mapRenderer.resetMapLayerProvider(-1);
}
}
if (!Algorithms.objectEquals(st.MAP_TRANSPARENCY.get(), cachedMapTransparency)) {
cachedMapTransparency = st.MAP_TRANSPARENCY.get();
MapLayerConfiguration mapLayerConfiguration = new MapLayerConfiguration();
mapLayerConfiguration.setOpacityFactor(((float) cachedMapTransparency) / 255.0f);
mapRenderer.setMapLayerConfiguration(0, mapLayerConfiguration);
}
if (!Algorithms.objectEquals(st.MAP_OVERLAY.get(), cachedOverlay)) {
cachedOverlay = st.MAP_OVERLAY.get();
ITileSource tileSource = st.getTileSourceByName(cachedOverlay, false);
if (tileSource != null) {
TileSourceProxyProvider prov = new TileSourceProxyProvider(view.getApplication(), tileSource);
mapRenderer.setMapLayerProvider(1, prov.instantiateProxy(true));
prov.swigReleaseOwnership();
// mapRenderer.setMapLayerProvider(1,
// net.osmand.core.jni.OnlineTileSources.getBuiltIn().createProviderFor("Mapnik (OsmAnd)"));
} else {
mapRenderer.resetMapLayerProvider(1);
}
}
if (!Algorithms.objectEquals(st.MAP_OVERLAY_TRANSPARENCY.get(), cachedOverlayTransparency)) {
cachedOverlayTransparency = st.MAP_OVERLAY_TRANSPARENCY.get();
MapLayerConfiguration mapLayerConfiguration = new MapLayerConfiguration();
mapLayerConfiguration.setOpacityFactor(((float) cachedOverlayTransparency) / 255.0f);
mapRenderer.setMapLayerConfiguration(1, mapLayerConfiguration);
}
// opengl renderer
LatLon ll = tilesRect.getLatLonFromPixel(tilesRect.getPixWidth() / 2, tilesRect.getPixHeight() / 2);
mapRenderer.setTarget(new PointI(MapUtils.get31TileNumberX(ll.getLongitude()), MapUtils.get31TileNumberY(ll.getLatitude())));
mapRenderer.setAzimuth(-tilesRect.getRotate());
mapRenderer.setZoom((float) (tilesRect.getZoom() + tilesRect.getZoomAnimation() + tilesRect.getZoomFloatPart()));
float zoomMagnifier = st.MAP_DENSITY.get();
mapRenderer.setVisualZoomShift(zoomMagnifier - 1.0f);
} else {
if (!view.isZooming()) {
if (resourceManager.updateRenderedMapNeeded(tilesRect, drawSettings)) {
// pixRect.set(-view.getWidth(), -view.getHeight() / 2, 2 * view.getWidth(), 3 *
// view.getHeight() / 2);
final RotatedTileBox copy = tilesRect.copy();
copy.increasePixelDimensions(copy.getPixWidth() / 3, copy.getPixHeight() / 4);
resourceManager.updateRendererMap(copy, null);
}
}
MapRenderRepositories renderer = resourceManager.getRenderer();
drawRenderedMap(canvas, renderer.getBitmap(), renderer.getBitmapLocation(), tilesRect);
drawRenderedMap(canvas, renderer.getPrevBitmap(), renderer.getPrevBmpLocation(), tilesRect);
}
}
Aggregations