Я создал другой вопрос ( Как отобразить карту (файл неподвижного изображения) с текущим текущим местоположением )
Но он содержит 2 (два) вопроса, поэтому мне нужновыделите его.
Я пытаюсь создать прототип, который мог бы направить человека к месту его назначения.
- Это широкое здание с несколькими этажами.
- Я могу получить / получить карты (неподвижные изображения). например, ток: 1F пункт назначения: 5F;так что я могу получить неподвижные изображения 1-го, 2-го ... 5-го этажей (5 файлов изображений).
Сценарий:
- запустите приложение
- введите текущее местоположение (или можете автоматически установить его, используя текущее местоположение) и пункт назначения
- нажмите кнопку поиска маршрута для поиска карт для использования (фотографии) и отметки текущегоlocation & destination
- обновлять текущее местоположение при перемещении / переходе к месту назначения
Проблема: Я могу получить координату текущего местоположения через WiFi / cell tower / ipадрес, но не знаю, как поместить его в неподвижное изображение, чтобы отметить текущее местоположение.
Не могли бы вы поделиться концепциями / идеями или включить фрагменты кода .Большая помощь в моей диссертации.
Любые указания в правильном направлении приветствуются.
ОБНОВЛЕНИЕ
Фактический пример с фактическим, Ожидаемый результат, контрольный пример (посылка кодов здесь получена от mapsforge)
MercatorProjectionClass.java
/**
* A performance optimized implementation of the spherical Mercator projection.
*/
class MercatorProjectionClass {
/**
* Width and height of a map tile in pixel.
*/
static final int TILE_SIZE = 256;
/**
* Converts a latitude coordinate (in degrees) to a pixel Y coordinate at a certain zoom level.
*
* @param latitude
* the latitude coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the pixel Y coordinate of the latitude value.
*/
static double latitudeToPixelY(double latitude, byte zoom) {
double sinLatitude = Math.sin(latitude * (Math.PI / 180));
return (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI))
* ((long) TILE_SIZE << zoom);
}
/**
* Converts a latitude coordinate (in degrees) to a tile Y number at a certain zoom level.
*
* @param latitude
* the latitude coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the tile Y number of the latitude value.
*/
static long latitudeToTileY(double latitude, byte zoom) {
return pixelYToTileY(latitudeToPixelY(latitude, zoom), zoom);
}
/**
* Converts a longitude coordinate (in degrees) to a pixel X coordinate at a certain zoom level.
*
* @param longitude
* the longitude coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the pixel X coordinate of the longitude value.
*/
static double longitudeToPixelX(double longitude, byte zoom) {
return (longitude + 180) / 360 * ((long) TILE_SIZE << zoom);
}
/**
* Converts a longitude coordinate (in degrees) to the tile X number at a certain zoom level.
*
* @param longitude
* the longitude coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the tile X number of the longitude value.
*/
static long longitudeToTileX(double longitude, byte zoom) {
return pixelXToTileX(longitudeToPixelX(longitude, zoom), zoom);
}
/**
* Converts a pixel X coordinate at a certain zoom level to a longitude coordinate.
*
* @param pixelX
* the pixel X coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the longitude value of the pixel X coordinate.
*/
static double pixelXToLongitude(double pixelX, byte zoom) {
return 360 * ((pixelX / ((long) TILE_SIZE << zoom)) - 0.5);
}
/**
* Converts a pixel X coordinate to the tile X number.
*
* @param pixelX
* the pixel X coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the tile X number.
*/
static long pixelXToTileX(double pixelX, byte zoom) {
return (long) Math.min(Math.max(pixelX / TILE_SIZE, 0), Math.pow(2, zoom) - 1);
}
/**
* Converts a pixel Y coordinate at a certain zoom level to a latitude coordinate.
*
* @param pixelY
* the pixel Y coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the latitude value of the pixel Y coordinate.
*/
static double pixelYToLatitude(double pixelY, byte zoom) {
double y = 0.5 - (pixelY / ((long) TILE_SIZE << zoom));
return 90 - 360 * Math.atan(Math.exp(-y * (2 * Math.PI))) / Math.PI;
}
/**
* Converts a pixel Y coordinate to the tile Y number.
*
* @param pixelY
* the pixel Y coordinate that should be converted.
* @param zoom
* the zoom level at which the coordinate should be converted.
* @return the tile Y number.
*/
static long pixelYToTileY(double pixelY, byte zoom) {
return (long) Math.min(Math.max(pixelY / TILE_SIZE, 0), Math.pow(2, zoom) - 1);
}
private static final byte ZOOM_LEVEL = 14;
/**
* @param args
*/
public static void main(String[] args) {
// Pixel Coordinate of Chicago,IL
double pixel_y = 1559345;
double pixel_x = 1075954;
// Lat Lng of Chicago,IL
double lat_y = 41.850033;
double lng_x = -87.65005229999997;
testPixelXYToLatitude(pixel_y, pixel_x, lat_y, lng_x);
testLatLngToPixelXY(pixel_y, pixel_x, lat_y, lng_x);
}
private static void testPixelXYToLatitude(
double pixel_y, double pixel_x,
double lat_y, double lng_x) {
double actual_lat_y = MercatorProjectionClass.pixelYToLatitude(pixel_y, ZOOM_LEVEL);
double actual_lng_x = MercatorProjectionClass.pixelXToLongitude(pixel_x, ZOOM_LEVEL);
String expectedstr_lat_y = Double.toString(lat_y).substring(0, 5);
String expectedstr_lng_x = Double.toString(lng_x).substring(0, 6);
String actualstr_lat_y = Double.toString(actual_lat_y).substring(0, 5);
String actualstr_lng_x = Double.toString(actual_lng_x).substring(0, 6);
String result = (actualstr_lat_y.equals(expectedstr_lat_y) && actualstr_lng_x.equals(expectedstr_lng_x))?"PASSED":"FAILED";
System.out.println("PixelXYToLatitude test result:" + result);
}
private static void testLatLngToPixelXY(
double pixel_y, double pixel_x,
double lat_y, double lng_x) {
double actual_pixel_y = MercatorProjectionClass.latitudeToPixelY(lat_y, ZOOM_LEVEL);
double actual_pixel_x = MercatorProjectionClass.longitudeToPixelX(lng_x, ZOOM_LEVEL);
String expectedstr_pixel_y = Integer.toString((Double.valueOf(pixel_y).intValue()));
String expectedstr_pixel_x = Integer.toString((Double.valueOf(pixel_x).intValue()));
String actualstr_pixel_y = Integer.toString(Double.valueOf(actual_pixel_y).intValue());
String actualstr_pixel_x = Integer.toString(Double.valueOf(actual_pixel_x).intValue());
String result = (actualstr_pixel_y.equals(expectedstr_pixel_y) && actualstr_pixel_x.equals(expectedstr_pixel_x))?"PASSED":"FAILED";
System.out.println("LatLngToPixelXY test result:" + result);
}
}
Вывод вышеуказанного кода:
- Результат теста PixelXYToLatitude: PASSED
- Результат теста LatLngToPixelXY: PASSED
У меня уже есть класс проекции для преобразования LatLng в пиксель.Моя проблема сейчас заключается в том, как пометить в неподвижное изображение данного LatLng с помощью вышеуказанного класса.
Вот мое неподвижное изображение (Чикаго, Иллинойс):
![Here's my still image (Chicago,IL)](https://i.stack.imgur.com/luPEi.png)
Я хочу поставить отметку (вот пример, но позже нужно поменять шарик на меньший указатель)
![I want to put a mark (here's the example but change the balloon to pointer)](https://i.stack.imgur.com/4wpjW.jpg)