From 4cec45384ef4603e5bd1b6456ce43e4d14fbb52f Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 29 Apr 2010 08:04:05 +0000 Subject: [PATCH] Set encoding UTF-8 git-svn-id: https://osmand.googlecode.com/svn/trunk@20 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8 --- .../.settings/org.eclipse.core.resources.prefs | 3 +++ DataExtractionOSM/src/com/osmand/osm/MapUtils.java | 11 +++++++++++ OsmAnd/.settings/org.eclipse.core.resources.prefs | 3 +++ OsmAnd/src/com/osmand/MapActivity.java | 12 +++--------- 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 DataExtractionOSM/.settings/org.eclipse.core.resources.prefs create mode 100644 OsmAnd/.settings/org.eclipse.core.resources.prefs diff --git a/DataExtractionOSM/.settings/org.eclipse.core.resources.prefs b/DataExtractionOSM/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..0b4ace9acd --- /dev/null +++ b/DataExtractionOSM/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Thu Apr 29 00:40:46 EEST 2010 +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/DataExtractionOSM/src/com/osmand/osm/MapUtils.java b/DataExtractionOSM/src/com/osmand/osm/MapUtils.java index 52648b735d..50346bbcec 100644 --- a/DataExtractionOSM/src/com/osmand/osm/MapUtils.java +++ b/DataExtractionOSM/src/com/osmand/osm/MapUtils.java @@ -108,6 +108,17 @@ public class MapUtils { return (int) ((getTileNumberX(zoom, long1) - getTileNumberX(zoom, long2)) * tileSize); } + + public static int getLengthXFromMeters(int zoom, double latitude, double longitude, double meters, int tileSize, int widthOfDisplay) { + double tileNumberX = MapUtils.getTileNumberX(zoom, longitude); + double tileNumberLeft = tileNumberX - ((double) widthOfDisplay) / (2d * tileSize); + double tileNumberRight = tileNumberX + ((double) widthOfDisplay) / (2d * tileSize); + double dist = getDistance(latitude, getLongitudeFromTile(zoom, tileNumberLeft), latitude, getLongitudeFromTile(zoom, + tileNumberRight)); + + return (int) ((double) widthOfDisplay / dist * meters); + } + public static int getPixelShiftY(int zoom, double lat1, double lat2, int tileSize){ return (int) ((getTileNumberY(zoom, lat1) - getTileNumberY(zoom, lat2)) * tileSize); } diff --git a/OsmAnd/.settings/org.eclipse.core.resources.prefs b/OsmAnd/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..9bf033b12b --- /dev/null +++ b/OsmAnd/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +#Thu Apr 29 00:40:57 EEST 2010 +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/OsmAnd/src/com/osmand/MapActivity.java b/OsmAnd/src/com/osmand/MapActivity.java index c6d6f8649a..f64d8b1b22 100644 --- a/OsmAnd/src/com/osmand/MapActivity.java +++ b/OsmAnd/src/com/osmand/MapActivity.java @@ -115,15 +115,9 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat int newY = MapUtils.getPixelShiftY(mapView.getZoom(), lastKnownLocation.getLatitude(), mapView.getLatitude() , mapView.getTileSize()) + mapView.getHeight()/2; - // TODO clear radius & specify bearing! - double tileNumberX = MapUtils.getTileNumberX(mapView.getZoom(), mapView.getLongitude()); - double tileNumberLeft = tileNumberX - ((double)mapView.getWidth()) / (2d * mapView.getTileSize()); - double dist = MapUtils.getDistance(mapView.getLatitude(), - MapUtils.getLongitudeFromTile(mapView.getZoom(),tileNumberLeft), mapView.getLatitude(), - MapUtils.getLongitudeFromTile(mapView.getZoom(),tileNumberX)); - - int radius = (int) ((mapView.getWidth()/ (2d*dist))* lastKnownLocation.getAccuracy()); - + // TODO specify bearing! + int radius = MapUtils.getLengthXFromMeters(mapView.getZoom(), mapView.getLatitude(), mapView.getLongitude(), + lastKnownLocation.getAccuracy(), mapView.getTileSize(), mapView.getWidth()); pointOfView.setLocationX(newX); pointOfView.setLocationY(newY);