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


Python KML_ElementMaker.visibility方法代码示例

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


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

示例1: create_network_link_element

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def create_network_link_element(name, kml_file, ts_obj):

    lats, lons = flatten_lalos(None, ts_obj)

    network_link = KML.NetworkLink(
        KML.name(name),
        KML.visibility(1),
        KML.Region(
            KML.Lod(
                KML.minLodPixels(0),
                KML.maxLodPixels(1800)
            ),
            KML.LatLonAltBox(
                KML.north(lats[-1] + 0.5),
                KML.south(lats[0] - 0.5),
                KML.east(lons[-1] + 0.5),
                KML.west(lons[0] - 0.5)
            )
        ),
        KML.Link(
            KML.href(kml_file),
            KML.viewRefreshMode('onRegion')
        )
    )
    return network_link
开发者ID:hfattahi,项目名称:PySAR,代码行数:27,代码来源:save_kmz_timeseries.py

示例2: addLine

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def addLine(doc,line):
	coordinates = "";
	for p in line:
		coordinates += ("\n" + p.toKMLstr())
	pm1 = KML.Placemark(
		KML.name("GridLine"),
		KML.visibility(1),
		KML.LineString(
			KML.extrude(1),
			#KML.altitudeMode("relativeToGround"),
			KML.tesselate(0),
			KML.coordinates(coordinates)
		)
	)
	doc.Document.append(pm1)
开发者ID:will421,项目名称:PROJET_VM,代码行数:17,代码来源:kmlwriter.py

示例3: _docSkel

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def _docSkel(name):
    name = re.sub('[^a-zA-Z0-9\n\.]', ' ', name.split('.')[0]).title()
    doc = KML.kml(
        KML.Document(
            KML.name(name),
            KML.open('1'),
            KML.visibility('1'),
            # uncomment the following if you want to hide the children
            #            KML.Style(
            #                KML.ListStyle(
            #                    KML.listItemType('checkHideChildren')
            #                ),
            #                id='check-hide-children',
            #                ),
            #            KML.styleUrl('#check-hide-children'),
        )
    )
    return doc
开发者ID:johnnycakes79,项目名称:pyops,代码行数:20,代码来源:maps.py

示例4: addSegment

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def addSegment(doc,seg,colorStr):
	pm1 = KML.Placemark(
		KML.name("OneSegment"),
		KML.visibility(1),
		#KML.styleUrl("#redLineBluePoly"),
		KML.Style(
			KML.LineStyle(
				KML.color(colorStr),
				KML.width(3)
			)
		),
		KML.LineString(
			KML.extrude(1),
			KML.tesselate(0),
			#KML.altitudeMode("relativeToGround"),
			KML.coordinates("{}\n{}".format(seg[0].toKMLstr(),seg[1].toKMLstr())
			)
		)
	)
	doc.Document.append(pm1)
开发者ID:will421,项目名称:PROJET_VM,代码行数:22,代码来源:kmlwriter.py

示例5: generate_cbar_element

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def generate_cbar_element(inps):

    out_name_base = plot.auto_figure_title(inps.ts_file, inps_dict=vars(inps))
    cbar_png_file = '{}_cbar.png'.format(out_name_base)

    cbar_png_file = plot_colorbar(out_file=cbar_png_file, vmin=inps.vlim[0], vmax=inps.vlim[1], cmap=inps.colormap)
    cbar_overlay = KML.ScreenOverlay(
        KML.name('Colorbar'),
        KML.Icon(
            KML.href("{}".format(cbar_png_file)),
            KML.viewBoundScale(0.75)
        ),
        KML.overlayXY(x="0", y="0", xunits="fraction", yunits="fraction"),
        KML.screenXY(x="0", y="0", xunits="fraction", yunits="fraction"),
        KML.size(x="0", y="250", xunits="pixel", yunits="pixel"),
        KML.rotation(0),
        KML.visibility(1),
        KML.open(0)
    )
    print('add colorbar.')
    return cbar_overlay, cbar_png_file
开发者ID:hfattahi,项目名称:PySAR,代码行数:23,代码来源:save_kmz_timeseries.py

示例6: makeFile

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]

#.........这里部分代码省略.........
                    GX.FlyTo(
                        GX.duration(0.25),
                        GX.flyToMode("smooth"),
                        KML.LookAt(
                            KML.longitude(float(data['coordinates']['lng'])),
                            KML.latitude(float(data['coordinates']['lat'])),
                            KML.altitude(0),
                            KML.heading(aspect),
                            KML.tilt(data['data']),
                            KML.name(data['data']),
                            KML.range(self.range),
                            KML.altitudeMode("relativeToGround"),
                        )
                    )
                )
            tour_doc.Document[gxns + "Tour"].Playlist.append(GX.Wait(GX.duration(1.0)))

            # tour_doc.Document[gxns+"Tour"].Playlist.append(
            #        GX.TourControl(GX.playMode("pause"))
            #    )

            # add a placemark for the data
            tour_doc.Document.Folder.append(
                KML.Placemark(
                    KML.name(data['data']),
                    KML.description(
                        "<h1>" + data['data'] + "</h1>"
                    ),
                    KML.styleUrl('#{0}'.format(stylename)),
                    KML.Point(
                        KML.extrude(1),
                        KML.altitudeMode("relativeToGround"),
                        KML.coordinates("{lon},{lat},{alt}".format(
                            lon=float(data['coordinates']['lng']),
                            lat=float(data['coordinates']['lat']),
                            alt=50,
                        )
                        )
                    ),
                    id=data['data'].replace(' ', '_')
                )
            )
            # show the placemark balloon
            tour_doc.Document[gxns + "Tour"].Playlist.append(
                GX.AnimatedUpdate(
                    GX.duration(2.0),
                    KML.Update(
                        KML.targetHref(),
                        KML.Change(
                            KML.Placemark(
                                KML.visibility(1),
                                GX.balloonVisibility(1),
                                targetId=data['data'].replace(' ', '_')
                            )
                        )
                    )
                )
            )

            tour_doc.Document[gxns + "Tour"].Playlist.append(GX.Wait(GX.duration(2.0)))

            tour_doc.Document[gxns + "Tour"].Playlist.append(
                GX.AnimatedUpdate(
                    GX.duration(2.0),
                    KML.Update(
                        KML.targetHref(),
                        KML.Change(
                            KML.Placemark(
                                GX.balloonVisibility(0),
                                targetId=data['data'].replace(' ', '_')
                            )
                        )
                    )
                )
            )
            # fly to a space viewpoint
            tour_doc.Document[gxns + "Tour"].Playlist.append(
                GX.FlyTo(
                    GX.duration(5),
                    GX.flyToMode("bounce"),
                    KML.LookAt(
                        KML.longitude(float(data['coordinates']['lng'])),
                        KML.latitude(float(data['coordinates']['lat'])),
                        KML.altitude(0),
                        KML.heading(0),
                        KML.tilt(0),
                        KML.range(10000000.0),
                        KML.altitudeMode("relativeToGround"),
                    )
                ),
            )

        # check that the KML document is valid using the Google Extension XML Schema
        # assert(Schema("kml22gx.xsd").validate(tour_doc))

        # print etree.tostring(tour_doc, pretty_print=True)

        # output a KML file (named based on the Python script)
        outfile = file("kmls_management/static/" + self.kml_name, 'w')
        outfile.write(etree.tostring(tour_doc, pretty_print=True))
开发者ID:LiquidGalaxyLAB,项目名称:ViewYourData,代码行数:104,代码来源:placemark_generator.py

