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/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/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. 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 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..bf436f8 100644 --- a/ModestMaps/__init__.py +++ b/ModestMaps/__init__.py @@ -1,8 +1,9 @@ +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)) >>> p -(370.724, 342.549) +(370.752, 342.626) >>> m.pointLocation(p) (37.804, -122.263) @@ -68,13 +69,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 +94,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 @@ -174,7 +183,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]), @@ -221,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: