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

Skip to content

Commit e7960e1

Browse files
committed
+ test_neighbour_points()
1 parent bd9b6f0 commit e7960e1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
import logging as mod_logging
2525
import unittest as mod_unittest
26+
import math as mod_math
27+
2628
import srtm as mod_srtm
2729
import srtm.utils as mod_utils
2830

@@ -172,3 +174,25 @@ def test_rows_and_columns(self):
172174
row_1, column_1 = elevation_file.get_row_and_column(47, 13)
173175
row_2, column_2 = elevation_file.get_row_and_column(47 - d * 1.1, 13)
174176
self.assertEquals(row_1, row_2 - 1)
177+
178+
def test_neighbour_points(self):
179+
elevation_data = mod_srtm.get_data()
180+
for i in range(1000):
181+
latitude = 47 + i / 5000.
182+
longitude = 13 + i / 5000.
183+
184+
print 'point:', latitude, longitude
185+
186+
elevation_file = elevation_data.get_file(latitude, longitude)
187+
d = 1. / elevation_file.square_side
188+
d_meters = d * mod_utils.ONE_DEGREE
189+
190+
point_1, point_2, point_3, point_4 = elevation_file.get_neighbour_points(latitude, longitude)
191+
192+
print 'Neighbour points:'
193+
print point_1
194+
print point_2
195+
print point_3
196+
print point_4
197+
198+
self.assertTrue(mod_utils.distance(point_1[0], point_1[1], latitude, longitude) < d_meters * mod_math.sqrt(2.))

0 commit comments

Comments
 (0)