示例7: gmaps

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def gmaps(input, configFile):
    """
       Check and deal with command line agruments.
    """

    if NOKMLLIB:
        print("\nOoops! 'gmaps' needs KML_ElementMaker from pykml.factory")
        print("       Try: pip install pykml\n")
    else:
        # # Check input arguments
        # if len(sys.argv) < 2 or len(sys.argv) > 3:
        #     # ... show usage hint...
        #     _gmapsusage(sys.argv[0])
        #     # ... exit!
        #     raise SystemExit(1)

        # input = sys.argv[1]
        # if sys.argv[2]:
        #     configFile = sys.argv[2]
        # else:
        #     configFile = False

        # create containers
        experiments = {}
        filters = {}
        currents = {}
        styles = []

        # Open input file for reading.
        infile = open(input, 'r')

        # Scan through the file line-by-line.
        # TODO: look into moving this for loop into a function
        for line in infile.readlines():
            if line.startswith('Trail'):
                break

            # TODO: Replace the crude pattern matching below with RegEx...
            if line.startswith('Experiment:'):
                expr = line.split(': ')[1].strip()
                if expr not in experiments:
                    experiments[expr] = KML.Folder(KML.name(expr.replace('_',
                                                                         ' ')),
                                                   KML.open('1'),
                                                   id='expr_{}'.format(expr))
                currents['experiment'] = expr

            if line.startswith('Swath:'):
                fltr = line.split(': ')[1].strip()
                if fltr not in filters:
                    filters[fltr] = KML.Folder(KML.name(fltr.replace('_', ' ')),
                                               KML.open('0'),
                                               KML.visibility('1'),
                                               KML.Style(KML.ListStyle(KML.listItemType('checkHideChildren')), id='check-hide-children'),
                                               KML.styleUrl('#check-hide-children'),
                                               id='fltr_{}'.format(fltr))
                    experiments[currents['experiment']].append(filters[fltr])
                currents['filter'] = fltr

            if line.startswith('Orbit:'):
                orbit = line.split()[1].strip()
                currents['orbit'] = orbit

            if line.startswith('Pericenter time (UTC):'):
                peric_time = line.split(': ')[1].strip()
                currents['pericenter time'] = peric_time

            if line.startswith('First image time (UTC):'):
                first_image_t = line.split(': ')[1].strip()
                currents['first image time'] = first_image_t

            if line.startswith('First image time (from pericenter):'):
                first_image_t_frm_peric = line.split(': ')[1].strip()
                currents['first image time from pericenter'] = first_image_t_frm_peric

            if line.startswith('Last image time (UTC):'):
                last_image_t = line.split(': ')[1].strip()
                currents['last image time'] = last_image_t

            if line.startswith('Last image time (from pericenter):'):
                last_image_t_frm_peric = line.split(': ')[1].strip()
                currents['last image time from pericenter'] = last_image_t_frm_peric

            # build an 'image' placemark element
            if line.startswith(' '):
                image = _buildSwath(line, currents)
                filters[currents['filter']].append(image)

        infile.close()

        # the styles for the different swaths
        colors = {}

        # if the MAPPS ini has been provided get colours from it.
        if configFile:
            inifile = open(configFile, 'r')
            for line in inifile.readlines():
                if '\swathColorName=' in line:
                    cHTML = line.rsplit("=#", 1)[1].strip()
                    cKML = '{}{}{}'.format(cHTML[4:6], cHTML[2:4], cHTML[0:2])
#.........这里部分代码省略.........
开发者ID:johnnycakes79,项目名称:pyops,代码行数:103,代码来源:maps.py

