本文整理汇总了Python中feature.Feature.get_km方法的典型用法代码示例。如果您正苦于以下问题:Python Feature.get_km方法的具体用法?Python Feature.get_km怎么用?Python Feature.get_km使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feature.Feature
的用法示例。
在下文中一共展示了Feature.get_km方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _process_reittiopas_results_to_features
# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import get_km [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()