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


Python KML_ElementMaker.description方法代码示例

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


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

示例1: to_kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
    def to_kml(self, filename):
        """
        Export the group to a kml file
        """
        if not self.sights:
            print('This group does not have sights. Aborting export.')
            return

        document = KML.Document()
        document.append(KML.title(self.name))
        if self.description:
            document.append(KML.description(self.description))

        country_folders = {}
        place_folders = {}

        for sight in self.sights.all():
            if not sight.geoposition:
                continue

            placemark = KML.Placemark(
                KML.name(u'{0.name}'.format(sight)),
                KML.description(sight.get_long_description()),
                KML.Point(KML.coordinates('{0[0]}, {0[1]}, 0.0'.format(
                    sight.geoposition.coords,
                ))),
            )

            placemark.append(KML.ExtendedData(
                KML.Data(
                    name='gx_media_links',
                    value=u'{name}.jpg'.format(name=sight.name),
                )
            ))

            place_folder_id = sight.thplace.id
            country_folder_id = sight.thplace.thcountry.id

            country_folder = country_folders.setdefault(
                country_folder_id,
                KML.Folder(KML.name(sight.thplace.thcountry.name)),
            )

            place_folder = place_folders.setdefault(
                place_folder_id,
                KML.Folder(KML.name(sight.thplace.name)),
            )

            place_folder.append(placemark)
            country_folder.append(place_folder)
            document.append(country_folder)

        file_obj = open(filename, 'w')
        file_obj.write(
            etree.tostring(
                document,
                pretty_print=True,
                encoding='utf8'))
开发者ID:jricardo27,项目名称:travelhelper,代码行数:60,代码来源:group.py

示例2: create_kml_placemarks_for_tracks_and_waypoints

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def create_kml_placemarks_for_tracks_and_waypoints(tracks, waypoints, sample=1, description=None, color=None, name=None):
    placemarks = []
    tracks = tracks or []
    waypoints = waypoints or []

    for track in tracks:
        coordinates = ["%s,%s" % (p.longitude, p.latitude) for i, p in enumerate(track.points) if
                       i % sample == 0 or len(track.points) < 100]
        placemarks.append(
            KML.Placemark(
                KML.name(name or track.name),
                KML.description(description or track.description or ""),
                KML.Style(
                    KML.LineStyle(
                        KML.color(color) if color else get_random_color(),
                        KML.width(3)
                    )
                ),
                KML.MultiGeometry(
                    KML.LineString(
                        KML.coordinates(" ".join(coordinates))
                    )
                )
            )
        )

    for waypoint in waypoints:
        coordinates = "%s,%s" % (waypoint.long, waypoint.lat)
        placemarks.append(
            KML.Placemark(
                KML.name(name or waypoint.name),
                KML.description(description or waypoint.description or ""),
                KML.Style(
                    KML.IconStyle(
                        KML.color("ffffffff"),
                        KML.scale(1.0),
                        KML.Icon(
                            KML.href(
                                "http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")
                        ),
                    ),
                    KML.LabelStyle(
                        KML.scale(0.0)
                    )
                ),
                KML.Point(
                    KML.coordinates(coordinates)
                )
            )
        )
    return placemarks
开发者ID:lbosson,项目名称:geoblogger,代码行数:53,代码来源:kml_helpers.py

示例3: addPointsCustom

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def addPointsCustom(doc, dataframe, latLabel, longLabel, valueLabel, bins, skipNull=1):
    if len(dataframe.index) == 0:
        return doc
    
    if (len(bins) != 10):
        raise ValueError("Expected bins to have 10 entries, got {}".format(len(bins)))

    plottedCoord = []
    for i in dataframe.index:
        # get color
        if pd.isnull(dataframe.loc[i, valueLabel]):
            colorName = 0
        else:
            diff = np.array(bins) - dataframe.loc[i, valueLabel]
            colorName = 10
            for (x, d) in enumerate(diff):
                if d > 0:
                    colorName = x
                    break
    
        #add placemark to KML
        if not pd.isnull(dataframe.loc[i, valueLabel]) or skipNull == 0:
            coordStr = "{} {}".format(dataframe.loc[i, longLabel], dataframe.loc[i, latLabel])
            if coordStr not in plottedCoord:
                point = KML.Placemark(
                   KML.description("{:5f}".format(dataframe.loc[i, valueLabel])),
                   KML.styleUrl("stylemap_house_{}".format(colorName)),
                   KML.Point(
                       KML.coordinates("{},{},0".format(dataframe.loc[i, longLabel],dataframe.loc[i, latLabel]))
                        )
                    )
                doc.append(point)
                plottedCoord.append(coordStr)
    return doc