示例8:

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
                    alt=50,
                )
                )
            ),
            id=feature['name'].replace(' ', '_')
        )
    )
    # show the placemark balloon
    tour_doc.Document[gxns + "Tour"].Playlist.append(
        GX.AnimatedUpdate(
            GX.duration(2.0),
            KML.Update(
                KML.targetHref(),
                KML.Change(
                    KML.Placemark(
                        KML.visibility(1),
                        GX.balloonVisibility(1),
                        targetId=feature['name'].replace(' ', '_')
                    )
                )
            )
        )
    )

    tour_doc.Document[gxns + "Tour"].Playlist.append(GX.Wait(GX.duration(2.0)))

    tour_doc.Document[gxns + "Tour"].Playlist.append(
        GX.AnimatedUpdate(
            GX.duration(2.0),
            KML.Update(
                KML.targetHref(),
开发者ID:recombinant,项目名称:pykml,代码行数:33,代码来源:circle_around_landmarks.py

示例9: create_kml_tour

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def create_kml_tour(addresses, filename):
    '''
    Creates a kml tour of the sites
    Modified from pykml example here https://pythonhosted.org/pykml/examples/tour_examples.html
    python
    Generate a KML document of a tour based on rotating around locations.
    '''
    tilt = 20
    distance = 20

    # define a variable for the Google Extensions namespace URL string
    gxns = '{' + nsmap['gx'] + '}'

    # start with a base KML tour and playlist
    tour_doc = KML.kml(
        KML.Document(
          GX.Tour(
            KML.name("Play me!"),
            GX.Playlist(),
          ),
          KML.Folder(
            KML.name('Sites'),
            id='sites',
          ),
        )
    )

    for address in addresses:
        #import ipdb; ipdb.set_trace()
        # fly to a space viewpoint
        tour_doc.Document[gxns+"Tour"].Playlist.append(
          GX.FlyTo(
            GX.duration(5),
            GX.flyToMode("smooth"),
            KML.LookAt(
              KML.longitude(address['longitude']),
              KML.latitude(address['latitude']),
              KML.altitude(0),
              KML.heading(0),
              KML.tilt(0),
              KML.range(10000000.0),
              KML.altitudeMode("relativeToGround"),
            )
          ),
        )
        # fly to the address
        tilt = tilt + 10
        distance = distance + 10
        tour_doc.Document[gxns+"Tour"].Playlist.append(
          GX.FlyTo(
            GX.duration(0.25),
            GX.flyToMode("smooth"),
            KML.LookAt(
              KML.longitude(address['longitude']),
              KML.latitude(address['latitude']),
              KML.altitude(0),
              KML.heading(0),
##              KML.tilt(address['tilt']),
##              KML.range(address['range']),
              KML.tilt(tilt),
              KML.range(distance),
              KML.altitudeMode("relativeToGround"),
            )
          ),
        )
        
        # add a placemark for the address
        tour_doc.Document.Folder.append(
          KML.Placemark(
            KML.name("?"),
            KML.description(
                "<h1>{name}</h1><br/>{desc}".format(
                        name=address['Site'],
                        desc=address['Bandwidth'],
                )
            ),
            KML.Point(
              KML.extrude(1),
              KML.altitudeMode("relativeToGround"),
              KML.coordinates("{lon},{lat},{alt}".format(
                      lon=address['longitude'],
                      lat=address['latitude'],
                      alt=50,
                  )
              )
            ),
            id=address['Site'].replace(' ','_')
          )
        )
        # show the placemark balloon
        tour_doc.Document[gxns+"Tour"].Playlist.append(
            GX.AnimatedUpdate(
              GX.duration(2.0),
              KML.Update(
                KML.targetHref(),
                KML.Change(
                  KML.Placemark(
                    KML.visibility(1),
                    GX.balloonVisibility(1),
                    targetId=address['Site'].replace(' ','_')
#.........这里部分代码省略.........
开发者ID:FranMcG,项目名称:mapper,代码行数:103,代码来源:mapper.py

示例10: appendTrackPlacemarks

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]

#.........这里部分代码省略.........
                        if 'EXIF:GPSLongitudeRef' in tags and \
                           tags['EXIF:GPSLongitudeRef'] == 'W':

                            lon = -lon

                    if "EXIF:DateTimeOriginal" in tags:
                        m = re.match(r'\s*(\d+:\d+:\d+)\s+'
                                     r'(\d+:\d+:[\d.]+)\s*',
                                     tags['EXIF:DateTimeOriginal'])
                        datestr = re.sub(r':', '-', m.group(1))
                        timestr = m.group(2)

                    if "EXIF:GPSAltitude" in tags:
                        alt = tags['EXIF:GPSAltitude']

                    if self.verbosity > 1:
                        print(datestr,
                              timestr,
                              lat,
                              lon,
                              alt,
                              '\n',
                              file=sys.stderr)

                    if datestr and timestr and lat and lon:
                        in_kml = ' in kml'

                        if datestr not in places:
                            places[datestr] = {}
                        
                        timefile = timestr + filebase
                        if timefile not in places[datestr]:
                            places[datestr][timefile] = {}
                    
                        jpegmeta = places[datestr][timefile]
                        jpegmeta['filebase'] = filebase
                        jpegmeta['time'] = GX.when('T'.join(datestr, timestr))
                        jpegmeta['place'] = \
                            GX.coord('{0} {1} {2}'.format(lon, 
                                                          lat, 
                                                          alt))
                        jpegmeta['point'] = \
                            KML.Point(
                                KML.coordinates('{0},{1},{2}'.format\
                                                (lon, lat, 0)))
                        if self.config['arguments']['url']:
                            jpegmeta['fileurl'] = '/'.join(
                                self.config['arguments']['url'], basedir, f)
                        else:
                            jpegmeta['fileurl'] = '/'.join('file:/', filepath)

                if self.verbosity > 0:
                    print('    ' + f, in_kml, file=sys.stderr)

        # Build the track folder and placemark folder
        track_folder = KML.Folder()
        image_folder = KML.Folder()
        for datestr in sorted(places.keys()):
            colourID = '#colour' + str(self.colourIndex)
            placemark = KML.Placemark(
                KML.visibility('1'),
                KML.name(basedir),
                KML.description('Path taken at ' + basedir + ' on ' + 
                                datestr),
                KML.styleUrl(colourID)
                )
            self.colourIndex = (self.colourIndex + 1) % self.colourSetLen

            track = GX.Track(
                KML.altitudeMode('clampToGround')
                )
            for tf in sorted(places[datestr].keys()):
                # append when elements
                track.append(places[datestr][tf]['time'])
            for tf in sorted(places[datestr].keys()):
                # append coord elements
                track.append(jpegmeta[tf]['place'])
            placemark.append(track)
            track_folder.append(placemark)
            
            for tf in sorted(places[datestr].keys()):
                jpegmeta = places[datestr][tf]
                
                jpg = jpegmeta['filebase']
                cdatakey = 'CDATA' + directory + datestr + jpg
                self.cdatatext[cdatakey] = ('<![CDATA[<img src="' + 
                    jpegmeta['fileurl'] + ' width=400/><br/>' + 
                    'Taken at ' + directory + ' on ' + datestr + '<br/>]]>')
                image_folder.append( 
                    KML.Placemark(
                        KML.visibility('1'),
                        KML.styleUrl('#picture'),
                        KML.name(jpg),
                        KML.description('{' + cdatakey + '}'),
                        jpegmeta['point']
                    )
                )

        doc.append(track_folder)
        doc.append(image_folder)
开发者ID:redmanr,项目名称:jpggps2kml,代码行数:104,代码来源:jpggps2kml.py

示例11: makeKmlDoc

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
    def makeKmlDoc(self):
        """
        """
        self.cdatatext = {}
        args = self.config['arguments']
        
        trackfolder = imagefolder = None
        self.colourIndex = 0
        
        if ('update' in self.config['arguments'] and 
            self.config['arguments']['update']):
            
            with open(args['out'], 'r') as f:
                doc = KML.parse(f)
            # Find a folder that contains a Name with the text "tracks"
            trackfolder = doc.find('./Folder/[Name="tracks"]/..')
            # Find a folder that contains a Name with the text "tracks"
            imagefolder = doc.find('./Folder/[Name="images"]/..')

            if trackfolder:
                self.colourIndex = \
                    ((len(trackfolder.findall(KML.PlaceMark)) - 1) % 
                      self.colourSetLen)
        else:
            # create a new KML structure from scratch
            doc = KML.Document(
                      KML.description('Tracks and image placemarks'),
                      KML.visibility('1'),
                      KML.open('1'),
                      KML.name("Tracks and Images")
                  )
    
            # Append a style for pictures using the camera icon
            doc.append(
                KML.Style(
                    KML.IconStyle(
                        KML.scale(1.0),
                        KML.Icon(
                            KML.href(
                                'http://maps.google.com/mapfiles/kml/'\
                                'shapes/camera.png'),
                        ),
                        id="picture_style"
                    ),
                    id='picture'
                )
            )
    
            # Append styles for lines in different colours
            colourSet = [['7fff0000', 6, 'ffff0000', 8],
                         ['7f00ff00', 6, 'ff00ff00', 8],
                         ['7f0000ff', 6, 'ff0000ff', 8],
                         ['7fffff00', 6, 'ffffff00', 8],
                         ['7fff00ff', 6, 'ffff00ff', 8],
                         ['7f00ffff', 6, 'ff00ffff', 8]]
            self.colourSetLen = len(colourSet)
            
            for colourIndex in range(len(colourSet)):
                normal, narrow, highlight, wide = colourSet[colourIndex]
                colourID = 'colour' + str(colourIndex)
                self.colourStyle(doc, 
                                 colourID, 
                                 normal, 
                                 narrow,
                                 highlight,
                                 wide)
            
            trackfolder = KML.Folder(
                              KML.Name('tracks')
                              )
            doc.append(trackfolder)
            
            imagefolder = KML.Folder(
                              KML.Name('images')
                              )
            doc.append(imagefolder)

        return (doc, trackfolder, imagefolder)
开发者ID:redmanr,项目名称:jpggps2kml,代码行数:80,代码来源:jpggps2kml.py

示例12: read_image_placemarks_from_jpeg

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]

#.........这里部分代码省略.........
            '/'.join(self.url, jpegrooted)
        """
        args = self.config['arguments']
        
        # Does a placemark for this image already exist in the imagefolder?
        for pm in imagefolder:
            name = pm.find('Name')
            if name and name.text == jpegbase:
                if self.verbosity > 1:
                    print(jpegbase,'found in imagefolder', file=sys.stderr)
                
                # image already present
                if 'replace' in args and args['replace']:
                    # replace the image by dropping the existing copy
                    if self.verbosity > 1:
                        print('replace ' + jpegbase, file=sys.stderr)
                    imagefolder.drop(pm)
                else:
                    # keep the image, so bail from further processing
                    if self.verbosity > 1:
                        print('retain existing ' + jpegbase, file=sys.stderr)
                    return
        
        # Get here only if we need to generate a new Placemark        
        tags = et.get_tags(self.items, jpegdisk)
        if self.verbosity > 1:
            for k in tags:
                if k in self.items:
                    print(k, ' = ', tags[k], file=sys.stderr)

        lat = lon = None
        datestr = timestr = ''
        alt = 0

        if "EXIF:GPSLatitude" in tags:
            lat = tags['EXIF:GPSLatitude']
            if ('EXIF:GPSLatitudeRef' in tags and 
                tags['EXIF:GPSLatitudeRef'] == 'S'):

                lat = -lat

        if "EXIF:GPSLongitude" in tags:
            lon = tags['EXIF:GPSLongitude']
            if ('EXIF:GPSLongitudeRef' in tags and 
                tags['EXIF:GPSLongitudeRef'] == 'W'):

                lon = -lon

        if "EXIF:GPSAltitude" in tags:
            alt = tags['EXIF:GPSAltitude']

        if "EXIF:DateTimeOriginal" in tags:
            m = re.match(r'\s*(\d+:\d+:\d+)\s+'
                         r'(\d+:\d+:[\d.]+)\s*',
                         tags['EXIF:DateTimeOriginal'])
            datestr = re.sub(r':', '-', m.group(1))
            timestr = m.group(2)

        if self.verbosity > 1:
            print(datestr,
                  timestr,
                  lat,
                  lon,
                  alt,
                  '\n',
                  file=sys.stderr)

        in_kml = ''
        if datestr and timestr and lat and lon:
            in_kml = ' in kml'

            if 'url' in args and args['url']:
                jpegurl = '/'.join([self.config['arguments']['url'], 
                                    jpegrooted])
            else:
                jpegurl = '/'.join(['file:/', jpegdisk])
            
 #           cdatakey = 'CDATA' + jpegrooted + datestr + jpegbase
            cdatakey = datestr + jpegbase
            self.cdatatext[cdatakey] = ('<![CDATA[<img src="' + 
                jpegurl + '" width=400/><br/>' + 
                'in ' + os.path.dirname(jpegrooted) + 
                ' at ' + timestr +
                ' on ' + datestr + '<br/>]]>')
            
            
            imagefolder.append( 
                KML.Placemark(
                    KML.visibility('1'),
                    KML.styleUrl('#picture'),
                    KML.name(jpegbase),
                    KML.description('{' + cdatakey + '}'),
                    KML.Point(KML.coordinates('{0},{1},{2}'.format(lon, 
                                                                   lat, 
                                                                   alt)))
                    )
                )

        if self.verbosity > 0:
            print('    ' + jpegrooted, in_kml, file=sys.stderr)
开发者ID:redmanr,项目名称:jpggps2kml,代码行数:104,代码来源:jpggps2kml.py

示例13: read_track_from_gpx

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
    def read_track_from_gpx(self, 
                            filepath, 
                            filebase, 
                            trackfolder,
                            colourIndex):
        """
        Read a single GPX file and extract the track(s), converting them to a 
        list of KML tracks.  Append or replace each track in the trackfolder.
        This fills the trackfolder in makekml.
        
        Arguments:
        filepath: the full path to the GPX file
        filebase: the basename of the GPX file, used to name the KML tracks
        trackfolder: a KML.Folder to hold track Placemarks
        colourIndex: the next colourIndex to use when creating a linestyle
        
        On successful exit, trackfolder and colourIndex will have been updated.
        """
        args = self.config['arguments']
        gpxtree = etree.parse(filepath).getroot()        
        namespace = gpxtree.nsmap[None]
        if self.verbosity > 1:
            print('namespace for ' + filepath + ': ' + namespace, 
                  file=sys.stderr)
        
        print('{%s}trk' % namespace, file=sys.stderr)
        print(namespace + 'trk', file=sys.stderr)
        for gpxtrack in gpxtree.getiterator('{%s}trk' % namespace):
            print('got here', file=sys.stderr)
            # Extract the track name from the GPX track
            try:
                trackname = gpxtrack.find('{%s}name' % namespace).text
            except:
                print('track does not have name in ' + filepath, 
                      file=sys.stderr)
                trackname = filebase
            print('trackname = ' + trackname, file=sys.stderr)

            # does a Placemark already exist with this name?
            placemark = None
            for pm in trackfolder.findall('GX.Placemark'):
                if pm.find('KML.name').text == trackname:
                    placemark = pm
                    break
            if 'replace' in args and args['replace']:
                trackfolder.drop(placemark)
                placemark = None
            
            if not placemark:
                # Create a new Placemark to hold the KML track(s)
                colourID = '#colour' + str(self.colourIndex)
                self.colourIndex = (self.colourIndex + 1) % self.colourSetLen

                placemark = KML.Placemark(
                    KML.visibility('1'),
                    KML.name(trackname),
                    KML.description(trackname + ' from ' + filebase),
                    KML.styleUrl(colourID)
                    )
                trackfolder.append(placemark)

                tracklist = []
                for gpxtrkseg in gpxtrack.getiterator('{%s}trkseg' % namespace):
                    # A GPX trkseg translates into aGX.track
                    kmltrack = GX.Track(
                        KML.altitudeMode('clampToGround')
                        )
                    whenlist = []
                    coordlist = []
                    for gpxtrkpoint in gpxtrkseg:
                        lat = gpxtrkpoint.attrib['lat']
                        lon = gpxtrkpoint.attrib['lon']
                        alt = gpxtrkpoint.find('{%s}ele'% namespace).text
                        time = gpxtrkpoint.find('{%s}time'% namespace).text
                        
                        whenlist.append(GX.when(time))
                        coordlist.append(GX.coord('{0} {1} {2}'.format(lon, 
                                                                       lat, 
                                                                       alt)))
                    for w in whenlist:
                        kmltrack.append(w)
                    for c in coordlist:
                        kmltrack.append(c)
                    tracklist.append(kmltrack)
                
                if tracklist:
                    if len(tracklist) > 1:
                        multitrack = GX.MultiTrack()
                        for t in tracklist:
                            multitrack.append(t)
                        placemark.append(multitrack)
                    else:
                        placemark.append(tracklist[0])
                else:
                    print('no tracks found in ' + filepath, file=sys.stderr)
开发者ID:redmanr,项目名称:jpggps2kml,代码行数:97,代码来源:jpggps2kml.py

示例14: create_regionalized_networklinks_file

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import visibility [as 别名]
def create_regionalized_networklinks_file(regions, ts_obj, box_list, lod, step, output_file):

    ## 1. Create directory to store regioalized KML data files
    kml_data_files_directory = "kml_data_files"
    links_directory = "{0}by{0}_links".format(step)
    mkdir_kml_data_file_command = "mkdir {}".format(kml_data_files_directory)
    os.system(mkdir_kml_data_file_command)
    cmdDirectory = "cd {}; mkdir {}/".format(kml_data_files_directory, links_directory)
    print("Creating KML links directory")
    os.system(cmdDirectory)

    ## 2. Create master KML element and KML Document element
    kml = KML.kml()
    kml_document = KML.Document()

    ## 3. Define min and max levels of detail for large vs small data
    min_lod = lod[0]
    max_lod = lod[1]

    ## 4. Define list of regionalized boxes and list of number of regions
    region_nums = list(range(0, len(regions)))

    ## 5. Generate a new network link element for each region
    for ele in zip(regions, box_list, region_nums):

        region_document = ele[0]
        box = ele[1]
        num = ele[2]

        kml_file = "region_{}.kml".format(num)

        ## 5.1 Write the first region_document to a file and move it to the proper subdircetory
        kml_1 = KML.kml()
        kml_1.append(region_document)
        print('writing ' + kml_file)
        with open(kml_file, 'w') as f:
            f.write(etree.tostring(kml_1, pretty_print=True).decode('utf-8'))

        cmdMove = "mv {sm} {dir}/{sm}".format(sm=kml_file, dir="{}/{}".format(kml_data_files_directory, links_directory))
        print("Moving KML Data Files to directory")
        os.system(cmdMove)

        ## 5.2 Flatten lats and lons data
        lats, lons = flatten_lalos(box, ts_obj)

        ## 5.3 Define new NetworkLink element
        network_link = KML.NetworkLink(
            KML.name('Region {}'.format(num)),
            KML.visibility(1),
            KML.Region(
                KML.Lod(
                    KML.minLodPixels(min_lod),
                    KML.maxLodPixels(max_lod)
                ),
                KML.LatLonAltBox(
                    KML.north(lats[0] + 0.5),
                    KML.south(lats[-1] - 0.5),
                    KML.east(lons[0] + 0.5),
                    KML.west(lons[-1] - 0.5)
                )
            ),
            KML.Link(
                KML.href("{}/{}".format(links_directory, kml_file)),
                KML.viewRefreshMode('onRegion')
            )
        )

        ## 5.4 Append new NetworkLink to KML document
        kml_document.append(network_link)

    ## 6. Write the full KML document to the output file and move it to the proper directory
    kml.append(kml_document)
    with open(output_file, 'w') as f:
        f.write(etree.tostring(kml, pretty_print=True).decode('utf-8'))

    return "{}/{}".format(kml_data_files_directory, output_file), kml_data_files_directory
开发者ID:hfattahi,项目名称:PySAR,代码行数:78,代码来源:save_kmz_timeseries.py


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