1

似乎有很多关于从经度和纬度转换为 X 和 Y 坐标的知识,但反之则不然。

这是我的一个基于 Kavrayskiy 数学的函数

  float xp = kavraX(radians(pv.x), radians(pv.y))*FACTOR;
  float yp = kavraY(radians(pv.x), radians(pv.y))*FACTOR;

// mapping -- this gives you screen X and Y coords from LAT and LONG
float kavraX (float latitude, float longitude) // Kavra for Kavrayskiy 
// formula from http://en.wikipedia.org/wiki/Kavrayskiy_VII_projection
{
  return ((3 * longitude) / TWO_PI)*sqrt(pow(PI, 2)/3 - pow(latitude, 2));
} 

float kavraY (float latitude, float longitude) 
{
  return latitude*-1;
} 

在这种情况下,pv.x 可能只是 34(对于 LA),在这种情况下,pv.y 将是 -118。不过,我很难扭转这个等式。有任何想法吗?

4

1 回答 1

2

好的,基于数学@维基百科,我设法扭转了这个等式

  // find latitude from Y coord
    // height / 2 to make middle of map ZERO, *-1 to flip it, so south of equator is negative.
    // divide by FACTOR to make it fit within bounds of larger map
  float reMapY = ((mouseY - (height/2))*-1)/FACTOR;
  println(degrees(reMapY));

  // I have no idea what I'm doing
  float temp = sqrt((pow(PI,2)/3 - pow(reMapY,2)));
  float reMapX = (mouseX - (width/2))/FACTOR;
  float temp2 = ((reMapX / temp) * TWO_PI) / 3;
  println(degrees(temp2));

请记住,FACTOR 是我设计中固有的东西,因为我的地图的大小。我相信它应该是宽度 = 5.47 * FACTOR。

于 2013-11-08T02:28:27.460 回答