Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0230314

Browse files
committed
Testing points in file
1 parent beb915b commit 0230314

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

srtm/data.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,16 @@ def __init__(self, file_name, data):
220220
self.square_side = int(square_side)
221221

222222
def get_elevation(self, latitude, longitude):
223-
start_latitude, start_longitude = self.latitude, self.longitude
224-
225223
if not (self.latitude <= latitude < self.latitude + 1):
226224
raise Exception('Invalid latitude %s for file %s' % (latitude, self.file_name))
227225
if not (self.longitude <= longitude < self.longitude + 1):
228226
raise Exception('Invalid longitude %s for file %s' % (longitude, self.file_name))
229227

230228
points = self.square_side ** 2
231229

232-
row = int(mod_math.floor((start_latitude + 1 - latitude) * float(self.square_side - 1)))
233-
column = int(mod_math.floor((longitude - start_longitude) * float(self.square_side - 1)))
230+
pdb.set_trace()
231+
row = int(mod_math.floor((self.latitude + 1 - latitude) * float(self.square_side - 1)))
232+
column = int(mod_math.floor((longitude - self.longitude) * float(self.square_side - 1)))
234233

235234
return self.get_elevation_from_row_and_column(row, column)
236235

test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,13 @@ def test_invalit_file(self):
8787
geo_elevation_data = mod_srtm.get_data()
8888
geo_file = geo_elevation_data.get_file(-47.0, -13.99)
8989
self.assertEquals(None, geo_file)
90+
91+
def test_coordinates_in_file(self):
92+
geo_elevation_data = mod_srtm.get_data()
93+
geo_file = geo_elevation_data.get_file(47.0, 13.99)
94+
95+
print 'file:', geo_file
96+
97+
self.assertEquals(geo_file.get_elevation(47, 13),
98+
geo_file.get_elevation(47, 13))
99+

0 commit comments

Comments
 (0)