@@ -231,6 +231,24 @@ def get_row_and_column(self, latitude, longitude):
231
231
return mod_math .floor ((self .latitude + 1 - latitude ) * float (self .square_side - 1 )), \
232
232
mod_math .floor ((longitude - self .longitude ) * float (self .square_side - 1 ))
233
233
234
+ def get_neighbour_points (self , latitude , longitude ):
235
+ d = 1. / self .square_side
236
+ d_meters = d * mod_utils .ONE_DEGREE
237
+
238
+ row , column = self .get_row_and_column (latitude , longitude )
239
+
240
+ point_1 = self .latitude + 1 - row * d , self .longitude + column * d
241
+ point_2 = self .latitude + 1 - (row + 1 ) * d , self .longitude + column * d
242
+ point_3 = self .latitude + 1 - row * d , self .longitude + (column + 1 ) * d
243
+ point_4 = self .latitude + 1 - (row + 1 ) * d , self .longitude + (column + 1 ) * d
244
+
245
+ assert latitude <= point_1 [0 ] and point_1 [1 ] <= longitude
246
+ assert point_2 [0 ] <= latitude and point_2 [1 ] <= longitude
247
+ assert latitude <= point_3 [0 ] and longitude <= point_3 [1 ]
248
+ assert point_2 [0 ] <= latitude and longitude <= point_4 [1 ]
249
+
250
+ return point_1 , point_2 , point_3 , point_4
251
+
234
252
def get_elevation (self , latitude , longitude , approximate = None ):
235
253
"""
236
254
If approximate is True then only the points from SRTM grid will be
@@ -256,20 +274,8 @@ def approximation(self, latitude, longitude):
256
274
Dummy approximation with nearest points. The nearest the neighbour the
257
275
more important will be its elevation.
258
276
"""
259
- d = 1. / self .square_side
260
- d_meters = d * mod_utils .ONE_DEGREE
261
-
262
- row , column = self .get_row_and_column (latitude , longitude )
263
-
264
- point_1 = self .latitude + 1 - row * d , self .longitude + column * d
265
- point_2 = self .latitude + 1 - (row + 1 ) * d , self .longitude + column * d
266
- point_3 = self .latitude + 1 - row * d , self .longitude + (column + 1 ) * d
267
- point_4 = self .latitude + 1 - (row + 1 ) * d , self .longitude + (column + 1 ) * d
268
277
269
- assert latitude <= point_1 [0 ] and point_1 [1 ] <= longitude
270
- assert point_2 [0 ] <= latitude and point_2 [1 ] <= longitude
271
- assert latitude <= point_3 [0 ] and longitude <= point_3 [1 ]
272
- assert point_2 [0 ] <= latitude and longitude <= point_4 [1 ]
278
+ point_1 , point_2 , point_3 , point_4 = self .get_neighbour_points (latitude , longitude )
273
279
274
280
# Since the less the distance => the more important should be the
275
281
# distance of the point, we'll use d-distance as importance coef
0 commit comments