我正在尝试将城市的经度/纬度位置转换为笛卡儿,以便我可以将其转换为像素位置以显示在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
答案 0 :(得分:1)
您使用的是什么map projection?纬度/经度可以直接用作圆柱投影中的y / x - 这是最简单的游戏方式。否则,转换将完全取决于投影的选择。
答案 1 :(得分:0)
我过去遇到过类似的问题,this帮助我度过了这个问题