Python - SqlAlchemy: Filter query by great circle distance?
问题 I am using Python and Sqlalchemy to store latitude and longitude values in a Sqlite database. I have created a hybrid method for my Location object, @hybrid_method def great_circle_distance(self, other): """ Tries to calculate the great circle distance between the two locations If it succeeds, it will return the great-circle distance multiplied by 3959, which calculates the distance in miles. If it cannot, it will return None. """ return math.acos( self.cos_rad_lat * other.cos_rad_lat * math