Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-08-13 09:28:49 +02:00
commit 45ba94f101
24 changed files with 192 additions and 129 deletions

View file

@ -757,6 +757,8 @@ public class BinaryRoutePlanner {
return false;
}
private static final float TURN_DEGREE_MIN = 45;
/**
* Helper method to prepare final result
*/
@ -826,12 +828,12 @@ public class BinaryRoutePlanner {
if (next != rr.getEndPointIndex() && !rr.getObject().roundabout() && attachedRoutes != null) {
float before = rr.getBearing(next, !plus);
float after = rr.getBearing(next, plus);
boolean straight = Math.abs(MapUtils.degreesDiff(before + 180, after)) < 70;
boolean straight = Math.abs(MapUtils.degreesDiff(before + 180, after)) < TURN_DEGREE_MIN;
boolean split = false;
// split if needed
for (RouteSegmentResult rs : attachedRoutes) {
double diff = MapUtils.degreesDiff(before + 180, rs.getBearingBegin());
if (Math.abs(diff) < 50) {
if (Math.abs(diff) <= TURN_DEGREE_MIN) {
split = true;
} else if (!straight && Math.abs(diff) < 100) {
split = true;
@ -988,7 +990,7 @@ public class BinaryRoutePlanner {
if (prev != null) {
// add description about turn
double mpi = MapUtils.degreesDiff(prev.getBearingEnd(), rr.getBearingBegin());
if (mpi >= 50) {
if (mpi >= TURN_DEGREE_MIN) {
if (mpi < 60) {
t = TurnType.valueOf(TurnType.TSLL, leftSide);
} else if (mpi < 120) {
@ -998,7 +1000,7 @@ public class BinaryRoutePlanner {
} else {
t = TurnType.valueOf(TurnType.TU, leftSide);
}
} else if (mpi < -50) {
} else if (mpi < -TURN_DEGREE_MIN) {
if (mpi > -60) {
t = TurnType.valueOf(TurnType.TSLR, leftSide);
} else if (mpi > -120) {
@ -1062,14 +1064,15 @@ public class BinaryRoutePlanner {
if(attachedRoutes != null){
for(RouteSegmentResult rs : attachedRoutes){
double ex = MapUtils.degreesDiff(rs.getBearingBegin(), rr.getBearingBegin());
if(ex < 45 && ex >= 0) {
double mpi = Math.abs(MapUtils.degreesDiff(prev.getBearingEnd(), rs.getBearingBegin())) ;
if((ex < TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex >= 0) {
kl = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {
right += lns;
}
speak = speak || !highwayLowEnd(rs.getObject().getHighway());
} else if(ex > -45 && ex <= 0) {
} else if((ex > -TURN_DEGREE_MIN || mpi < TURN_DEGREE_MIN) && ex <= 0) {
kr = true;
int lns = rs.getObject().getLanes();
if (lns > 0) {

View file

@ -89,11 +89,6 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.rim.ajde.internal.verifier</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
@ -102,7 +97,6 @@
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>net.rim.ajde.BlackBerryAndroidNature</nature>
</natures>
<linkedResources>
<link>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>

View file

@ -0,0 +1,3 @@
<?xml version='1.0' encoding='utf-8'?>
<resources>
</resources>

View file

@ -1,6 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<resources><string name="layer_map_appearance">Konfigurovať obrazovku…</string>
<string name="show_lanes">Zobraziť jazdné pruhy</string>
<resources>
<string name="live_monitoring_mode_off">Spustiť\n stopovanie naživo</string>
<string name="live_monitoring_mode_on">Zastaviť\n stopovanie naživo</string>
<string name="layer_map_appearance">Konfigurovať obrazovku…</string>
<string name="show_lanes">Jazdné pruhy</string>
<string name="avoid_unpaved">Nespevneným cestám</string>
<string name="avoid_ferries">Trajektom</string>
<string name="avoid_in_routing_title">Vyhnúť sa…</string>
@ -15,9 +18,9 @@
<string name="gps_wakeup_interval">Interval prebúdzania GPS: %s</string>
<string name="int_continuosly">Priebežne</string>
<string name="monitoring_mode_off">GPX zázn.</string>
<string name="monitoring_mode_on">GPX vyp.</string>
<string name="bg_service_sleep_mode_off">Zapnúť režim spánku</string>
<string name="bg_service_sleep_mode_on">Vypnúť režim spánku</string>
<string name="monitoring_mode_on">Zastavit\n GPX záznam</string>
<string name="bg_service_sleep_mode_off">Zapnúť\n režim spánku</string>
<string name="bg_service_sleep_mode_on">Vypnúť\n režim spánku</string>
<string name="map_widget_top_text">Názov ulice</string>
<string name="map_widget_config">Konfigurácia</string>
<string name="map_widget_map_select">Výber mapy</string>
@ -916,9 +919,9 @@
<string name="show_cameras_descr">Zobrazenie radarov (môže byť zakázané v niektorých krajinách)</string>
<string name="show_speed_limits_descr">Zobrazenie radarov a spomaľovačov</string>
<string name="avoid_toll_roads_descr">Vyvarovanie sa plateným cestám pri kalkulácii trasy</string>
<string name="show_cameras">Zobrazenie radarov</string>
<string name="show_speed_limits">Zobraziť radary</string>
<string name="avoid_toll_roads">Vyhnúť sa spoplatneným cestám</string>
<string name="show_cameras">Radary</string>
<string name="show_speed_limits">Rýchlostné obmedzenia</string>
<string name="avoid_toll_roads">Spoplatneným cestám</string>
<string name="tip_recent_changes_0_8_2_t">Zmeny vo verzii 0.8.2 :
\n\t* Vylepšená navigácia
\n\t* Dynamické mapové widgety</string>

View file

@ -9,8 +9,8 @@
1. All your modified/created strings are in the top of the file (to make easier find what's translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="live_monitoring_mode_off">Live tracking</string>
<string name="live_monitoring_mode_on">Stop Live tracking</string>
<string name="live_monitoring_mode_off">Start\n live tracking</string>
<string name="live_monitoring_mode_on">Stop\n live tracking</string>
<string name="layer_map_appearance">Configure screen&#8230;</string>
<string name="show_lanes">Show lanes</string>
<string name="avoid_unpaved">Avoid unpaved roads</string>
@ -25,9 +25,9 @@
<string name="map_widget_view_direction">Viewing direction</string>
<string name="map_widget_transparent">Transparent skin</string>
<string name="monitoring_mode_off">Record GPX</string>
<string name="monitoring_mode_on">Stop GPX rec.</string>
<string name="bg_service_sleep_mode_off">Enable sleep mode</string>
<string name="bg_service_sleep_mode_on">Stop sleep mode</string>
<string name="monitoring_mode_on">Stop\n GPX rec.</string>
<string name="bg_service_sleep_mode_off">Enable\n sleep mode</string>
<string name="bg_service_sleep_mode_on">Stop\n sleep mode</string>
<string name="gps_wakeup_interval">GPS wake-up interval : %s</string>
<string name="int_continuosly">Continuously</string>
<string name="screen_is_locked">To unlock screen press lock icon</string>

View file

@ -10,7 +10,7 @@ public class RotatedTileBox {
private float tileWidth;
private float tileHeight;
private float rotate;
private int zoom;
private float zoom;
private float rotateCos;
private float rotateSin;
@ -28,7 +28,7 @@ public class RotatedTileBox {
rotateSin = FloatMath.sin(rad);
}
public void set(float leftTileX, float topTileY, float tileWidth, float tileHeight, float rotate, int zoom) {
public void set(float leftTileX, float topTileY, float tileWidth, float tileHeight, float rotate, float zoom) {
this.leftTileX = leftTileX;
if(rotate < 0){
rotate += 360;
@ -51,9 +51,13 @@ public class RotatedTileBox {
return rotateSin;
}
public int getZoom() {
public float getZoom() {
return zoom;
}
public int getIntZoom() {
return Math.round(zoom);
}
public float getRotate() {
return rotate;
@ -77,7 +81,7 @@ public class RotatedTileBox {
public boolean containsTileBox(RotatedTileBox box) {
PointF temp = new PointF();
if(box.getZoom() != zoom){
if(box.zoom != zoom){
throw new UnsupportedOperationException();
}
box.calcPointTile(0, 0, temp);
@ -105,7 +109,7 @@ public class RotatedTileBox {
float tx3 = calcPointTileX(0, tileHeight);
float minTileX = Math.min(Math.min(leftTileX, tx), Math.min(tx2, tx3)) ;
float maxTileX = Math.max(Math.max(leftTileX, tx), Math.max(tx2, tx3)) ;
int max = 1 << zoom;
int max = (int) MapUtils.getPowZoom(zoom);
if(minTileX < 0){
minTileX = 0;
}

View file

@ -22,6 +22,7 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@ -29,8 +30,11 @@ import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.TouchDelegate;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.view.Window;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
@ -207,7 +211,7 @@ public class MainMenuActivity extends Activity {
}
});
View closeButton = window.findViewById(R.id.CloseButton);
final View closeButton = window.findViewById(R.id.CloseButton);
closeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@ -222,6 +226,27 @@ public class MainMenuActivity extends Activity {
}
}
});
closeButton.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
closeButton.performClick();
return true;
}
});
//increase touch area for the button
final View parent = (View) closeButton.getParent();
parent.post( new Runnable() {
// Post in the parent's message queue to make sure the parent
// lays out its children before we call getHitRect()
@Override
public void run() {
Rect r = new Rect();
closeButton.getHitRect(r);
r.right += r.width() * 3;
r.bottom += r.height() * 3;
parent.setTouchDelegate(new TouchDelegate(r, closeButton));
}
});
View searchButton = window.findViewById(R.id.SearchButton);
searchButton.setOnClickListener(new OnClickListener() {

View file

@ -458,6 +458,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
}
public void changeZoom(float newZoom){
newZoom = Math.round(newZoom * OsmandMapTileView.ZOOM_DELTA) * OsmandMapTileView.ZOOM_DELTA_1;
boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
if (getMyApplication().accessibilityEnabled())
@ -703,7 +704,9 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
SensorManager sensorMgr = (SensorManager) getSystemService(SENSOR_SERVICE);
Sensor s = sensorMgr.getDefaultSensor(Sensor.TYPE_ORIENTATION);
if (s != null) {
sensorMgr.registerListener(this, s, SensorManager.SENSOR_DELAY_UI);
if(!sensorMgr.registerListener(this, s, SensorManager.SENSOR_DELAY_NORMAL)) {
Log.e(LogUtil.TAG, "Sensor could not be enabled");
}
}
sensorRegistered = true;
}
@ -881,22 +884,6 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
}
public float defineZoomFromSpeed(float speed) {
// Hardy's old implementation: correct for roughly constant "look ahead" distance on different screens using screen size correction, see Issue 914
// less than 23: show zoom 17
// int screenSizeCorrection = (int)Math.round(Math.log(((float)getMapView().getHeight())/320.0f) / Math.log(2.0f));
// if(speed < 23f/3.6){
// return 17 + screenSizeCorrection;
// } else if(speed < 43f/3.6){
// return 16 + screenSizeCorrection;
// } else if(speed < 63f/3.6){
// return 15 + screenSizeCorrection;
// } else if(speed < 83f/3.6){
// return 14 + screenSizeCorrection;
// }
// return 13 + screenSizeCorrection;
// new implementation
// TODO Hardy: verify look ahead distance, there still seems bug in calculation
if (speed < 7f / 3.6) {
return 0;
}

View file

@ -29,8 +29,8 @@ import android.preference.PreferenceScreen;
import android.view.View;
public class OsmandBackgroundServicePlugin extends OsmandPlugin implements LockInfoControlActions {
public static final int[] MINUTES = new int[]{2, 3, 5, 10, 15, 30, 45, 60, 90};
public static final int[] SECONDS = new int[]{0, 30, 45, 60};
public static final int[] SECONDS = new int[]{0, 30, 60, 90};
public static final int[] MINUTES = new int[]{2, 3, 5, 10, 15, 30, 60, 90};
private final static boolean REGISTER_BG_SETTINGS = false;
private static final String ID = "osmand.backgroundservice";
private OsmandSettings settings;
@ -153,7 +153,7 @@ public class OsmandBackgroundServicePlugin extends OsmandPlugin implements LockI
final ActionItem bgServiceAction = new ActionItem();
final boolean off = view.getApplication().getNavigationService() == null;
bgServiceAction.setTitle(view.getResources().getString(!off? R.string.bg_service_sleep_mode_on : R.string.bg_service_sleep_mode_off));
// bgServiceAction.setIcon(view.getResources().getDrawable(R.drawable.car_small));
bgServiceAction.setIcon(view.getResources().getDrawable(!off? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive));
bgServiceAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -106,8 +106,8 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements LockInfoCont
adapter.registerItem(R.string.context_menu_item_add_waypoint, R.drawable.list_activities_gpx_waypoint, listener, -1);
}
public static final int[] MINUTES = new int[]{2, 3, 5, 10, 15, 30, 45, 60, 90};
public static final int[] SECONDS = new int[] { 1, 2, 3, 5};
public static final int[] SECONDS = new int[] {1, 2, 3, 5, 10, 15, 30, 60, 90};
public static final int[] MINUTES = new int[] {2, 3, 5};
@Override
public void settingsActivityCreate(final SettingsActivity activity, PreferenceScreen screen) {
@ -263,7 +263,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements LockInfoCont
final ActionItem bgServiceAction = new ActionItem();
final boolean off = !view.getSettings().SAVE_TRACK_TO_GPX.get();
bgServiceAction.setTitle(view.getResources().getString(off? R.string.monitoring_mode_off : R.string.monitoring_mode_on));
bgServiceAction.setIcon(view.getResources().getDrawable(off ? R.drawable.monitoring_rec_big : R.drawable.monitoring_rec_inactive));
bgServiceAction.setIcon(view.getResources().getDrawable(off ? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big));
bgServiceAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -290,7 +290,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin implements LockInfoCont
final ActionItem liveAction = new ActionItem();
final boolean liveoff = !view.getSettings().LIVE_MONITORING.get();
liveAction.setTitle(view.getResources().getString(liveoff? R.string.live_monitoring_mode_off : R.string.live_monitoring_mode_on));
liveAction.setIcon(view.getResources().getDrawable(liveoff?R.drawable.monitoring_rec_big:R.drawable.monitoring_rec_inactive));
liveAction.setIcon(view.getResources().getDrawable(liveoff? R.drawable.monitoring_rec_inactive : R.drawable.monitoring_rec_big));
liveAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -528,10 +528,10 @@ public class MapRenderRepositories {
boolean loaded;
if(nativeLib != null) {
cObjects = new LinkedList<BinaryMapDataObject>();
loaded = loadVectorDataNative(dataBox, requestedBox.getZoom(), renderingReq, nativeLib);
loaded = loadVectorDataNative(dataBox, requestedBox.getIntZoom(), renderingReq, nativeLib);
} else {
cNativeObjects = null;
loaded = loadVectorData(dataBox, requestedBox.getZoom(), renderingReq);
loaded = loadVectorData(dataBox, requestedBox.getIntZoom(), renderingReq);
}
if (!loaded || checkWhetherInterrupted()) {
@ -542,19 +542,19 @@ public class MapRenderRepositories {
currentRenderingContext = new OsmandRenderer.RenderingContext(context);
renderingReq.clearState();
renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getZoom());
renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getIntZoom());
if(renderingReq.searchRenderingAttribute(RenderingRuleStorageProperties.A_DEFAULT_COLOR)) {
currentRenderingContext.defaultColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_COLOR_VALUE);
}
renderingReq.clearState();
renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getZoom());
renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getIntZoom());
if(renderingReq.searchRenderingAttribute(RenderingRuleStorageProperties.A_SHADOW_RENDERING)) {
currentRenderingContext.shadowRenderingMode = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE);
currentRenderingContext.shadowRenderingColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_SHADOW_COLOR);
}
currentRenderingContext.leftX = (float) requestedBox.getLeftTileX();
currentRenderingContext.topY = (float) requestedBox.getTopTileY();
currentRenderingContext.zoom = requestedBox.getZoom();
currentRenderingContext.leftX = requestedBox.getLeftTileX();
currentRenderingContext.topY = requestedBox.getTopTileY() ;
currentRenderingContext.zoom = requestedBox.getIntZoom();
currentRenderingContext.rotate = requestedBox.getRotate();
currentRenderingContext.width = (int) (requestedBox.getTileWidth() * OsmandRenderer.TILE_SIZE);
currentRenderingContext.height = (int) (requestedBox.getTileHeight() * OsmandRenderer.TILE_SIZE);
@ -562,6 +562,8 @@ public class MapRenderRepositories {
currentRenderingContext.useEnglishNames = prefs.USE_ENGLISH_NAMES.get();
currentRenderingContext.setDensityValue(prefs.USE_HIGH_RES_MAPS.get(),
prefs.MAP_TEXT_SIZE.get(), renderer.getDensity());
// init rendering context
currentRenderingContext.tileDivisor = (float) MapUtils.getPowZoom(31 - requestedBox.getZoom());
if (checkWhetherInterrupted()) {
return;
}
@ -573,19 +575,25 @@ public class MapRenderRepositories {
if (rr != null) {
transparent = renderingReq.getIntPropertyValue(rr) > 0;
}
// if(transparent) {
// bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.ARGB_8888);
// } else {
bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.RGB_565);
// }
// 1. generate image step by step
Bitmap reuse = prevBmp;
this.prevBmp = this.bmp;
this.prevBmpLocation = this.bmpLocation;
if (reuse != null && reuse.getWidth() == currentRenderingContext.width && reuse.getHeight() == currentRenderingContext.height) {
bmp = reuse;
bmp.eraseColor(currentRenderingContext.defaultColor);
} else {
if(reuse != null){
log.error(String.format("Create new image ? %d != %d (w) %d != %d (h) ", currentRenderingContext.width, reuse.getWidth(), currentRenderingContext.height, reuse.getHeight()));
}
bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.RGB_565);
}
this.bmp = bmp;
this.bmpLocation = tileRect;
if(nativeLib != null) {
renderer.generateNewBitmapNative(currentRenderingContext, nativeLib, cNativeObjects, bmp, renderingReq, notifyList);
} else {
@ -601,8 +609,11 @@ public class MapRenderRepositories {
// revert if it was interrupted
// (be smart a bit do not revert if road already drawn)
if(currentRenderingContext.lastRenderedKey < 35) {
reuse = this.bmp;
this.bmp = this.prevBmp;
this.bmpLocation = this.prevBmpLocation;
this.prevBmp = reuse;
this.prevBmpLocation = null;
}
currentRenderingContext = null;
return;
@ -610,7 +621,8 @@ public class MapRenderRepositories {
currentRenderingContext = null;
// 2. replace whole image
this.prevBmp = null;
// keep cache
// this.prevBmp = null;
this.prevBmpLocation = null;
if (prefs.DEBUG_RENDERING_INFO.get()) {
String timeInfo = "Searching: " + searchTime + " ms"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
@ -660,15 +672,16 @@ public class MapRenderRepositories {
}
public Bitmap getPrevBitmap() {
return prevBmp;
return prevBmpLocation == null ? null : prevBmp ;
}
public synchronized void clearCache() {
cObjects = new ArrayList<BinaryMapDataObject>();
cObjectsBox = new RectF();
prevBmp = null;
requestedBox = prevBmpLocation = null;
// Do not clear main bitmap to not cause a screen refresh
// prevBmp = null;
// bmp = null;
// bmpLocation = null;
}

View file

@ -49,13 +49,11 @@ public class MapVectorLayer extends BaseMapLayer {
}
private void updateRotatedTileBox(){
// float ts = view.getTileSize();
int zm = Math.round(view.getFloatZoom());
float xL = view.calcDiffTileX(pixRect.left - view.getCenterPointX(), pixRect.top - view.getCenterPointY()) + view.getXTile();
float yT = view.calcDiffTileY(pixRect.left - view.getCenterPointX(), pixRect.top - view.getCenterPointY()) + view.getYTile();
float mult = (float) Math.pow(2, zm - view.getZoom());
float ts = (float) (view.getSourceTileSize() * Math.pow(2, view.getFloatZoom() - (int) zm));
rotatedTileBox.set(xL * mult, yT * mult, ((float) pixRect.width()) / ts , ((float) pixRect.height()) / ts, view.getRotate(), zm);
float mult = (float) Math.pow(2, view.getFloatZoom() - view.getZoom());
float xL = (view.calcDiffTileX(pixRect.left - view.getCenterPointX(), pixRect.top - view.getCenterPointY()) + view.getXTile());
float yT = (view.calcDiffTileY(pixRect.left - view.getCenterPointX(), pixRect.top - view.getCenterPointY()) + view.getYTile()) ;
float ts = view.getSourceTileSize();
rotatedTileBox.set(xL * mult, yT * mult, ((float) pixRect.width()) / ts , ((float) pixRect.height()) / ts, view.getRotate(), view.getFloatZoom());
}
public boolean isVectorDataVisible() {
@ -118,21 +116,23 @@ public class MapVectorLayer extends BaseMapLayer {
if (bmp != null && bmpLoc != null) {
float rot = bmpLoc.getRotate();
float mult = (float) MapUtils.getPowZoom(view.getZoom() - bmpLoc.getZoom());
float fmult = (float) MapUtils.getPowZoom(view.getFloatZoom() - bmpLoc.getZoom());
float tx = view.getXTile();
float ty = view.getYTile();
float dleftX1 = (bmpLoc.getLeftTileX() * mult - tx) ;
float dtopY1 = (bmpLoc.getTopTileY() * mult - ty);
float tx = view.getXTile() / mult;
float ty = view.getYTile() / mult;
float dleftX1 = bmpLoc.getLeftTileX() - tx;
float dtopY1 = bmpLoc.getTopTileY() - ty;
float ts = view.getSourceTileSize() * fmult;
float cos = bmpLoc.getRotateCos();
float sin = bmpLoc.getRotateSin();
float x1 = MapUtils.calcDiffPixelX(sin, cos, dleftX1, dtopY1, view.getTileSize()) + view.getCenterPointX();
float y1 = MapUtils.calcDiffPixelY(sin, cos, dleftX1, dtopY1, view.getTileSize()) + view.getCenterPointY();
float x1 = MapUtils.calcDiffPixelX(sin, cos, dleftX1, dtopY1, ts) + view.getCenterPointX();
float y1 = MapUtils.calcDiffPixelY(sin, cos, dleftX1, dtopY1, ts) + view.getCenterPointY();
canvas.rotate(-rot, view.getCenterPointX(), view.getCenterPointY());
destImage.set(x1, y1, x1 + bmpLoc.getTileWidth() * mult * view.getTileSize(), y1 + bmpLoc.getTileHeight() * mult
* view.getTileSize());
destImage.set(x1, y1, x1 + bmpLoc.getTileWidth() * ts, y1 +
bmpLoc.getTileHeight() * ts);
if(!bmp.isRecycled()){
canvas.drawBitmap(bmp, null, destImage, paintImg);
shown = true;

View file

@ -160,8 +160,6 @@ public class OsmandRenderer {
Bitmap bmp, RenderingRuleSearchRequest render, final List<IMapDownloaderCallback> notifyList) {
long now = System.currentTimeMillis();
if (rc.width > 0 && rc.height > 0 && searchResultHandler != null) {
// init rendering context
rc.tileDivisor = (int) (1 << (31 - rc.zoom));
rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
try {
@ -201,8 +199,6 @@ public class OsmandRenderer {
cv.drawColor(rc.defaultColor);
}
if (objects != null && !objects.isEmpty() && rc.width > 0 && rc.height > 0) {
// init rendering context
rc.tileDivisor = (int) (1 << (31 - rc.zoom));
rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE;

View file

@ -653,7 +653,7 @@ public class RouteCalculationResult {
return null;
}
public AlarmInfo getMostImportantAlarm(Location fromLoc, AlarmInfo speedAlarm) {
public AlarmInfo getMostImportantAlarm(Location fromLoc, AlarmInfo speedAlarm, boolean showCameras) {
int aInfo = currentDirectionInfo;
int cRoute = currentRoute;
AlarmInfo mostImportant = speedAlarm;
@ -676,7 +676,7 @@ public class RouteCalculationResult {
}
float time = speed > 0 ? d / speed : 0;
int vl = inf.updateDistanceAndGetPriority(time, d);
if(vl < value){
if(vl < value && (!showCameras || inf.getType() == AlarmInfo.SPEED_CAMERA)){
mostImportant = inf;
value = vl;
}

View file

@ -175,15 +175,18 @@ public class RoutingHelper {
makeUturnWhenPossible = false;
return locationProjection;
}
boolean calculateRoute = false;
synchronized (this) {
// 0. Route empty or needs to be extended? Then re-calculate route.
if(route.isEmpty()) {
calculateRoute = true;
} else {
float posTolerance = POSITION_TOLERANCE;
if(currentLocation.hasAccuracy()) {
posTolerance = POSITION_TOLERANCE / 3 + currentLocation.getAccuracy();
}
// 1. Update current route position status according to latest received location
boolean finished = updateCurrentRouteStatus(currentLocation);
boolean finished = updateCurrentRouteStatus(currentLocation, posTolerance);
if (finished) {
return null;
}
@ -191,10 +194,10 @@ public class RoutingHelper {
int currentRoute = route.currentRoute;
// 2. Analyze if we need to recalculate route
// >120m off current route (sideways)
// >100m off current route (sideways)
if (currentRoute > 0) {
double dist = getOrthogonalDistance(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute));
if (dist > 2 * POSITION_TOLERANCE) {
if (dist > 1.7 * posTolerance) {
log.info("Recalculate route, because correlation : " + dist); //$NON-NLS-1$
calculateRoute = true;
}
@ -202,21 +205,24 @@ public class RoutingHelper {
// 3. Identify wrong movement direction (very similar to 2?)
Location next = route.getNextRouteLocation();
boolean wrongMovementDirection = checkWrongMovementDirection(currentLocation, next);
if (wrongMovementDirection && currentLocation.distanceTo(routeNodes.get(currentRoute)) > 2 * POSITION_TOLERANCE) {
if (wrongMovementDirection && currentLocation.distanceTo(routeNodes.get(currentRoute)) > posTolerance) {
log.info("Recalculate route, because wrong movement direction: " + currentLocation.distanceTo(routeNodes.get(currentRoute))); //$NON-NLS-1$
calculateRoute = true;
}
// 4. Identify if UTurn is needed
boolean uTurnIsNeeded = identifyUTurnIsNeeded(currentLocation);
boolean uTurnIsNeeded = identifyUTurnIsNeeded(currentLocation, posTolerance);
// 5. Update Voice router
if (calculateRoute == false || uTurnIsNeeded == true) {
voiceRouter.updateStatus(currentLocation, uTurnIsNeeded);
boolean inRecalc = calculateRoute || isRouteBeingCalculated();
if (!inRecalc && !uTurnIsNeeded) {
voiceRouter.updateStatus(currentLocation);
} else if (uTurnIsNeeded) {
voiceRouter.makeUTStatus();
}
// calculate projection of current location
if (currentRoute > 0) {
double dist = getOrthogonalDistance(currentLocation, routeNodes.get(currentRoute - 1), routeNodes.get(currentRoute));
double projectDist = mode == ApplicationMode.CAR ? POSITION_TOLERANCE : POSITION_TOLERANCE / 2;
double projectDist = mode == ApplicationMode.CAR ? posTolerance : posTolerance / 2;
locationProjection = new Location(locationProjection);
if (dist < projectDist) {
Location nextLocation = routeNodes.get(currentRoute);
@ -270,7 +276,7 @@ public class RoutingHelper {
return index;
}
private boolean updateCurrentRouteStatus(Location currentLocation) {
private boolean updateCurrentRouteStatus(Location currentLocation, float posTolerance) {
List<Location> routeNodes = route.getImmutableLocations();
int currentRoute = route.currentRoute;
// 1. Try to proceed to next point using orthogonal distance (finding minimum orthogonal dist)
@ -296,7 +302,7 @@ public class RoutingHelper {
}
} else if (newDist < dist || newDist < 10) {
// newDist < 10 (avoid distance 0 till next turn)
if (dist > POSITION_TOLERANCE) {
if (dist > posTolerance) {
processed = true;
if (log.isDebugEnabled()) {
log.debug("Processed by distance : " + newDist + " " + dist); //$NON-NLS-1$//$NON-NLS-2$
@ -331,7 +337,7 @@ public class RoutingHelper {
// 2. check if destination found
Location lastPoint = routeNodes.get(routeNodes.size() - 1);
if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < POSITION_TOLERANCE) {
if (currentRoute > routeNodes.size() - 3 && currentLocation.distanceTo(lastPoint) < posTolerance * 1.5) {
showMessage(context.getString(R.string.arrived_at_destination));
voiceRouter.arrivedDestinationPoint();
clearCurrentRoute(null);
@ -341,7 +347,7 @@ public class RoutingHelper {
}
public boolean identifyUTurnIsNeeded(Location currentLocation) {
public boolean identifyUTurnIsNeeded(Location currentLocation, float posTolerance) {
if (finalLocation == null || currentLocation == null || !route.isCalculated()) {
this.makeUturnWhenPossible = false;
return makeUturnWhenPossible;
@ -357,7 +363,7 @@ public class RoutingHelper {
if (Math.abs(diff) > 135f) {
float d = currentLocation.distanceTo(nextRoutePosition);
// 60m tolerance to allow for GPS inaccuracy
if (d > POSITION_TOLERANCE) {
if (d > posTolerance) {
if (makeUTwpDetected == 0) {
makeUTwpDetected = System.currentTimeMillis();
// require 5 sec since first detection, to avoid false positive announcements
@ -467,7 +473,7 @@ public class RoutingHelper {
return i;
}
public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc){
public synchronized AlarmInfo getMostImportantAlarm(MetricsConstants mc, boolean showCameras){
float mxspeed = route.getCurrentMaxSpeed();
AlarmInfo speedAlarm = null;
if(mxspeed != 0 && lastFixedLocation != null && lastFixedLocation.hasSpeed()) {
@ -482,13 +488,13 @@ public class RoutingHelper {
speedAlarm = AlarmInfo.createSpeedLimit(speed);
}
}
return route.getMostImportantAlarm(lastFixedLocation, speedAlarm);
return route.getMostImportantAlarm(lastFixedLocation, speedAlarm, showCameras);
}
public String formatStreetName(String name, String ref) {
if(name != null && name.length() > 0){
if(ref != null && ref.length() > 0) {
name += "(" + ref +")";
name = ref + " " + name;
}
return name;
} else {

View file

@ -160,11 +160,22 @@ public class VoiceRouter {
return currentStatus <= statusToCheck;
}
protected void makeUTStatus() {
// Mechanism via STATUS_UTWP_TOLD: Until turn in the right direction, or route is re-calculated in forward direction
if (currentStatus != STATUS_UTWP_TOLD) {
if (playMakeUTwp()) {
currentStatus = STATUS_UTWP_TOLD;
playGoAheadDist = 0;
}
}
}
/**
* Updates status of voice guidance
* @param currentLocation
*/
protected void updateStatus(Location currentLocation, boolean makeUturnWhenPossible) {
protected void updateStatus(Location currentLocation) {
// Directly after turn: goAhead (dist), unless:
// < PREPARE_LONG_DISTANCE (3000m): playPrepareTurn
// < PREPARE_DISTANCE (1500m): playPrepareTurn
@ -175,17 +186,7 @@ public class VoiceRouter {
speed = Math.max(currentLocation.getSpeed(), speed);
}
// Mechanism via STATUS_UTWP_TOLD: Until turn in the right direction, or route is re-calculated in forward direction
if (makeUturnWhenPossible == true) {
if (currentStatus != STATUS_UTWP_TOLD) {
if (playMakeUTwp()) {
currentStatus = STATUS_UTWP_TOLD;
playGoAheadDist = 0;
}
}
return;
}
NextDirectionInfo nextInfo = router.getNextRouteDirectionInfo(new NextDirectionInfo(), true);
// after last turn say:
if (nextInfo == null || nextInfo.directionInfo.distance == 0) {

View file

@ -116,7 +116,7 @@ public class LockInfoControl {
final ActionItem lockScreenAction = new ActionItem();
lockScreenAction.setTitle(view.getResources().getString(
isScreenLocked ? R.string.bg_service_screen_unlock : R.string.bg_service_screen_lock));
lockScreenAction.setIcon(view.getResources().getDrawable(isScreenLocked ? R.drawable.lock_disabled : R.drawable.lock_enabled));
lockScreenAction.setIcon(view.getResources().getDrawable(isScreenLocked ? R.drawable.lock_enabled : R.drawable.lock_disabled));
lockScreenAction.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -321,7 +321,7 @@ public class MapInfoLayer extends OsmandMapLayer {
flp = new FrameLayout.LayoutParams((int)(78 * scaleCoefficient),
(int)(78 * scaleCoefficient), Gravity.RIGHT | Gravity.BOTTOM);
flp.rightMargin = STATUS_BAR_MARGIN_X;
flp.rightMargin = (int) (10*scaleCoefficient);
flp.bottomMargin = (int) (85*scaleCoefficient);
alarmControl.setLayoutParams(flp);
@ -617,7 +617,7 @@ public class MapInfoLayer extends OsmandMapLayer {
if (!text.equals(getText().toString())) {
TextPaint pp = new TextPaint(getPaint());
if (!text.equals("")) {
pp.setTextSize(25 * scaleCoefficient);
pp.setTextSize(20 * scaleCoefficient);
float ts = pp.measureText(text);
int wth = getWidth();
while (ts > wth && pp.getTextSize() > (14 * scaleCoefficient)) {

View file

@ -103,7 +103,7 @@ public class NextTurnInfoControl extends MapInfoControl {
canvas.translate(0, 3 * scaleCoefficient);
canvas.drawPath(pathForTurn, paintRouteDirection);
canvas.drawPath(pathForTurn, paintBlack);
if (exitOut != null && !horisontalMini) {
if (exitOut != null && !horisontalMini && !makeUturnWhenPossible) {
drawShadowText(canvas, exitOut, width / 2 - 7 * scaleCoefficient,
height / 2 + textPaint.getTextSize() / 2 - 3 * scaleCoefficient, textPaint);
}

View file

@ -16,6 +16,8 @@ import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.router.TurnType;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
@ -516,6 +518,7 @@ public class RouteInfoControls {
paintCircle.setStrokeWidth(11 * scaleCoefficient);
paintCircle.setStyle(Style.STROKE);
paintCircle.setAntiAlias(true);
paintCircle.setDither(true);
final Paint content = new Paint();
content.setColor(Color.WHITE);
content.setStyle(Style.FILL);
@ -527,18 +530,22 @@ public class RouteInfoControls {
final MapInfoControl alarm = new MapInfoControl(ctx) {
private String text = "";
private Bitmap img = null;
private int imgId;
@Override
public boolean updateInfo() {
boolean limits = settings.SHOW_SPEED_LIMITS.get();
boolean cams = settings.SHOW_CAMERAS.get();
boolean visible = false;
if ((limits || cams) && routingHelper != null && routingHelper.isFollowingMode()) {
AlarmInfo alarm = routingHelper.getMostImportantAlarm(settings.METRIC_SYSTEM.get());
AlarmInfo alarm = routingHelper.getMostImportantAlarm(settings.METRIC_SYSTEM.get(), cams);
if(alarm != null) {
int locimgId = 0;
if(alarm.getType() == AlarmInfo.SPEED_LIMIT) {
text = alarm.getIntValue() +"";
} else if(alarm.getType() == AlarmInfo.SPEED_CAMERA) {
text = "CAM";
locimgId = R.drawable.warnings_speed_camera;
} else if(alarm.getType() == AlarmInfo.BORDER_CONTROL) {
text = "CLO";
} else if(alarm.getType() == AlarmInfo.TOLL_BOOTH) {
@ -546,6 +553,7 @@ public class RouteInfoControls {
} else if(alarm.getType() == AlarmInfo.TRAFFIC_CALMING) {
// temporary omega
text = "~^~";
locimgId = R.drawable.warnings_speed_bump;
} else if(alarm.getType() == AlarmInfo.STOP) {
// text = "STOP";
}
@ -557,6 +565,16 @@ public class RouteInfoControls {
visible = limits;
}
}
if(visible) {
if(locimgId != imgId) {
imgId = locimgId;
if(imgId == 0) {
img = null;
} else {
img = BitmapFactory.decodeResource(getResources(), locimgId);
}
}
}
}
}
updateVisibility(visible);
@ -565,10 +583,14 @@ public class RouteInfoControls {
@Override
protected void onDraw(Canvas canvas) {
RectF f = new RectF(th / 2, th / 2, getWidth() - th / 2, getHeight() - th / 2);
canvas.drawOval(f, content);
canvas.drawOval(f, paintCircle);
canvas.drawText(text, getWidth() / 2, getHeight() / 2 + ptext.descent() + 3 * scaleCoefficient, ptext);
if(img == null) {
RectF f = new RectF(th / 2, th / 2, getWidth() - th / 2, getHeight() - th / 2);
canvas.drawOval(f, content);
canvas.drawOval(f, paintCircle);
canvas.drawText(text, getWidth() / 2, getHeight() / 2 + ptext.descent() + 3 * scaleCoefficient, ptext);
} else {
canvas.drawBitmap(img, 0, 0, paintCircle);
}
}
};

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>