当前位置: 首页>>代码示例>>Python>>正文


Python Feature.set_transport_type方法代码示例

本文整理汇总了Python中feature.Feature.set_transport_type方法的典型用法代码示例。如果您正苦于以下问题:Python Feature.set_transport_type方法的具体用法?Python Feature.set_transport_type怎么用?Python Feature.set_transport_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在feature.Feature的用法示例。


在下文中一共展示了Feature.set_transport_type方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _process_reittiopas_results_to_features

# 需要导入模块: from feature import Feature [as 别名]
# 或者: from feature.Feature import set_transport_type [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()
     
开发者ID:apps8os,项目名称:trip-chain-game,代码行数:77,代码来源:features.py


注:本文中的feature.Feature.set_transport_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。