开发者ID:jyskwong,项目名称:houses,代码行数:36,代码来源:kmllib.py

示例4: kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def kml(locations):
    """KML file for the locations
    """
    # create document
    document = KML.kml(KML.Document(KML.name("Layer example")))
    # bullets
    for layer_code,layer_name in categories(locations):
        style = KML.Style(
            KML.IconStyle(
                KML.scale(1.0),
                KML.Icon(
                    KML.href('%slocations/%s.png' % (settings.MEDIA_URL, layer_code)),
                ),
                id='icon-%s' % layer_code
            ),
            id=layer_code
        )
        document.append(style)
    # locations
    folder = KML.Folder()
    for location in locations:
        placemark = KML.Placemark(
            KML.name(location['title']),
            KML.description('<![CDATA[ %s ]]>' % location['description']),
            KML.styleUrl('#%s' % location['category']),
            KML.Point(
                KML.coordinates(','.join([location['lng'],location['lat']]))
                ),
            )
        folder.append(placemark)
    document.append(folder)
    # rettsugo!
    return etree.tostring(document)
开发者ID:,项目名称:,代码行数:35,代码来源:

示例5: create_kml_from_waypoint

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def create_kml_from_waypoint(waypoint):
    coordinates = "%s,%s" % (waypoint.long, waypoint.lat)
    doc = KML.kml(
        KML.Document(
            KML.Placemark(
                KML.name(waypoint.name),
                KML.description(waypoint.description if waypoint.description else ""),
                KML.Style(
                    KML.IconStyle(
                        KML.color("ffffffff"),
                        KML.scale(1.0),
                        KML.Icon(
                            KML.href("http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png")
                        ),
                    ),
                    KML.LabelStyle(
                        KML.scale(0.0)
                    )
                ),
                KML.Point(
                    KML.coordinates(coordinates)
                )
            )
        )
    )
    return doc
开发者ID:lbosson,项目名称:geoblogger,代码行数:28,代码来源:kml_helpers.py

示例6: generateKML

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def generateKML(ids, spotList):
    km = KML.kml()
    doc = KML.Document(KML.name("Aires camping car info"))
    icones = glob.glob(LOGOS_FOLDER+"A*")
    for icone in icones:
        icone = icone.replace(DESC_FOLDER, "")
        type = os.path.basename(icone).replace("40.gif", "")
        style = KML.Style(
          KML.IconStyle(
            KML.scale(1.0),
            KML.Icon(
              KML.href(icone),
            ),
          ),
          id=type.lower()
        )
        doc.append(style)
    for id in ids:
        idStr = str(id)
        with codecs.open(DESC_FOLDER+"/"+idStr+".html",'r',encoding='utf-8') as f:
            place = KML.Placemark(
                    KML.name(spotList[id]["name"]),
                    KML.description(f.read()),
                    KML.styleUrl("#"+spotList[id]["type"].lower()),
                    KML.Point(
                        KML.coordinates(spotList[id]["lat"]+","+spotList[id]["long"])
                        )
                    )
            doc.append(place)
    km.append(doc)
    print(etree.tostring(km))
开发者ID:nleleu,项目名称:ccinfo,代码行数:33,代码来源:ccinfo.py

示例7: test_getXmlWithCDATA

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
 def test_getXmlWithCDATA(self):
     '''tests the format_as_cdata function'''
     from pykml.util import format_xml_with_cdata
     
     kmlobj = KML.kml(
         KML.Document(
             KML.Placemark(
                 KML.name('foobar'),
                 KML.styleUrl('#big_label'),
                 KML.description('<html>'),
                 KML.text('<html>'),
                 KML.linkDescription('<html>'),
                 KML.displayName('<html>')
             )
         )
     )
     self.assertEqual(
         etree.tostring(format_xml_with_cdata(kmlobj)),
         '<kml xmlns:gx="http://www.google.com/kml/ext/2.2"'
                       ' xmlns:atom="http://www.w3.org/2005/Atom"'
                       ' xmlns="http://www.opengis.net/kml/2.2">'
           '<Document>'
             '<Placemark>'
               '<name>foobar</name>'
               '<styleUrl>#big_label</styleUrl>'
               '<description><![CDATA[<html>]]></description>'
               '<text><![CDATA[<html>]]></text>'
               '<linkDescription><![CDATA[<html>]]></linkDescription>'
               '<displayName><![CDATA[<html>]]></displayName>'
             '</Placemark>'
           '</Document>'
         '</kml>'
     )
