Skip to content

Commit

Permalink
chg: dev: Migrate from LatLon to GeoPy for Py3 compatibility.
Browse files Browse the repository at this point in the history
Closes #130
  • Loading branch information
ashmastaflash committed Jan 6, 2019
1 parent a57edae commit 6712872
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Testing is done with pytest. Coverage module optional.
Testing requirements (local testing possible only on Linux):
* lshw
* pip packages: pytest-cov pytest-pep8 pyserial hvac kalibrate haversine
python-geoip python-geoip-geolite2 pyudev gps3 LatLon python-dateutil
python-geoip python-geoip-geolite2 pyudev gps3 geopy python-dateutil


1. Navigate to the base directory of the repository.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
psutil==5.4.8
pyserial==3.4
pyyaml==4.2b1
geopy==1.18.1
gps3==0.33.3
hvac==0.7.1
kalibrate==2.1.0
Expand All @@ -9,4 +10,3 @@ python-dateutil==2.7.5
python-geoip==1.2
python-geoip-geolite2==2015.303
pyudev==0.21.0
LatLon==1.0.2
14 changes: 7 additions & 7 deletions sitch/sitchlib/feed_schema_translator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""This is the object that translates from source feed to sensor schema."""
from string import Template
import LatLon
import geopy


class FeedSchemaTranslator(object):
Expand Down Expand Up @@ -39,10 +39,10 @@ def translators_from_schema(cls, fields):
@classmethod
def latlon_trans_fcc(cls, row):
"""returns dict with lat, lon"""
latlon = {}
lat_pre = Template('$LOC_LAT_DEG $LOC_LAT_MIN $LOC_LAT_SEC $LOC_LAT_DIR').substitute(row) # NOQA
lon_pre = Template('$LOC_LONG_DEG $LOC_LONG_MIN $LOC_LONG_SEC $LOC_LONG_DIR').substitute(row) # NOQA
ll = LatLon.string2latlon(lat_pre, lon_pre, "d% %m% %S% %H")
latlon["lat"] = ll.to_string('D%')[0]
latlon["lon"] = ll.to_string('D%')[1]
lat_t = '$LOC_LAT_DEG ${LOC_LAT_MIN}m ${LOC_LAT_SEC}s $LOC_LAT_DIR'
lon_t = '$LOC_LONG_DEG ${LOC_LONG_MIN}m ${LOC_LONG_SEC}s $LOC_LONG_DIR'
lat = Template(lat_t).substitute(row)
lon = Template(lon_t).substitute(row)
point = geopy.point.Point(" ".join([lat, lon]))
latlon = {"lat": point.latitude, "lon" = point.longitude}
return latlon

0 comments on commit 6712872

Please sign in to comment.