Skip to content

Commit

Permalink
Merge pull request #165 from njwilson23/fix145
Browse files Browse the repository at this point in the history
fixes issue #145
  • Loading branch information
Scisco committed Mar 24, 2016
2 parents f0c229b + 49883cf commit 14f6408
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
11 changes: 9 additions & 2 deletions landsat/landsat.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,15 @@ def main(args):
s = Search()

try:
lat = float(args.lat) if args.lat else None
lon = float(args.lon) if args.lon else None
if args.lat is not None:
lat = float(args.lat)
else:
lat = None

if args.lon is not None:
lon = float(args.lon)
else:
lon = None
except ValueError:
return ["The latitude and longitude values must be valid numbers", 1]

Expand Down
2 changes: 1 addition & 1 deletion landsat/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def query_builder(self, paths_rows=None, lat=None, lon=None, address=None, start

if address:
query.append(self.address_builder(address))
elif lat and lon:
elif (lat is not None) and (lon is not None):
query.append(self.lat_lon_builder(lat, lon))

if query:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def test_search(self):
result = self.s.search(lat=lat, lon=lon, start_date=start_date, end_date=end_date)
self.assertEqual('2015-02-06', result['results'][0]['date'])

def test_search_zero_lon(self):
# Make sure that zero coordinates are handled correctly
paths_rows = '003,003'
lon = 0.0
lat = 52.0
start_date = '2016-01-01'
end_date = '2016-01-10'

result = self.s.search(start_date=start_date, end_date=end_date,
lon=0.0, lat=52.0)
self.assertEqual('2016-01-06', result['results'][0]['date'])

def test_search_with_geojson(self):

# TEST A REGULAR SEARCH WITH KNOWN RESULT for paths and rows
Expand Down

0 comments on commit 14f6408

Please sign in to comment.