tkintermapview 1.29__tar.gz → 1.30__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (19) hide show
  1. {tkintermapview-1.29 → tkintermapview-1.30}/PKG-INFO +20 -2
  2. {tkintermapview-1.29 → tkintermapview-1.30}/setup.py +2 -2
  3. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/__init__.py +1 -2
  4. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/map_widget.py +32 -13
  5. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/utility_functions.py +0 -11
  6. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview.egg-info/PKG-INFO +20 -2
  7. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview.egg-info/requires.txt +2 -0
  8. {tkintermapview-1.29 → tkintermapview-1.30}/LICENSE.txt +0 -0
  9. {tkintermapview-1.29 → tkintermapview-1.30}/README.md +0 -0
  10. {tkintermapview-1.29 → tkintermapview-1.30}/setup.cfg +0 -0
  11. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/canvas_button.py +0 -0
  12. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/canvas_path.py +0 -0
  13. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/canvas_polygon.py +0 -0
  14. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/canvas_position_marker.py +0 -0
  15. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/canvas_tile.py +0 -0
  16. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview/offline_loading.py +0 -0
  17. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview.egg-info/SOURCES.txt +0 -0
  18. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview.egg-info/dependency_links.txt +0 -0
  19. {tkintermapview-1.29 → tkintermapview-1.30}/tkintermapview.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tkintermapview
3
- Version: 1.29
3
+ Version: 1.30
4
4
  Summary: A python Tkinter widget to display image tile maps like OpenStreetMap or Satellite Images.
5
5
  Home-page: https://github.com/TomSchimansky/TkinterMapView
6
6
  Author: Tom Schimansky
@@ -11,5 +11,23 @@ Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
+ Requires-Dist: geopy
15
+ Requires-Dist: certifi
16
+ Requires-Dist: geocoder
17
+ Requires-Dist: pillow
18
+ Requires-Dist: requests
19
+ Requires-Dist: pyperclip
20
+ Requires-Dist: pywin32; platform_system == "Windows"
21
+ Requires-Dist: customtkinter
22
+ Dynamic: author
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: license
28
+ Dynamic: license-file
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
14
32
 
15
33
  **Detailed Information: https://github.com/TomSchimansky/TkinterMapView**
@@ -9,7 +9,7 @@ from setuptools import setup
9
9
  # 5. python3.10 -m twine upload dist/*
10
10
 
