コード例 #1
0
def build_map():
	for i in range(-90, 91):
		for j in range(-180, 181):
			id = i.__str__() + "/" + j.__str__()
			upper_left = Point(i, j)
			upper_right = Point(i + 1, j)
			lower_left = Point(i, j + 1)
			lower_right = Point(i + 1, j + 1) 
			coordinates = Coordinates(upper_right, upper_left, lower_right, lower_left)
			new_cell = Cell(id, coordinates)
			map_cells.update({id : new_cell})
コード例 #2
0
multi_qt = []

reals = {}

map_cells = {}
all_products ={}


for i in range(-90, 91):
	for j in range(-180, 181):
		id = i.__str__() + "/" + j.__str__()
		upper_left = Point(i, j)
		upper_right = Point(i + 1, j)
		lower_left = Point(i, j + 1)
		lower_right = Point(i + 1, j + 1) 
		coordinates = Coordinates(upper_right, upper_left, lower_right, lower_left)
		new_cell = Cell(id, coordinates)
		map_cells.update({id : new_cell})

def get_dist(loc1, loc2):
	parts1 = loc1.split('/')
	parts2 = loc2.split('/')
	x1 = float(parts1[0]) + 0.5
	x2 = float(parts2[0]) + 0.5
	y1 = float(parts1[1]) + 0.5
	y2 = float(parts2[1]) + 0.5
	# res = math.sqrt(math.pow((x1 - x2), 2) + math.pow((y1 - y2), 2 ))
	p1 = (x1, y1)
	p2 = (x2, y2)
	res = great_circle(p1, p2).kilometers
	return res