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

long is also a valid type #57

Merged
merged 5 commits into from Jun 26, 2015
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There need to be two spaces before the #


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