使用 iso60709 位置仅获取纬度和经度的正值
当我运行以下代码时,由于某种原因负号被删除,并且我总是得到正的纬度和经度。
代码:
def extract_reduced_accuracy_lat_long(location):
if location:
loc = Location(location)
print("location is")
print(loc)
lat = round(float(loc.lat.degrees), 1)
lng = round(float(loc.lng.degrees), 1)
return lat, lng
else:
return None, None
lat, long = extract_reduced_accuracy_lat_long("-40.20361-40.20361")
print(lat)
print(long)
输出:
location is
<iso6709.iso6709.Location object at 0x7fc37447ae10>
40.2
40.2
知道为什么会发生这种情况。谢谢
When I run the following code the negative sign get's removed for some reason and I always end up with a positive latitude and longitude.
Code:
def extract_reduced_accuracy_lat_long(location):
if location:
loc = Location(location)
print("location is")
print(loc)
lat = round(float(loc.lat.degrees), 1)
lng = round(float(loc.lng.degrees), 1)
return lat, lng
else:
return None, None
lat, long = extract_reduced_accuracy_lat_long("-40.20361-40.20361")
print(lat)
print(long)
output:
location is
<iso6709.iso6709.Location object at 0x7fc37447ae10>
40.2
40.2
Any idea why this is happening. Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
让我们尝试将坐标括在括号中,如下所示:
Let's try to wrap in parentheses your coordinates like this:
您必须使用支架来包含坐标点。这样,它就在逗号分开的参数上取了两点。像这样:
You must use brackets to contain your coordinate points. This way it is taking two points at arguments, separated by a comma. Like so: