Skip to content

Commit

Permalink
Merge pull request #31 from ckc-org/improve-lat-long-code-style
Browse files Browse the repository at this point in the history
Improve code style and documentation
  • Loading branch information
gibsonbailey authored Sep 22, 2022
2 parents e57961d + a2462a0 commit 4a6e1b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, 3.10.5]
python-version: [3.8, 3.9, 3.10.x]
django-version: ['<4', '>=4']

steps:
Expand Down
11 changes: 7 additions & 4 deletions ckc/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ class DjangoGeoPointProvider(BaseProvider):
"""

def geo_point(self, **kwargs):
kwargs['coords_only'] = True
faker = factory.faker.faker.Faker()

# local_latlng returns something like:
# local_latlng normally returns something like:
# ('40.72371', '-73.95097', 'Greenpoint', 'US', 'America/New_York')
coords = faker.local_latlng(**kwargs)
return Point(x=float(coords[1]), y=float(coords[0]), srid=4326)
# with coords_only kwarg, it returns something like:
# ('40.72371', '-73.95097')
kwargs.setdefault('coords_only', True)
lat, lon, *_ = faker.local_latlng(**kwargs)
# Point calls for longitude as x and latitude as y
return Point(x=float(lon), y=float(lat), srid=4326)
except (ImportError, ImproperlyConfigured):
pass

0 comments on commit 4a6e1b7

Please sign in to comment.