本文整理汇总了Python中feature.Feature.set_speed方法的典型用法代码示例。如果您正苦于以下问题:Python Feature.set_speed方法的具体用法?Python Feature.set_speed怎么用?Python Feature.set_speed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feature.Feature
的用法示例。
在下文中一共展示了Feature.set_speed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_reittiopas_results_to_features
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import set_speed [as 别名]
def _process_reittiopas_results_to_features(self,segments):
#Array of routes, get route
avg_km = ""
avg_speed = ""
avg_co2 = 0.00
avg_time = ""
features = []
#route
if segments != None and len(segments) > 0:
if "length" in segments:
length = str(segments["length"])
avg_km = float(float(length) / 1000)
if "duration" in segments:
time = str(segments["duration"])
avg_time = float(float(time) / 3600)
avg_speed = float(avg_km / avg_time)
for segment in segments["legs"]:
feature = Feature()
feature.set_type("LineString")
#set up feature coords
if "locs" in segment:
#coordinates nodes
coords = []
for node in segment["locs"]:
c = []
x=""
y=""
if "coord" in node:
coord = node["coord"]
if "x" in coord:
x = coord["x"]
c.append(x)
if "y" in coord:
y = coord["y"]
c.append(y)
coords.append(c)
feature.set_coords(coords)
if "type" in segment:
act = segment["type"]
activity = ""
if act == "walk":
activity = "on-foot"
elif self._is_number(act) == True:
activity = "in-vehicle"
else:
activity = "unknown"
feature.set_activity(activity)
if "length" in segment:
length = str(segment["length"])
kms = float(float(length) / 1000)
feature.set_km(kms)
if "duration" in segment:
time = str(segment["duration"])
hours = float(float(time) / 3600)
speed = float(feature.get_km() / hours)
feature.set_speed(speed)
feature.set_time(hours)
if "code" in segment:
code = str(segment["code"])
if len(code) > 1:
transport = code[1:]
type = self._interpret_type_of_transport(code[0], segment["type"])
if transport != "" and type != "":
feature.set_transport(transport)
feature.set_transport_type(type)
features.append(feature)
avg_co2 = avg_co2 + float(feature.get_co2())
#recorde trip route
self.set_features(features)
self.set_km(avg_km)
self.set_time(avg_time)
self.set_speed(avg_speed)
self.set_co2(avg_co2)
return self._build_geojson_trip()
示例2: _get_location_coordinates
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import set_speed [as 别名]
def _get_location_coordinates(feature_array, last, end_time, start_time, locations):
features = []
present_location = None
previous_location = None
distance = 0.00
segment_distances = []
activity_distances = dict()
ed_tyyppi = ""
tyyppi = ""
first_location_index=0
kms = float(6373)
for i in range(0,last):
feature = Feature()
ed_tyyppi = tyyppi
time, time1, time2 = "", "", ""
speed = 0.00
transport = ""
co2 = 0.00
seg_km = 0.00
#Setup variables
tyyppi = feature_array[i]['geometry']['type']
coords = feature_array[i]["geometry"]["coordinates"]
activity = feature_array[i]["properties"]["activity"]
start_time = locations[first_location_index].time
time = get_trip_segment_time(feature_array, last, end_time, i, start_time)
# append first_location_index
if tyyppi == 'LineString':
first_location_index += len(coords) - 1
else:
# it is a point
# and location has not changed
pass
#Setup feature
feature.set_type(tyyppi)
feature.set_coords(coords)
feature.set_activity(activity)
feature.set_time(time)
if tyyppi == "LineString" or tyyppi == "Point" or tyyppi=="Feature":
if tyyppi == "Point":
previous_location = present_location
present_location = coords
if previous_location != None and present_location != None:
if len(present_location) > 0 and len(previous_location) > 0:
distance = distance + kms*_calculate_trip_distance(present_location[1], present_location[0], previous_location[1],previous_location[0])
elif tyyppi == "LineString":
seg_km = 0.00
for coord in coords:
previous_location = present_location
present_location = coord
#logger.info(present_location, previous_location)
if previous_location != None and present_location != None:
if len(present_location) > 0 and len(previous_location) > 0:
km=kms*_calculate_trip_distance(present_location[1], present_location[0], previous_location[1],previous_location[0])
distance = distance + km
if ed_tyyppi == "LineString":
seg_km = seg_km + km
segment_distances.append(seg_km)
activity_distances[activity]=seg_km
else:
coords = feature_array[i]["geometry"]["coordinates"]
activity = feature_array[i]["properties"]["activity"]
feature.set_coords(coords)
feature.set_km(seg_km)
if (time != "" or time != None) and (seg_km > 0.00):
speed = _calculate_avg_speed(time, km)
feature.set_speed(speed)
features.append(feature)
return distance, features