|
21 | 21 |
|
22 | 22 | import pdb
|
23 | 23 |
|
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 |
27 | 28 |
|
28 | 29 | mod_logging.basicConfig(level=mod_logging.DEBUG,
|
29 | 30 | format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s')
|
@@ -142,3 +143,32 @@ def test_approximation(self):
|
142 | 143 |
|
143 | 144 | self.assertNotEquals(elevation_with_approximation, elevation_without_approximation)
|
144 | 145 | 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