11
11
  setup(name="tkintermapview",
12
- version="1.29",
12
+ version="1.30",
13
13
  author="Tom Schimansky",
14
14
  license="Creative Commons Zero v1.0 Universal",
15
15
  url="https://github.com/TomSchimansky/TkinterMapView",
@@ -20,5 +20,5 @@ setup(name="tkintermapview",
20
20
  classifiers=["Operating System :: OS Independent",
21
21
  "Programming Language :: Python :: 3",
22
22
  "License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication"],
23
- install_requires=["geocoder", "pillow", "requests", "pyperclip", 'pywin32; platform_system=="Windows"', "customtkinter"],
23
+ install_requires=["geopy", "certifi", "geocoder", "pillow", "requests", "pyperclip", 'pywin32; platform_system=="Windows"', "customtkinter"],
24
24
  python_requires=">=3.6")
@@ -1,7 +1,6 @@
1
- __version__ = "1.29"
1
+ __version__ = "1.30"
2
2
 
3
3
  from .map_widget import TkinterMapView
4
4
  from .offline_loading import OfflineLoader
5
5
  from .utility_functions import convert_coordinates_to_address, convert_coordinates_to_country, convert_coordinates_to_city
6
- from .utility_functions import convert_address_to_coordinates
7
6
  from .utility_functions import decimal_to_osm, osm_to_decimal
@@ -10,7 +10,10 @@ import sys
10
10
  import io
11
11
  import sqlite3
12
12
  import pyperclip
13
- import geocoder
13
+ import ssl
14
+ import certifi
15
+ from geopy.geocoders import Nominatim
16
+ from geopy.exc import GeocoderTimedOut, GeocoderUnavailable
14
17
  from PIL import Image, ImageTk
15
18
  from typing import Callable, List, Dict, Union, Tuple
16
19
  from functools import partial
@@ -323,7 +326,7 @@ class TkinterMapView(tkinter.Frame):
323
326
 
324
327
  self.check_map_border_crossing()
325
328
  self.draw_initial_array()
326
- # self.draw_move() ausreichend?
329
+ # self.draw_move() enough?
327
330
 
328
331
  return marker_object
329
332
 
@@ -331,17 +334,32 @@ class TkinterMapView(tkinter.Frame):
331
334
  """ Function uses geocode service of OpenStreetMap (Nominatim).
332
335
  https://geocoder.readthedocs.io/providers/OpenStreetMap.html """
333
336
 
334
- result = geocoder.osm(address_string)
337
+ ssl_ctx = ssl.create_default_context(cafile=certifi.where())
338
+ geolocator = Nominatim(user_agent="TkinterMapView/1.0 (contact@customtkinter.tomschimansky.com)", ssl_context=ssl_ctx)
335
339
 
336
- if result.ok:
340
+ try:
341
+ location = geolocator.geocode(address_string)
342
+ except (GeocoderTimedOut, GeocoderUnavailable) as e:
343
+ print(f"Geocoding error: {e}")
344
+ return False
345
+
346
+ if location:
347
+
348
+ # 2. Extract bounding box from the raw Nominatim response
349
+ # Nominatim format: ['lat_min', 'lat_max', 'lon_min', 'lon_max']
350
+ raw_bbox = location.raw.get("boundingbox")
337
351
 
338
- # determine zoom level for result by bounding box
339
- if hasattr(result, "bbox"):
352
+ if raw_bbox:
340
353
  zoom_not_possible = True
341
354
 
355
+ # Convert string coordinates to floats and map them to SW / NE
356
+ lat_min, lat_max, lon_min, lon_max = map(float, raw_bbox)
357
+ southwest = (lat_min, lon_min)
358
+ northeast = (lat_max, lon_max)
359
+
342
360
  for zoom in range(self.min_zoom, self.max_zoom + 1):
343
- lower_left_corner = decimal_to_osm(*result.bbox['southwest'], zoom)
344
- upper_right_corner = decimal_to_osm(*result.bbox['northeast'], zoom)
361
+ lower_left_corner = decimal_to_osm(*southwest, zoom)
362
+ upper_right_corner = decimal_to_osm(*northeast, zoom)
345
363
  tile_width = upper_right_corner[0] - lower_left_corner[0]
346
364
 
347
365
  if tile_width > math.floor(self.width / self.tile_size):
@@ -354,13 +372,14 @@ class TkinterMapView(tkinter.Frame):
354
372
  else:
355
373
  self.set_zoom(10)
356
374
 
375
+ # 3. Retrieve the formatted address text
357
376
  if text is None:
358
- try:
359
- text = result.geojson['features'][0]['properties']['address']
360
- except:
361
- text = address_string
377
+ # geopy provides a beautifully formatted address out of the box
378
+ text = location.address if location.address else address_string
379
+
380
+ # 4. Set the position using the extracted coordinates
381
+ return self.set_position(location.latitude, location.longitude, marker=marker, text=text, **kwargs)
362
382
 
363
- return self.set_position(*result.latlng, marker=marker, text=text, **kwargs)
364
383
  else:
365
384
  return False
366
385
 
@@ -40,14 +40,3 @@ def convert_coordinates_to_city(deg_x: float, deg_y: float) -> str:
40
40
  def convert_coordinates_to_country(deg_x: float, deg_y: float) -> str:
41
41
  """ returns country name """
42
42
  return geocoder.osm([deg_x, deg_y], method="reverse").country
43
-
44
-
45
- def convert_address_to_coordinates(address_string: str) -> tuple:
46
- """ returns address object for given coords or None if no address found """
47
-
48
- result = geocoder.osm(address_string)
49
-
50
- if result.ok:
51
- return tuple(result.latlng)
52
- else:
53
- return None
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: tkintermapview
3
- Version: 1.29
3
+ Version: 1.30
4
4
  Summary: A python Tkinter widget to display image tile maps like OpenStreetMap or Satellite Images.
5
5
  Home-page: https://github.com/TomSchimansky/TkinterMapView
6
6
  Author: Tom Schimansky
@@ -11,5 +11,23 @@ Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
11
11
  Requires-Python: >=3.6
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE.txt
14
+ Requires-Dist: geopy
15
+ Requires-Dist: certifi
16
+ Requires-Dist: geocoder
17
+ Requires-Dist: pillow
18
+ Requires-Dist: requests
19
+ Requires-Dist: pyperclip
20
+ Requires-Dist: pywin32; platform_system == "Windows"
21
+ Requires-Dist: customtkinter
22
+ Dynamic: author
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: license
28
+ Dynamic: license-file
29
+ Dynamic: requires-dist
30
+ Dynamic: requires-python
31
+ Dynamic: summary
14
32
 
15
33
  **Detailed Information: https://github.com/TomSchimansky/TkinterMapView**
@@ -1,3 +1,5 @@
1
+ geopy
2
+ certifi
1
3
  geocoder
2
4
  pillow
3
5
  requests
File without changes
File without changes
File without changes