Exemplo n.º 1
0
 def _compute_distance(self, row):
     pt0 = row['prev_pt']
     pt1 = row['geometry']
     if type(pt0) != Point:
         return 0.0
     if pt0 == pt1:
         return 0.0
     if self.is_latlon():
         dist_meters = measure_distance_spherical(pt0, pt1)
     else:  # The following distance will be in CRS units that might not be meters!
         dist_meters = measure_distance_euclidean(pt0, pt1)
     return dist_meters  
Exemplo n.º 2
0
 def _compute_speed(self, row):
     pt0 = row['prev_pt']
     pt1 = row['geometry']
     if type(pt0) != Point:
         return 0.0
     if type(pt1) != Point:
         raise ValueError('Invalid trajectory! Got {} instead of point!'.format(pt1))
     if pt0 == pt1:
         return 0.0
     if self.is_latlon():
         dist_meters = measure_distance_spherical(pt0, pt1)
     else:  # The following distance will be in CRS units that might not be meters!
         dist_meters = measure_distance_euclidean(pt0, pt1)
     return dist_meters / row['delta_t'].total_seconds()
 def test_spherical_distance(self):
     assert measure_distance_spherical(Point(
         -74.00597, 40.71427), Point(-118.24368,
                                     34.05223)) == pytest.approx(3935735)
 def test_measure_distance_spherical_throws_type_error(self):
     with pytest.raises(TypeError):
         measure_distance_spherical((0, 0), (0, 1))