示例#1
0
    def gen_kml(self):
        """
        Generate a KML file with keypoints on the locations of the pictures, including height
        :return:
        """
        style_dot = "sn_shaded_dot"
        style_path = "red_path"

        doc = KML.kml(
            KML.Document(
                KML.Name("GPS of the images"),
                KML.Style(
                    KML.IconStyle(
                        KML.scale(0.4),
                        KML.Icon(
                            KML.href(
                                "http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png"
                            )),
                    ),
                    id=style_dot,
                ),
                KML.Style(KML.LineStyle(
                    KML.color('7f0000ff'),
                    KML.width(6),
                    GX.labelVisibility('1'),
                ),
                          id=style_path)))

        # create points
        for i, gps in enumerate(self.tagged_gps):
            ii = i + 1
            doc.Document.append(
                KML.Placemark(
                    KML.styleUrl('#{0}'.format(style_dot)),
                    KML.Point(
                        KML.extrude(True), KML.altitudeMode('absolute'),
                        KML.coordinates("{},{},{}".format(
                            gps.lon, gps.lat, gps.alt))),
                    KML.name(str(ii))
                    if ii % 5 == 0 or ii == 1 else KML.name()))

        # create the path
        doc.Document.append(
            KML.Placemark(
                KML.styleUrl('#{0}'.format(style_path)),
                KML.LineString(
                    KML.altitudeMode('absolute'),
                    KML.coordinates(' '.join([
                        "{},{},{}".format(gps.lon, gps.lat, gps.alt)
                        for gps in self.tagged_gps
                    ])))))

        s = etree.tostring(doc)

        file_path = self.output + 'GoogleEarth_points.kml'
        f = open(file_path, 'w')
        f.write(s)
        f.close()

        print '[INFO] KML file generated on:', file_path
示例#2
0
    def gen_klm(self):
        """
        Generate a KML file with keypoints on the locations of the pictures, including height
        :return:
        """
        style_dot = "sn_shaded_dot"
        style_path = "red_path"

        doc = KML.kml(
            KML.Document(
                KML.Name("GPS of the images"),
                KML.Style(
                    KML.IconStyle(
                        KML.scale(0.4),
                        KML.Icon(
                            KML.href("http://maps.google.com/mapfiles/kml/shapes/shaded_dot.png")
                        ),
                    ),
                    id=style_dot,
                ),
                KML.Style(
                    KML.LineStyle(
                        KML.color('7f0000ff'),
                        KML.width(6),
                        GX.labelVisibility('1'),
                    ),
                    id=style_path
                )   
            )
        )

        # create points
        for i, gps in enumerate(self.tagged_gps):
                ii = i + 1
                doc.Document.append(
                    KML.Placemark(
                        KML.styleUrl('#{0}'.format(style_dot)),
                        KML.Point(
                            KML.extrude(True),
                            KML.altitudeMode('relativeToGround'),
                            KML.coordinates("{},{},{}".format(gps.lon, gps.lat, gps.alt))
                        ),
                        KML.name(str(ii)) if ii % 5 == 0 or ii == 1 else KML.name()
                    )
                )

        # create the path
        doc.Document.append(
            KML.Placemark(
                KML.styleUrl('#{0}'.format(style_path)),
                KML.LineString(
                    KML.altitudeMode('relativeToGround'),
                    KML.coordinates(
                        ' '.join(["{},{},{}".format(gps.lon, gps.lat, gps.alt) for gps in self.tagged_gps])
                    )
                )
            )
        )

        s = etree.tostring(doc)

        file_path = self.output + 'GoogleEarth_points.kml'
        f = open(file_path,'w')
        f.write(s)
        f.close()

        print '[INFO] KML file generated on:', file_path