Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drawing a polygon with one edge along the south pole returns error #142

Open
PizzaTreeIsland opened this issue Jun 29, 2024 · 0 comments
Open

Comments

@PizzaTreeIsland
Copy link

Hi,

this code:

import tkinter as tk  
import tkintermapview  
  
  
root = tk.Tk()  
map = tkintermapview.TkinterMapView(root, height=1000, width=1000)  
polygon = map.set_polygon([(-35.0, -10.0), (-35.0, 15.0), (-90.0, 15.0), (-90.0, -10.0), (-35.0, -10.0)])  
  
map.pack()  
root.mainloop()

returns this error:

Traceback (most recent call last):
  File "Z:/OverpassBBoxStitcher/test.py", line 7, in <module>
    polygon = map.set_polygon([(-35.0, -10.0), (-35.0, 15.0), (-90.0, 15.0), (-90.0, -10.0), (-35.0, -10.0)])
  File "Python36\site-packages\tkintermapview\map_widget.py", line 381, in set_polygon
    polygon.draw()
  File "Python36\site-packages\tkintermapview\canvas_polygon.py", line 101, in draw
    canvas_position = self.get_canvas_pos(position, widget_tile_width, widget_tile_height)
  File "Python36\site-packages\tkintermapview\canvas_polygon.py", line 74, in get_canvas_pos
    tile_position = decimal_to_osm(*position, round(self.map_widget.zoom))
  File "Python36\site-packages\tkintermapview\utility_functions.py", line 12, in decimal_to_osm
    ytile = (1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n
ValueError: math domain error

I will work around this issue by clamping all the south values to -89.99999, but that feels hacky and un-elegant.
For the north pole, a similar issue does not occur.

This is what I want it to look like:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant