How to use the haversine.distance function in haversine

To help you get started, we’ve selected a few haversine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Piera / SnowBase / MVC / app.py View on Github external
geohash_str = place + '%'
		neighbor = dbsession.query(model.Station_Geohash).\
			select_from(model.Station_Geohash).\
			filter(model.Station_Geohash.geohash_loc.ilike(geohash_str)).\
			all()
		neighborhoods = neighborhoods + neighbor
	dist_list = []
	# For all of the stations found in neighborhoods, check for data and snow. 
	# If there is data and snow for a given station, add it to the heap
	for location in neighborhoods:
		try: 
			station = dbsession.query(model.Station).filter(model.Station.id == location.station_id).one()
			snow = station.snow_data[-1]
			origin = float(l), float(g)
			destination = float(station.latitude), float(station.longitude)
			kms = int(distance(origin, destination))
			mi = int(0.621371*kms)
			if snow.depth != None and snow.depth > 0:
				if snow.water_equiv != None and snow.water_equiv != 0:
					density = (int((snow.water_equiv / snow.depth) * 100))
					if density > 100:
							density = 100
				else: 
					density = "No Data" 
				dist_list.append({'dist':mi, 'text-code':station.id, 'id':station.given_id, 'ele':station.elevation,\
					'lat':station.latitude, 'lng':station.longitude, 'name':station.name, 'depth':snow.depth,\
				'depth_change':snow.depth_change, 'density':density, 'date':snow.date.strftime("%m/%d/%y %H:%M")})
			else:
				continue
		except IndexError:
			continue
	# Return the 10 closest stations, their distances away in miles (converted from kms)

haversine

Calculate the distance between 2 points on Earth.

MIT
Latest version published 6 months ago

Package Health Score

71 / 100
Full package analysis