Skip to content

Commit

Permalink
Merge pull request #57 from bennlich/patch-1
Browse files Browse the repository at this point in the history
`long` is also a valid type
  • Loading branch information
frewsxcv committed Jun 26, 2015
2 parents 3ef9066 + ad2d453 commit 2940ab7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion geojson/geometry.py
@@ -1,13 +1,20 @@
from decimal import Decimal

from geojson.base import GeoJSON
import sys


class Geometry(GeoJSON):
"""
Represents an abstract base class for a WGS84 geometry.
"""

if (sys.version_info[0] == 3):
# Python 3.x has no long type
JSON_compliant_types = (float, int, Decimal)
else:
JSON_compliant_types = (float, int, Decimal, long) # noqa

def __init__(self, coordinates=None, crs=None, **extra):
"""
Initialises a Geometry object.
Expand All @@ -29,7 +36,7 @@ def clean_coordinates(cls, coords):
for coord in coords:
if isinstance(coord, (list, tuple)):
cls.clean_coordinates(coord)
elif not isinstance(coord, (float, int, Decimal)):
elif not isinstance(coord, cls.JSON_compliant_types):
raise ValueError("%r is not JSON compliant number" % coord)


Expand Down

0 comments on commit 2940ab7

Please sign in to comment.