开发者ID:123abcde,项目名称:pykml,代码行数:35,代码来源:test_util.py

示例8: create_reference_point_element

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def create_reference_point_element(inps, lats, lons, ts_obj):

    star_file = "star.png"

    colormap = mpl.cm.get_cmap(inps.colormap)  # set colormap
    norm = mpl.colors.Normalize(vmin=inps.vlim[0], vmax=inps.vlim[1])

    ref_yx = (int(ts_obj.metadata['REF_Y']), int(ts_obj.metadata['REF_X']))
    ref_lalo = (lats[ref_yx[0], ref_yx[1]], lons[ref_yx[0], ref_yx[1]])

    reference_point = KML.Placemark(
        KML.Style(
            KML.IconStyle(
                KML.color(get_color_for_velocity(0.0, colormap, norm)),
                KML.scale(1.),
                KML.Icon(KML.href("{}".format(star_file)))
            )
        ),
        KML.description("Reference point <br /> \n <br /> \n" +
                        generate_description_string(ref_lalo, ref_yx, 0.00, 0.00, 0.00, 1.00)
                        ),
        KML.Point(
            KML.coordinates("{}, {}".format(ref_lalo[1], ref_lalo[0]))
        )
    )

    return reference_point, star_file
开发者ID:hfattahi,项目名称:PySAR,代码行数:29,代码来源:save_kmz_timeseries.py

示例9: generate_update

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
 def generate_update(self, change=None, create=None, delete=None):
   placemark = GX.Placemark(targetId=self.pm_id)
   track = GX.Track(targetId=self.track_id)
   while self.has_next_packet():
     placemark.append(KML.description(self.get_description()))
     self.get_next_packet().append_telemetry_to(track)
   if placemark.countchildren() > 0:
     change.append(placemark)
   if track.countchildren() > 0:
     create.append(track)
开发者ID:IoannisIn,项目名称:cellbots,代码行数:12,代码来源:earth.py

示例10: get_placemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
 def get_placemark(self, style_url=None, model_url=None):
   label = self.callsign+KmlStyleUtils.get_callsign_info(self.callsign)
   track = self.get_track(model_url)
   placemark = KML.Placemark(id=self.pm_id)
   placemark.append(KML.name(label))
   placemark.append(KML.description(self.get_description()))
   if style_url is not None:
     placemark.append(KML.styleUrl(style_url))
   placemark.append(track)
   return placemark
开发者ID:IoannisIn,项目名称:cellbots,代码行数:12,代码来源:earth.py

示例11: execute

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
    def execute(self):
        """
        Execute the command.
        """

        def __kml_table(data):
            """
            Helper method for creating the table of network data
            for the kml file.
            @param data: The parsed network data
            @type data: dict
            @return: Formatted kml table representation of the data.
            @rtype: string
            """
            kml_text = " <div style='height:400px;width:500px;overflow:auto'>\n   <table width='500'>\n"

            for key, value in data.items():
                kml_text += "       <tr><td>{0}</td><td>{1}</td></tr>\n".format(key, value)

            kml_text += "    </table>\n </div>\n"

            return kml_text

        networks = self.__network_service.list_models(source_file=self.__source_file)
        if len(networks) > 0:
            placemarks = []
            for network in networks:
                name = network.essid
                encryption = network.encryption
                href = "http://maps.google.com/mapfiles/kml/paddle/grn-stars.png"
                if not str(encryption).__contains__('WPA'):
                    href = "http://maps.google.com/mapfiles/kml/paddle/red-stars.png"

                pm = KML_ElementMaker.Placemark(
                    KML_ElementMaker.name(name),
                    KML_ElementMaker.description(__kml_table(network.as_dict())),
                    KML_ElementMaker.Style(
                        KML_ElementMaker.IconStyle(
                            KML_ElementMaker.Icon(
                                KML_ElementMaker.href(href)
                            ),
                        ),
                    ),
                    KML_ElementMaker.Point(
                        KML_ElementMaker.coordinates("{0},{1}".format(network.longitude, network.latitude))
                    )
                )
                placemarks.append(pm)

            fold = KML_ElementMaker.Folder()
            for placemark in placemarks:
                fold.append(placemark)

            self.__ofile.write(etree.tostring(fold, pretty_print=True))
开发者ID:maine-cyber,项目名称:kraken,代码行数:56,代码来源:commands.py

