From 749df0207b8b295a9c9d2c6d3766e6431ac1691a Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Tue, 27 Dec 2016 18:14:04 -0800 Subject: [PATCH 1/6] Corrected relative and Python 3 imports --- ModestMaps/BlueMarble.py | 8 ++++---- ModestMaps/CloudMade.py | 9 +++++---- ModestMaps/Geo.py | 2 +- ModestMaps/MapQuest.py | 9 +++++---- ModestMaps/Microsoft.py | 9 +++++---- ModestMaps/OpenStreetMap.py | 8 ++++---- ModestMaps/Providers.py | 4 ++-- ModestMaps/Stamen.py | 9 +++++---- ModestMaps/Yahoo.py | 8 ++++---- ModestMaps/__init__.py | 26 +++++++++++++++++--------- 10 files changed, 52 insertions(+), 40 deletions(-) diff --git a/ModestMaps/BlueMarble.py b/ModestMaps/BlueMarble.py index 31729b6..c2397c0 100644 --- a/ModestMaps/BlueMarble.py +++ b/ModestMaps/BlueMarble.py @@ -8,11 +8,11 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import Tiles +from . import Tiles class Provider(IMapProvider): def __init__(self): diff --git a/ModestMaps/CloudMade.py b/ModestMaps/CloudMade.py index 6f9478f..de5f000 100644 --- a/ModestMaps/CloudMade.py +++ b/ModestMaps/CloudMade.py @@ -30,11 +30,12 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import random, Tiles +import random +from . import Tiles class BaseProvider(IMapProvider): def __init__(self, apikey, style=None): diff --git a/ModestMaps/Geo.py b/ModestMaps/Geo.py index 55e67d4..01b4557 100644 --- a/ModestMaps/Geo.py +++ b/ModestMaps/Geo.py @@ -44,7 +44,7 @@ """ import math -from Core import Point, Coordinate +from .Core import Point, Coordinate class Location: def __init__(self, lat, lon): diff --git a/ModestMaps/MapQuest.py b/ModestMaps/MapQuest.py index c5f1b08..53b5380 100644 --- a/ModestMaps/MapQuest.py +++ b/ModestMaps/MapQuest.py @@ -14,11 +14,12 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import random, Tiles +import random +from . import Tiles class AbstractProvider(IMapProvider): def __init__(self): diff --git a/ModestMaps/Microsoft.py b/ModestMaps/Microsoft.py index 3918400..43aaada 100644 --- a/ModestMaps/Microsoft.py +++ b/ModestMaps/Microsoft.py @@ -20,11 +20,12 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import random, Tiles +import random +from . import Tiles class AbstractProvider(IMapProvider): def __init__(self): diff --git a/ModestMaps/OpenStreetMap.py b/ModestMaps/OpenStreetMap.py index 5519222..39fe924 100644 --- a/ModestMaps/OpenStreetMap.py +++ b/ModestMaps/OpenStreetMap.py @@ -8,11 +8,11 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import Tiles +from . import Tiles class Provider(IMapProvider): def __init__(self): diff --git a/ModestMaps/Providers.py b/ModestMaps/Providers.py index e2934b6..9404ff9 100644 --- a/ModestMaps/Providers.py +++ b/ModestMaps/Providers.py @@ -1,8 +1,8 @@ import re from math import pi, pow -from Core import Coordinate -from Geo import LinearProjection, MercatorProjection, deriveTransformation +from .Core import Coordinate +from .Geo import LinearProjection, MercatorProjection, deriveTransformation ids = ('MICROSOFT_ROAD', 'MICROSOFT_AERIAL', 'MICROSOFT_HYBRID', 'YAHOO_ROAD', 'YAHOO_AERIAL', 'YAHOO_HYBRID', diff --git a/ModestMaps/Stamen.py b/ModestMaps/Stamen.py index 57b942d..ed02e32 100644 --- a/ModestMaps/Stamen.py +++ b/ModestMaps/Stamen.py @@ -18,11 +18,12 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import random, Tiles +import random +from . import Tiles class BaseProvider(IMapProvider): def __init__(self, style, tile_format='png'): diff --git a/ModestMaps/Yahoo.py b/ModestMaps/Yahoo.py index 52ae84d..0cfcda5 100644 --- a/ModestMaps/Yahoo.py +++ b/ModestMaps/Yahoo.py @@ -20,11 +20,11 @@ from math import pi -from Core import Coordinate -from Geo import MercatorProjection, deriveTransformation -from Providers import IMapProvider +from .Core import Coordinate +from .Geo import MercatorProjection, deriveTransformation +from .Providers import IMapProvider -import Tiles +from . import Tiles ROAD_VERSION = '3.52' AERIAL_VERSION = '1.7' diff --git a/ModestMaps/__init__.py b/ModestMaps/__init__.py index 5777fa7..95be552 100644 --- a/ModestMaps/__init__.py +++ b/ModestMaps/__init__.py @@ -68,13 +68,21 @@ import sys import urllib -import httplib -import urlparse -import StringIO import math -import thread import time +try: + import httplib + import urlparse + import StringIO + import thread +except ImportError: + # Python 3 + import http.client as httplib + import urllib.parse as urlparse + from io import StringIO + import _thread as thread + try: import Image except ImportError: @@ -85,11 +93,11 @@ # maybe that's not what you're using MMaps for? Image = None -import Tiles -import Providers -import Core -import Geo -import Yahoo, Microsoft, BlueMarble, OpenStreetMap, CloudMade, MapQuest, Stamen +from . import Tiles +from . import Providers +from . import Core +from . import Geo +from . import Yahoo, Microsoft, BlueMarble, OpenStreetMap, CloudMade, MapQuest, Stamen import time # a handy list of possible providers, which isn't From 72510670e29c7e225bc51c701b2c9b8ee5efaa47 Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Tue, 27 Dec 2016 18:14:23 -0800 Subject: [PATCH 2/6] Fixed Python 2/3 octal conversion --- ModestMaps/Tiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModestMaps/Tiles.py b/ModestMaps/Tiles.py index bfcfb00..b288fca 100644 --- a/ModestMaps/Tiles.py +++ b/ModestMaps/Tiles.py @@ -83,7 +83,7 @@ def toBinaryString(i): """ return ''.join([octalStrings[int(c)] for c - in oct(i)]).lstrip('0') + in oct(i).lstrip('0o')]).lstrip('0') def fromBinaryString(s): """ Return an integer for a binary string. From fdc1f2ae5f4a0867c4f3e149f97cdd0534bc7b42 Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Tue, 27 Dec 2016 18:20:43 -0800 Subject: [PATCH 3/6] Fixed Python 2/3 use of map() --- ModestMaps/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModestMaps/__init__.py b/ModestMaps/__init__.py index 95be552..bace711 100644 --- a/ModestMaps/__init__.py +++ b/ModestMaps/__init__.py @@ -182,7 +182,7 @@ def calculateMapExtent(provider, width, height, *args): returns the coordinate of an initial tile and its point placement, relative to the map center. """ - coordinates = map(provider.locationCoordinate, args) + coordinates = list(map(provider.locationCoordinate, args)) TL = Core.Coordinate(min([c.row for c in coordinates]), min([c.column for c in coordinates]), From 4eb7fc318cc9a54e9a8f4c78e8823c977e1d29c3 Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Tue, 27 Dec 2016 18:20:59 -0800 Subject: [PATCH 4/6] Fixed floating point jiggle --- ModestMaps/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ModestMaps/__init__.py b/ModestMaps/__init__.py index bace711..b6c0d68 100644 --- a/ModestMaps/__init__.py +++ b/ModestMaps/__init__.py @@ -2,7 +2,7 @@ >>> m = Map(Microsoft.RoadProvider(), Core.Point(600, 600), Core.Coordinate(3165, 1313, 13), Core.Point(-144, -94)) >>> p = m.locationPoint(Geo.Location(37.804274, -122.262940)) >>> p -(370.724, 342.549) +(370.752, 342.626) >>> m.pointLocation(p) (37.804, -122.263) From e4da132c4899ee2d8747119560e0a26104d2d93a Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Tue, 27 Dec 2016 18:22:43 -0800 Subject: [PATCH 5/6] Fixed Python 2/3 print function --- ModestMaps/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ModestMaps/__init__.py b/ModestMaps/__init__.py index b6c0d68..bf436f8 100644 --- a/ModestMaps/__init__.py +++ b/ModestMaps/__init__.py @@ -1,3 +1,4 @@ +from __future__ import print_function """ >>> m = Map(Microsoft.RoadProvider(), Core.Point(600, 600), Core.Coordinate(3165, 1313, 13), Core.Point(-144, -94)) >>> p = m.locationPoint(Geo.Location(37.804274, -122.262940)) @@ -229,7 +230,7 @@ def printlocked(lock, *stuff): """ """ if lock.acquire(): - print >> sys.stderr, ' '.join([str(thing) for thing in stuff]) + print(' '.join([str(thing) for thing in stuff]), file=sys.stderr) lock.release() class TileRequest: From 524d5d36bdedc4995f06cdefaaa82546c41a75c2 Mon Sep 17 00:00:00 2001 From: Michal Migurski Date: Tue, 27 Dec 2016 18:24:23 -0800 Subject: [PATCH 6/6] Bumped to 1.4.7 with Python 3 support --- CHANGELOG | 3 +++ ModestMaps/VERSION | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 70ba09c..8944193 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +2016-12-27: 1.4.7 +- Added Python 3 support. + 2014-05-10: 1.4.6 - Moved VERSION to setup package_data so it will actually work. diff --git a/ModestMaps/VERSION b/ModestMaps/VERSION index c514bd8..be05bba 100644 --- a/ModestMaps/VERSION +++ b/ModestMaps/VERSION @@ -1 +1 @@ -1.4.6 +1.4.7