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

Skip to content

Commit bd9b6f0

Browse files
committed
+ test_rows_and_columns()
1 parent 4ab9b71 commit bd9b6f0

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

test.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121

2222
import pdb
2323

24-
import logging as mod_logging
25-
import unittest as mod_unittest
26-
import srtm as mod_srtm
24+
import logging as mod_logging
25+
import unittest as mod_unittest
26+
import srtm as mod_srtm
27+
import srtm.utils as mod_utils
2728

2829
mod_logging.basicConfig(level=mod_logging.DEBUG,
2930
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
@@ -142,3 +143,32 @@ def test_approximation(self):
142143

143144
self.assertNotEquals(elevation_with_approximation, elevation_without_approximation)
144145
self.assertTrue(abs(elevation_with_approximation - elevation_without_approximation) < 30)
146+
147+
def test_rows_and_columns(self):
148+
elevation_data = mod_srtm.get_data()
149+
elevation_file = elevation_data.get_file(47.0, 13.99)
150+
print elevation_file.latitude
151+
print elevation_file.longitude
152+
print elevation_file.square_side
153+
154+
d = 1. / elevation_file.square_side
155+
d_meters = d * mod_utils.ONE_DEGREE
156+
157+
row_1, column_1 = elevation_file.get_row_and_column(47, 13)
158+
row_2, column_2 = elevation_file.get_row_and_column(47 - d * .5, 13)
159+
self.assertEquals(row_1, row_2)
160+
self.assertEquals(column_1, column_2)
161+
162+
row_1, column_1 = elevation_file.get_row_and_column(47, 13)
163+
row_2, column_2 = elevation_file.get_row_and_column(47, 13 + d * .5)
164+
self.assertEquals(row_1, row_2)
165+
self.assertEquals(column_1, column_2)
166+
167+
row_1, column_1 = elevation_file.get_row_and_column(47, 13)
168+
row_2, column_2 = elevation_file.get_row_and_column(47, 13 + d * 1.1)
169+
self.assertEquals(row_1, row_2)
170+
self.assertEquals(column_1, column_2 - 1)
171+
172+
row_1, column_1 = elevation_file.get_row_and_column(47, 13)
173+
row_2, column_2 = elevation_file.get_row_and_column(47 - d * 1.1, 13)
174+
self.assertEquals(row_1, row_2 - 1)

0 commit comments

Comments
 (0)