Ejemplo n.º 1
0
	def get_driving_path_length_list(self, driving_area):
		driving_length = {}
		for i in range(len(driving_area)):
			length = len(driving_area[i])				
			path_length_sum = 0
			if(length>1):
				start_index = driving_area[i][0]
				end_index = driving_area[i][length-1]
				if(end_index!=self.column_length):
					end_index = end_index+1
				valid_point_list = []
				for j in range(start_index, end_index):
					if(self.__is_valid_data(j)):
						valid_point_list.append(j)
				for j in range(len(valid_point_list)):
					if(j>0):
						start_lon = float(self.ws['D' + str(valid_point_list[j-1])].value)
						start_lat = float(self.ws['E' + str(valid_point_list[j-1])].value)
						end_lon = float(self.ws['D' + str(valid_point_list[j])].value)
						end_lat = float(self.ws['E' + str(valid_point_list[j])].value)
						dist = calc_distance(start_lon, start_lat, end_lon, end_lat)
						path_length_sum = path_length_sum+dist
				
			driving_length[i] = path_length_sum
		return 	driving_length
Ejemplo n.º 2
0
	def __is_valid_dist_interval(self, index_list):#if max distance bigger than 3km
		max_dist = 0
		for i in index_list:
			for j in index_list:
				lon1 = float(self.ws['D' + str(i)].value)
				lat1 = float(self.ws['E' + str(i)].value)
				lon2 = float(self.ws['D' + str(j)].value)
				lat2 = float(self.ws['E' + str(j)].value)
				dist = calc_distance(lon1, lat1, lon2, lat2)
				if(dist>max_dist):
					max_dist = dist
		if(max_dist>DIST_THRESHOLD):
			return False
		
		return True
Ejemplo n.º 3
0
	def get_car_stop_area(self, speed_zero_index_list):#return the car stop area row lists
		icount = 0
		car_stop_area = {}
		car_stop_list = []
		for i in range(len(speed_zero_index_list)):
			if(i<len(speed_zero_index_list)-1):
				lon1 = float(self.ws['D' + str(speed_zero_index_list[i])].value)
				lat1 = float(self.ws['E' + str(speed_zero_index_list[i])].value)
				lon2 = float(self.ws['D' + str(speed_zero_index_list[i+1])].value)
				lat2 = float(self.ws['E' + str(speed_zero_index_list[i+1])].value)
				dist = calc_distance(lon1, lat1, lon2, lat2)
				if(dist<AREA_DIST_THRESHOLD):
					car_stop_list.append(speed_zero_index_list[i])
				else:
					car_stop_list.append(speed_zero_index_list[i])
					car_stop_area[icount] = car_stop_list
					car_stop_list = []
					icount = icount + 1
		return car_stop_area
Ejemplo n.º 4
0
	def get_driving_ave_speed(self, driving_area):
		driving_area_ave_speed = {}
		for i in range(len(driving_area)):
			j = driving_area[i][0]
			path_sum = 0
			time_sum = 0
			while(j<=driving_area[i][1]):
				if(j<self.column_length and self.__is_valid_data(j) and self.__is_valid_data(j+1)):
					lon_start = float(self.ws['D' + str(j)].value)
					lat_start = float(self.ws['E' + str(j)].value)
					lon_end = float(self.ws['D' + str(j+1)].value)
					lat_end = float(self.ws['E' + str(j+1)].value)
					path = calc_distance(lon_start, lat_start, lon_end, lat_end)
					path_sum = path_sum + path
					
					start_time = str(self.ws['I' + str(j)].value)			
					end_time = str(self.ws['I' + str(j+1)].value)

					interval = (datetime.strptime(end_time, '%Y-%m-%d %H:%M:%S')-datetime.strptime(start_time, '%Y-%m-%d %H:%M:%S')).seconds/(60*60)
					time_sum = time_sum + interval
				j = j+1
			driving_area_ave_speed[i] = path_sum/time_sum
		return driving_area_ave_speed
Ejemplo n.º 5
0
def test():
	distance = calc_distance(121.306216, 31.353354, 121.185040, 31.405485)
	print(distance)#km