示例12: get_kml_for_queryset

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def get_kml_for_queryset(queryset, filename=_('Geographical objects')):
    """
    :param queryset: GeoObject queryset
    :return: KML file from GeoObject queryset
    """
    kml = KML.kml(KML.Document(KML.open(1)))

    geo_objects = queryset.values_list('color', 'title', 'lat', 'lon', 'geometry', 'short_description')
    colors = set(items[0] for items in sorted(geo_objects))
    colors_dict = {color: convert_color_hex_to_kml(color) for color in colors}

    for line_color, polygon_color in colors_dict.values():
        kml.Document.append(KML.Style(
            KML.PolyStyle(KML.color(polygon_color)),
            KML.LineStyle(KML.color(line_color), KML.width(2)),
            id=line_color,
        ))
        print(line_color, polygon_color)

    for (color, title, lat, lon, polygon, short_description) in geo_objects:
            style_id = colors_dict[color][0]
            fld = KML.Folder(
                KML.name(title),
                KML.Placemark(
                    KML.name(title),
                    KML.styleUrl('#' + style_id),
                    KML.description(short_description),
                    KML.Point(KML.coordinates("{},{},0".format(lon, lat)))
                )
            )

            if polygon:
                polygon = parser.fromstring(polygon.kml)
                fld.append(KML.Placemark(KML.name(title), KML.styleUrl('#' + style_id),
                                         KML.description(short_description), polygon))

            kml.Document.append(fld)

    kml_str = '<?xml version="1.0" encoding="UTF-8"?>\n' + etree.tostring(kml, pretty_print=True).decode()
    return get_file_response(kml_str, filename)
开发者ID:,项目名称:,代码行数:42,代码来源:

示例13: kml_placemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
 def kml_placemark(self):
     return KML.Placemark(
             KML.name(self.redis.get('daftpunk:%s:address')),
             KML.Point(
                 KML.coordinates(
                     ','.join([
                         self.redis.get('daftpunk:%s:long' % self.id_),
                         self.redis.get('daftpunk:%s:lat' % self.id_)
                         ])
                     )
                 ),
             KML.description(self.redis.get('daftpunk:%s:description' % self.id_)),
             )
开发者ID:keoghpe,项目名称:daftpunk,代码行数:15,代码来源:property.py

示例14: buildKML

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
def buildKML():
   media_filtered = pickle.load( open( "media_filtered.p", "rb" ) )
   
   kml = open('media_KML.kml', "w")
   kmlobj = KML.kml(
       KML.Document(
           KML.Style(
               KML.BalloonStyle(
                   KML.displayMode('default'),
                   KML.text('<b>$[name]</b><br/>$[description]')
               ),
               KML.IconStyle(
                  KML.Icon(
                     KML.href('http://maps.google.com/mapfiles/kml/paddle/red-circle.png'),
                     KML.scale('1.0')
                  ),
                  id='mystyle'
               ),
               id="balloonStyle"
           )
       )
   )

   # add placemarks to the Document element
   for media in media_filtered:
      kmlobj.Document.append(
            KML.Placemark(
               KML.name(media.location.name),
               KML.description("Name: " + media.user.full_name + 
                               "<br>Username: <a href=\"https://instagram.com/" + media.user.username + "/\">" + media.user.username + "</a><br>" +
                               "<img src=" + media.images['standard_resolution'].url + "><br>" +
                               media.caption.text),
               KML.styleUrl('#balloonStyle'),
               KML.TimeStamp(
                  KML.when(media.created_time.isoformat() + 'Z')
               ),
               KML.Point(
                  KML.extrude(1),
                  KML.altitudeMode('relativeToGround'),
                  KML.coordinates('{lon},{lat},{alt}'.format(
                      lon=media.location.point.longitude,
                      lat=media.location.point.latitude,
                      alt=0,
               ),
            ),
         ),
      )
   )
   kml.write(etree.tostring(etree.ElementTree(kmlobj),pretty_print=True))
   kml.close()
开发者ID:pyropenguin,项目名称:MigrantInstagram,代码行数:52,代码来源:GetTaggedImages.py

示例15: _writerow

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import description [as 别名]
 def _writerow(self, row):
     desc = map(lambda r: u': '.join(r) + u"<br>", zip(self.opts.fields, row))
     self.placemarks.append(KML.Placemark(
         KML.name(row[13]),
         KML.Point(
             KML.extrude(1),
             KML.altitudeMode("relativeToGround"),
             KML.coordinates(u"{lon},{lat},{alt}".format(lon=row[5],lat=row[4],alt=0)),
             ),
         KML.description(
                 desc
             ),
         id=row[0],
         ))
开发者ID:johnnybayern,项目名称:twittersearch,代码行数:16,代码来源:TweetWriter.py


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