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


Python Kml.kml方法代码示例

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


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

示例1: test_kml_filter

# 需要导入模块: from simplekml import Kml [as 别名]
# 或者: from simplekml.Kml import kml [as 别名]
    def test_kml_filter(self):
        coordinates = [
            (-76.0, 38.0, 0.0),
            (-76.0, 38.0, 10.0),
            (-76.0, 38.0, 20.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 100.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 60.0),
        ]
        filtered_out = [(0.1, 0.001, 100), (0.0, 0.0, 0)]
        # Create Coordinates
        start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        start.save()
        for coord in coordinates:
            self.create_log_element(*coord)
        for coord in filtered_out:
            self.create_log_element(*coord)
        end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        end.save()

        kml = Kml()
        UasTelemetry.kml(user=self.user,
                         logs=UasTelemetry.by_user(self.user),
                         kml=kml,
                         kml_doc=kml)

        for filtered in filtered_out:
            tag = self.coord_format.format(filtered[1], filtered[0],
                                           filtered[2])
            self.assertTrue(tag not in kml.kml())

        for coord in coordinates:
            tag = self.coord_format.format(coord[1], coord[0], coord[2])
            self.assertTrue(tag in kml.kml())
开发者ID:RishabhSharma1906,项目名称:interop,代码行数:37,代码来源:uas_telemetry_test.py

示例2: test_kml_simple

# 需要导入模块: from simplekml import Kml [as 别名]
# 或者: from simplekml.Kml import kml [as 别名]
    def test_kml_simple(self):
        coordinates = [
            (-76.0, 38.0, 0.0),
            (-76.0, 38.0, 10.0),
            (-76.0, 38.0, 20.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 100.0),
            (-76.0, 38.0, 30.0),
            (-76.0, 38.0, 60.0),
        ]
        # Create Coordinates
        start = TakeoffOrLandingEvent(user=self.user, uas_in_air=True)
        start.save()
        for coord in coordinates:
            self.create_log_element(*coord)
        end = TakeoffOrLandingEvent(user=self.user, uas_in_air=False)
        end.save()

        kml = Kml()
        UasTelemetry.kml(user=self.user,
                         logs=UasTelemetry.by_user(self.user),
                         kml=kml,
                         kml_doc=kml)
        for coord in coordinates:
            tag = self.coord_format.format(coord[1], coord[0],
                                           units.feet_to_meters(coord[2]))
            self.assertTrue(tag in kml.kml())
开发者ID:legonigel,项目名称:interop,代码行数:29,代码来源:uas_telemetry_test.py

示例3: create_kml

# 需要导入模块: from simplekml import Kml [as 别名]
# 或者: from simplekml.Kml import kml [as 别名]
def create_kml(start_dt, traces):
    mintime = datetime(2100,1,1)
    maxtime = datetime(1901,1,1)
    bbox_nw = (sys.maxint, sys.maxint)
    bbox_se = (-sys.maxint, -sys.maxint)

    kml = Kml(name="Tracer")
    doc = kml.newdocument()

    fol = doc.newfolder(name="Traces")

    i = 0
    for id_, trace in traces:
        trace = list(trace)
        trk = fol.newgxtrack(name='Trace id: %s' % id_)

        times = [start_dt + timedelta(seconds=int(p['time'])) for p in trace]
        trk.newwhen([format_date(t) for t in times])

        places = [
            (float(p['lon']), float(p['lat']), 0)
            for p in trace
        ]
        trk.newgxcoord(places)

        m = min(places, key=operator.itemgetter(0))
        if m[0] < bbox_nw[0] and not (m[0] == 0.0 or m[1] == 0.0):
            bbox_nw = m[:2]

        m = max(places, key=operator.itemgetter(0))
        if m[0] > bbox_se[0] and not (m[0] == 0.0 or m[1] == 0.0):
            bbox_se = m[:2]

        mintime = min([mintime] + times)
        maxtime = max([maxtime] + times)

        trk.altitudemode = 'relativeToGround'

        trk.stylemap.normalstyle.iconstyle.icon.href = 'http://earth.google.com/images/kml-icons/track-directional/track-0.png'
        trk.stylemap.normalstyle.linestyle.color = CATEGORICAL_COLORS[i % len(CATEGORICAL_COLORS)]
        trk.stylemap.normalstyle.linestyle.width = 5
        trk.stylemap.normalstyle.labelstyle.scale = 1
        trk.stylemap.highlightstyle.iconstyle.icon.href = 'http://earth.google.com/images/kml-icons/track-directional/track-0.png'
        trk.stylemap.highlightstyle.iconstyle.scale = 1.2
        trk.stylemap.highlightstyle.linestyle.color = CATEGORICAL_COLORS[i % len(CATEGORICAL_COLORS)]
        trk.stylemap.highlightstyle.linestyle.width = 8

        i += 1

    doc.lookat.gxtimespan.begin = format_date(mintime)
    doc.lookat.gxtimespan.end   = format_date(maxtime)
    doc.lookat.longitude = bbox_nw[0] + (bbox_se[0] - bbox_nw[0]) / 2
    doc.lookat.latitude = bbox_nw[1] + (bbox_se[1] - bbox_nw[1]) / 2
    doc.lookat.range = 13000.00

    #doc.lookat.longitude, doc.lookat.latitude = list(list(traces)[0][1])[0]

    return kml.kml()
开发者ID:jazzido,项目名称:tracer,代码行数:60,代码来源:tracer.py


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