2012-04-09 227 views
2

我想將城市的經度/緯度位置轉換爲笛卡爾座標,然後我可以將它轉換爲像素位置以顯示在pygame屏幕上,但我無法計算出它。試圖將經度/緯度轉換爲笛卡爾座標

def ConvertPoint(self, Long, Lat, height, width): 
    self.x = Long 
    self.y = Lat 
    self.x = angleToPointX(self.x, self.y, 3959) 
    self.y = angleToPointY(self.x, self.y, 3959) 
    pygame.draw.circle(self.window, (255,0,0), (int(self.x), int(self.y)), 5) 
    print(self.x, self.y) 

功能:

def angleToPointX(lat, long, magnitude=1.0): 
    V = (math.cos(lat) * math.cos(long)) 
    return V 

def angleToPointY(lat, long, magnitude=1.0): 
    V = (math.sin(lat)) 
    return V 
+1

可能重複(http://stackoverflow.com/questions/1185408/轉換經度 - 緯度 - 笛卡爾座標) – 2012-04-09 20:55:44

+2

那麼你的問題是什麼? – 2012-04-09 20:55:46

+0

就像列夫說的那樣,問題是什麼? – 2012-04-09 20:56:11

回答

1

您正在使用什麼map projection?緯度/經度可以直接用作圓柱投影中的y/x - 這是進行遊戲的最簡單方法。否則,轉換將完全取決於投影的選擇。

+0

根據問題中的代碼判斷,我猜Mollweide。 – 2012-04-09 22:31:28

0

我已經遇到了類似的問題在過去和this就是幫助我度過[從經度\緯度轉換爲直角座標]它

相關問題