В настоящее время я работаю над "трекером". Цель состоит в том, чтобы поместить некоторые GPS-координаты (записанные с помощью устройства GPS) на карту статического изображения, загруженную с MapQuest (или OpenStreetMap). Для достижения этой цели я следовал следующей процедуре:
К несчастью, за одну неделю исследований и попыток мне не удалось поставить точку.
У кого-нибудь есть полное решение таких проблем?
спасибо
(Удалено: непоследовательно)
Вот пример чистого проекта
https://dl.dropboxusercontent.com/u/429726/MapSample.zip
Img: https://dl.dropboxusercontent.com/u/429726/MapSample.jpg
Добавлено несколько формул
Географические координаты> модификация ToMercator()
public System.Windows.Point ToMercator(int test = 0)
{
System.Windows.Point mercator;
double x = this.Longitude.ToMercator(test);
double y = this.Latitude.ToMercator(test);
mercator = new System.Windows.Point(x, y);
return mercator;
}
Изменение географииCoordinate> ToMercator()
public double ToMercator(int test = 0)
{
double result = 0;
switch (this.Type)
{
case(GeographicCoordinateType.Longitude):
switch (test) {
case 0:
return this.DecimalDegrees.ToRadians() * Maps.EarthGreatRadius;
case 1:
//http://jackofalltradesdeveloper.blogspot.be/2012/03/how-to-project-point-from-geography-to.html
return this.DecimalDegrees * 0.017453292519943 * 6378137;
case 2:
//http://alastaira.wordpress.com/2011/01/23/the-google-maps-bing-maps-spherical-mercator-projection/
return this.DecimalDegrees * 20037508.34 / 180;
}
break;
case(GeographicCoordinateType.Latitude):
switch (test)
{
case 0:
double latitude = this.DecimalDegrees;
if (latitude > 89.5)
{
latitude = 89.5;
}
if (latitude < -89.5)
{
latitude = -89.5;
}
double temp = Maps.EarthGreatRadius / Maps.EarthGreatRadius;
double es = 1.0 - (temp * temp);
double eccent = Math.Sqrt(es);
double phi = latitude.ToRadians();
double sinphi = Math.Sin(phi);
double con = eccent * sinphi;
double com = 0.5 * eccent;
con = Math.Pow((1.0 - con) / (1.0 + con), com);
double ts = Math.Tan(0.5 * ((Math.PI * 0.5) - phi)) / con;
double y = 0 - Maps.EarthGreatRadius * Math.Log(ts);
return y;
case 1:
double FSin = Math.Sin(this.DecimalDegrees.ToRadians());
return 6378137 / 2.0 * Math.Log((1.0 + FSin) / (1.0 - FSin));
case 2:
y = Math.Log(Math.Tan((90 + this.DecimalDegrees) * Math.PI / 360)) / (Math.PI / 180);
return y * 20037508.34 / 180;
}
break;
default:
throw new Exception();
}
return result;
}
Я пробовал формулы множителей и библиотеку Proj.Net, я всегда получаю ту же форму (-90 ° && "flatened")
Вот ответ
Географические координаты> ToMercator()
public System.Windows.Point ToMercator(int test = 0)
{
System.Windows.Point mercator;
double x = this.Longitude.ToMercator(test);
double y = this.Latitude.ToMercator(test);
mercator = new System.Windows.Point(x, y);
return mercator;
}
Должно быть
public System.Windows.Point ToMercator(int test = 0)
{
System.Windows.Point mercator;
double x = this.Latitude.ToMercator(test);
double y = this.Longitude.ToMercator(test);
mercator = new System.Windows.Point(x, y);
return mercator;
}
И GeographicCoordinate> ToMercator() должен поменять местами GeographicCoordinateType.Latitude/Longitude.
Мне также пришлось зафиксировать Y по полушарию
и работа была выполнена.
Я использовал это в прошлом для создания информации о карте на клиенте Windows Form:
Координаты карты также нужно перевести на меркатор. Вам нужны дельта x и треугольник карты и свойства изображения: конвертировать координаты lat/lon в пиксель? ,