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


Python KML_ElementMaker.altitude方法代码示例

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


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

示例1: kml_addAnimPoint

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
 def kml_addAnimPoint(self, pos, tm):
     #pos[0] : latitude
     #pos[1] : longitude
     #pos[2] : altitude
     #pos[3] : roll
     #pos[4] : pitch
     #pos[5] : yaw
     if (pos == None):
         return
     
     localTimeStr = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.localtime(tm))
     #rospy.logerr(localTimeStr)
     self.anim_fld.append(KML.Placemark(
         KML.TimeStamp(
             KML.when(localTimeStr)
         ),
         KML.altitudeMode("absolute"),
         KML.styleUrl('#sn_shaded_dot'),
         KML.LookAt(
             KML.longitude(pos[1]),
             KML.latitude(pos[0]),
             KML.altitude(pos[2]),
             KML.heading(pos[5]),
             KML.tilt(0.0),
             KML.range(100.0),
             KML.altitudeMode("absolute"),
         ),
         KML.Point(
             KML.coordinates("{lon},{lat},{alt}".format(lon=pos[1], lat=pos[0], alt=pos[2]))
         )
     ))        
开发者ID:silviomaeta,项目名称:kml_util,代码行数:33,代码来源:generate_kml.py

示例2: kml_addPathPoint

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
 def kml_addPathPoint(self, pos, dt):
     #pos[0] : latitude
     #pos[1] : longitude
     #pos[2] : altitude
     #pos[3] : roll
     #pos[4] : pitch
     #pos[5] : yaw
     if (pos == None):
         return
     #rospy.logerr(pos)
     
     self.tour_doc.Document[self.gxns+"Tour"].Playlist.append(
         GX.FlyTo(
             GX.duration(dt),
             GX.flyToMode("smooth"),
             #KML.Camera(
             KML.LookAt(
                 KML.latitude(pos[0]),
                 KML.longitude(pos[1]),
                 KML.altitude(pos[2]),
                 KML.heading(pos[5]),
                 #KML.tilt(pos[4] + 90.0),
                 #KML.roll(pos[3]),
                 KML.tilt(pos[4] + 75.0),
                 KML.range(20.0),
                 KML.altitudeMode("absolute"),
             ),
         ),
     )
     
     auxStr = ' {lon},{lat},{alt}\n'.format(lon=pos[1], lat=pos[0], alt=pos[2])
     #rospy.logerr(auxStr)
     self.execCoordListStr = self.execCoordListStr + auxStr
开发者ID:silviomaeta,项目名称:kml_util,代码行数:35,代码来源:generate_kml.py

示例3: test_basic_kml_document

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
    def test_basic_kml_document(self):
        """Tests the creation of a basic KML with Google Extensions ."""
        doc = KML.kml(
            GX.Tour(
                GX.Playlist(
                    GX.SoundCue(
                        KML.href('http://dev.keyhole.com/codesite/cntowerfacts.mp3')
                    ),
                    GX.Wait(
                        GX.duration(10)
                    ),
                    GX.FlyTo(
                        GX.duration(5),
                        GX.flyToMode('bounce'),
                        KML.LookAt(
                            KML.longitude(-79.387),
                            KML.latitude(43.643),
                            KML.altitude(0),
                            KML.heading(-172.3),
                            KML.tilt(10),
                            KML.range(1200),
                            KML.altitudeMode('relativeToGround'),
                        )
                    )
                )
            )
        )
        self.assertTrue(Schema('kml22gx.xsd').validate(doc))

        data = etree.tostring(doc, encoding='ascii')
        expected = \
            b'<kml xmlns:gx="http://www.google.com/kml/ext/2.2" ' \
            b'xmlns:atom="http://www.w3.org/2005/Atom" ' \
            b'xmlns="http://www.opengis.net/kml/2.2">' \
            b'<gx:Tour>' \
            b'<gx:Playlist>' \
            b'<gx:SoundCue>' \
            b'<href>http://dev.keyhole.com/codesite/cntowerfacts.mp3</href>' \
            b'</gx:SoundCue>' \
            b'<gx:Wait>' \
            b'<gx:duration>10</gx:duration>' \
            b'</gx:Wait>' \
            b'<gx:FlyTo>' \
            b'<gx:duration>5</gx:duration>' \
            b'<gx:flyToMode>bounce</gx:flyToMode>' \
            b'<LookAt>' \
            b'<longitude>-79.387</longitude>' \
            b'<latitude>43.643</latitude>' \
            b'<altitude>0</altitude>' \
            b'<heading>-172.3</heading>' \
            b'<tilt>10</tilt>' \
            b'<range>1200</range>' \
            b'<altitudeMode>relativeToGround</altitudeMode>' \
            b'</LookAt>' \
            b'</gx:FlyTo>' \
            b'</gx:Playlist>' \
            b'</gx:Tour>' \
            b'</kml>'

        self.assertXmlEquivalentOutputs(data, expected)
开发者ID:recombinant,项目名称:pykml,代码行数:62,代码来源:test_factory.py

示例4: get_look_at

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
 def get_look_at(self):
   return \
     KML.LookAt(
       KML.longitude(self.camera[0]),
       KML.latitude(self.camera[1]),
       KML.altitude(self.camera[2]),
       KML.heading(self.camera[3]),
       KML.tilt(self.camera[4]),
       KML.range(self.camera[5]),
     )
开发者ID:IoannisIn,项目名称:cellbots,代码行数:12,代码来源:earth.py

示例5: create_flyto_camera

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
def create_flyto_camera(location):
    
    flyto = GX.FlyTo(
        GX.duration(0.5),
        GX.flyToMode('smooth'),
    )
    flyto.append(
        KML.Camera(
            KML.longitude(location['loc'].longitude),
            KML.latitude(location['loc'].latitude),
            KML.altitude(location['loc'].altitude),
            KML.heading(location['loc'].heading),
            KML.tilt(location['loc'].tilt),
            KML.roll(location['loc'].roll),
            KML.altitudeMode('relativeToGround'),
        )
    )
    return flyto
开发者ID:123abcde,项目名称:pykml,代码行数:20,代码来源:example_spline_camera.py

示例6: create_camera_model_placemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
def create_camera_model_placemark(location):
    
    pm = KML.Placemark(
        KML.description(
            '<table border="1">'
            '<tr><th>latitude</th><td>{lat}</td>'
            '<tr><th>longitude</th><td>{lon}</td>'
            '<tr><th>altitude</th><td>{alt}</td>'
            '<tr><th>heading</th><td>{head}</td>'
            '<tr><th>tilt</th><td>{tilt}</td>'
            '<tr><th>roll</th><td>{roll}</td>'
            '</table>'.format(
                lat=location['loc'].latitude,
                lon=location['loc'].longitude,
                alt=location['loc'].altitude,
                head=location['loc'].heading,
                tilt=location['loc'].tilt,
                roll=location['loc'].roll,
            )
        ),
        KML.Model(
            KML.altitudeMode('relativeToGround'),
            KML.Location(
              KML.latitude(location['loc'].latitude),
              KML.longitude(location['loc'].longitude),
              KML.altitude(location['loc'].altitude),
            ),
            KML.Orientation(
              KML.heading(location['loc'].heading),
              KML.tilt(-location['loc'].tilt),
              KML.roll(location['loc'].roll),
            ),
            KML.Scale(
              KML.x(10),
              KML.y(10),
              KML.z(-10),
            ),
            KML.Link(
              KML.href('models/three_unit_lines.dae'),
            )
        )
    )
    return pm
开发者ID:123abcde,项目名称:pykml,代码行数:45,代码来源:example_spline_camera.py

示例7: point_placemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
def point_placemark(origin, name, x, y):
    point = srr.util.local_to_global(origin, x, y)

    return KML.Placemark(
        KML.name(name),
        KML.LookAt(
            KML.longitude(point[0]),
            KML.latitude(point[1]),
            KML.altitude(0),
            KML.heading(origin[2]),
            KML.tilt(0),
            KML.roll(0),
            KML.altitudeMode("relativeToGround"),
            KML.range(DEFAULT_HEIGHT)
        ),
        KML.Point(
            KML.coordinates("{lon},{lat},{alt}".format(
                lon=point[0], lat=point[1], alt=0)),
            )
        )
开发者ID:cephalsystems,项目名称:srr,代码行数:22,代码来源:viewer.py

示例8: make_kml

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
 def make_kml(self, lon, lat):
     """
     :return: write kml file from defined properties
     """
     doc = KML.kml(
     etree.Comment(' required when using gx-prefixed elements '),
     GX.FlyTo(
     GX.flyToMode('bounce'),
     GX.duration('0.5')
     ),
     KML.Placemark(
     KML.name('gx:altitudeMode Example'),
     KML.Camera(
       KML.altitude(self.vh),
       KML.longitude(str(lon)),
       KML.latitude(str(lat))
     ),
     ),
     )
     string = etree.tostring(etree.ElementTree(doc),pretty_print=True)
     #writeToFile
     f = open(self.outfile, 'w')
     f.writelines(string)
     f.close()
开发者ID:initze,项目名称:GE_game,代码行数:26,代码来源:ge_game.py

示例9: frame_placemark

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
def frame_placemark(origin, name, x, y, theta=0.0,
                    marker='axes.png', scale=1.0, color='ffffffff'):
    frame = srr.util.local_to_global(origin, x, y, theta)

    return KML.Placemark(
        KML.name(name),
        KML.Point(
            KML.coordinates("{lon},{lat},{alt}".format(
                lon=frame[0], lat=frame[1], alt=0)),
            ),
        KML.LookAt(
            KML.longitude(frame[0]),
            KML.latitude(frame[1]),
            KML.altitude(0),
            KML.heading(frame[2]),
            KML.tilt(0),
            KML.roll(0),
            KML.altitudeMode("relativeToGround"),
            KML.range(DEFAULT_HEIGHT)
        ),
        KML.Style(
            KML.IconStyle(
                KML.scale(scale),
                KML.heading(frame[2]),
                KML.color(color),
                KML.Icon(
                    KML.href(flask.url_for('static',
                                           filename=marker,
                                           _external=True)),
                    ),
                KML.hotSpot(x="0.5", y="0.5",
                            xunits="fraction",
                            yunits="fraction")
                ),
            )
        )
开发者ID:cephalsystems,项目名称:srr,代码行数:38,代码来源:viewer.py

示例10:

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
   KML.styleUrl("#pushpin"),
   KML.Point(
     KML.coordinates(170.1435558771009,-43.60505741890396,0)
   ),
   id="mountainpin1"
 ),
 GX.Tour(
   KML.name("Play me!"),
   GX.Playlist(
     GX.FlyTo(
       GX.duration(3),
       GX.flyToMode("bounce"),
       KML.Camera(
         KML.longitude(170.157),
         KML.latitude(-43.671),
         KML.altitude(9700),
         KML.heading(-6.333),
         KML.tilt(33.5),
       )
     ),
     GX.AnimatedUpdate(
       GX.duration(5),
       KML.Update(
         KML.targetHref(),
         KML.Change(
           KML.IconStyle(
             KML.scale(10.0),
             targetId="mystyle"
           )
         )
       )
开发者ID:123abcde,项目名称:pykml,代码行数:33,代码来源:animatedupdate_example.py

示例11: _buildSwath

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
def _buildSwath(line, data, polyalt=5000):
    """
    So far, an ugly hack on building the KML elements
    """

    # split input line
    line = line.split()

    # add polygon altitude to end of line tuple
    line.append(polyalt)

    # parse the time element of the line
    dt = _makeTime(line[1])
    date = dt.date()
    time = dt.time()

    # define time format string
    format = "%Y-%m-%dT%H:%M:%SZ"

    # ensure longitude is between -/+ 180 degrees
    for i in [4, 6, 8, 10]:
        if float(line[i]) > 180.0:
            val = float(line[i]) - 360.0
            line[i] = str(val)

    # build the vertices of the swath (remember the first vertex has to
    # repeat at the end.
    vertices = []
    for c in [3, 5, 7, 9, 3, 5]:
        vertices.append(",".join([line[i] for i in [c + 1, c, -1]]))

    # get center of swath
    clat, clng = _swathCenter(line)

    # create an image placemark for the kml
    image = KML.Placemark(
        # define name based on experiment and filter/channel
        KML.name('{}: {}'.format(data['experiment'], data['filter'])),
        # define description
        # TODO: come up with a more flexible way of doing this...
        KML.description(
            'Orbit no.:                          {}\n'.format(
                data['orbit']),
            'Pericenter time (UTC):              {}\n'.format(
                data['pericenter time'].replace('_', ' ')),
            'First image time (UTC):             {}\n'.format(
                data['first image time'].replace('_', ' ')),
            'First image time (from pericenter): {}\n'.format(
                data['first image time from pericenter'].replace('_',
                                                                 ' ')),
            'Last image time (UTC):              {}\n'.format(
                data['last image time'].replace('_', ' ')),
            'Last image time (from pericenter):  {}\n\n'.format(
                data['last image time from pericenter'].replace('_', ' ')),
            'Image sequence:                     {}\n'.format(line[0]),
            'Image date:                         {}\n'.format(date),
            'Image time:                         {}\n'.format(time),
            'Orbit no.:                          {}\n\n'.format(
                data['orbit']),
            'Pericentre relative time:           {}\n'.format(
                line[2].replace('_', ' ')),
            'Duration:                           {}\n\n'.format(line[20]),
            'S/C altitude:                       {}\n'.format(line[21]),
            'S/C latitude:                       {}\n'.format(line[22]),
            'S/C longitude:                      {}\n'.format(line[23]),
            'S/C target elevation:               {}\n'.format(line[24]),
            'S/C target azimuth:                 {}\n\n'.format(line[25]),
            'Reflection Angle:                   {}\n'.format(line[27]),
            'Sun target elevation:               {}\n'.format(line[28]),
            'Sun target azimuth:                 {}\n'.format(line[29]),
            'Target phase:                       {}\n'.format(line[30]),
            'Target elongation:                  {}\n'.format(line[31]),
            'Local Time:                         {}\n'.format(line[32]),
            'Image smear:                        {}\n'.format(line[33]),
            'Mercury True Anomaly:               {}\n'.format(line[35])
        ),
        # specify appearance time
        KML.TimeSpan(
            #KML.begin(str(tempTime))
            KML.begin(dt.strftime(format))
        ),
        # the style for this swath has been mapped in <swath>stylemap
        KML.styleUrl('#{}stylemap'.format(data['filter'])),
        #KML.styleUrl('#{}1'.format(data['filter'])),
        # define where the 'eye' looks when this swath is double clicked
        KML.LookAt(
            KML.longitude(clng),
            KML.latitude(clat),
            KML.altitude('5000'),
            KML.heading('0'),
            KML.tilt('30'),
            KML.roll('0'),
            KML.altitudeMode('relativeToGround'),
            KML.range('1500000')
        ),
        # defined the geometry object that will hold the swath polygon
        KML.MultiGeometry(
            # defined the swath polygon
            KML.Polygon(
                #KML.tessellate('1'),
#.........这里部分代码省略.........
开发者ID:johnnycakes79,项目名称:pyops,代码行数:103,代码来源:maps.py

示例12: create_kml_tour

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [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

示例13: main

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

#.........这里部分代码省略.........
    except:
        print '%%%%%%%%%%'
        print 'Error:\nThe input file is not geocoded\n'
        print '%%%%%%%%%%'
        Usage();sys.exit(1)


    #######################################################
    ###################  Output KMZ  ######################

    ############### Make PNG file
    print 'Making png file ...'   
    length = data.shape[0]
    width  = data.shape[1]
    try:fig_size
    except:
        fig_size_0 = 6.0           ## min figure dimension: 6.0
        ratio = float(length)/float(width)
        fig_size = [fig_size_0,fig_size_0*ratio]
    print 'figure size:  %.1f, %.1f'%(fig_size[0],fig_size[1])
    ccmap = plt.get_cmap(color_map)
    fig = plt.figure(figsize=fig_size,frameon=False)
    ax = fig.add_axes([0., 0., 1., 1.])
    ax.set_axis_off()

    aspect = width/(length*1.0)
    try:     ax.imshow(data,aspect='auto',cmap=ccmap,vmax=Vmax,vmin=Vmin)
    except:  ax.imshow(data,aspect='auto',cmap=ccmap)

    if disp_ref == 'yes':
        try:
            xref = int(atr['ref_x'])
            yref = int(atr['ref_y'])
            ax.plot(xref,yref,'ks',ms=ref_size)
            print 'show reference point'
        except: print 'Cannot find reference point info!'

    ax.set_xlim([0,width])
    ax.set_ylim([length,0])

    figName = outName + '.png'
    print 'writing '+figName
    plt.savefig(figName, pad_inches=0.0, transparent=True, dpi=fig_dpi)

    ############### Making colorbar
    pc = plt.figure(figsize=(1,8))
    axc = pc.add_subplot(111)
    if   fig_unit in ['mm','mm/yr']: v_scale = 1000
    elif fig_unit in ['cm','cm/yr']: v_scale = 100
    elif fig_unit in ['m',  'm/yr']: v_scale = 1
    norm = mpl.colors.Normalize(vmin=Vmin*v_scale, vmax=Vmax*v_scale)
    clb  = mpl.colorbar.ColorbarBase(axc,cmap=ccmap,norm=norm, orientation='vertical')

    #clb.set_label(fig_unit)
    clb.set_label(cbar_label+' ['+fig_unit+']')
    clb.locator = ticker.MaxNLocator(nbins=cbar_bin_num)
    clb.update_ticks()

    pc.subplots_adjust(left=0.2,bottom=0.3,right=0.4,top=0.7)
    pc.patch.set_facecolor('white')
    pc.patch.set_alpha(0.7)
    pc.savefig('colorbar.png',bbox_inches='tight',facecolor=pc.get_facecolor(),dpi=300)

    ############## Generate KMZ file
    print 'generating kml file ...'
    try:     doc = KML.kml(KML.Folder(KML.name(atr['PROJECT_NAME'])))
    except:  doc = KML.kml(KML.Folder(KML.name('PySAR product')))
    slc = KML.GroundOverlay(KML.name(figName),KML.Icon(KML.href(figName)),\
                            KML.altitudeMode('clampToGround'),\
                            KML.LatLonBox(KML.north(str(North)),KML.south(str(South)),\
                                          KML.east( str(East)), KML.west( str(West))))
    doc.Folder.append(slc)

    #############################
    print 'adding colorscale ...'
    cb_rg = min(North-South, East-West)
    cb_N = (North+South)/2.0 + 0.5*0.5*cb_rg
    cb_W = East  + 0.1*cb_rg
    slc1 = KML.GroundOverlay(KML.name('colorbar'),KML.Icon(KML.href('colorbar.png')),\
                             KML.altitude('2000'),KML.altitudeMode('absolute'),\
                             KML.LatLonBox(KML.north(str(cb_N)),KML.south(str(cb_N-0.5*cb_rg)),\
                                           KML.west( str(cb_W)),KML.east( str(cb_W+0.14*cb_rg))))
    doc.Folder.append(slc1)

    #############################
    kmlstr = etree.tostring(doc, pretty_print=True) 
    kmlname = outName + '.kml'
    print 'writing '+kmlname
    kmlfile = open(kmlname,'w')
    kmlfile.write(kmlstr)
    kmlfile.close()

    kmzName = outName + '.kmz'
    print 'writing '+kmzName
    cmdKMZ = 'zip ' + kmzName +' '+ kmlname +' ' + figName + ' colorbar.png'
    os.system(cmdKMZ)

    cmdClean = 'rm '+kmlname;      print cmdClean;    os.system(cmdClean)
    cmdClean = 'rm '+figName;      print cmdClean;    os.system(cmdClean)
    cmdClean = 'rm colorbar.png';  print cmdClean;    os.system(cmdClean)
开发者ID:yunjunz,项目名称:PySAR,代码行数:104,代码来源:save_kml.py

示例14:

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
            KML.name('Features'),
            id='features',
        ),
    )
)
for feature in feature_list:
    # 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(feature['lon']),
                KML.latitude(feature['lat']),
                KML.altitude(0),
                KML.heading(0),
                KML.tilt(0),
                KML.range(10000000.0),
                KML.altitudeMode("relativeToGround"),
            )
        ),
    )
    # fly to the feature
    tour_doc.Document[gxns + "Tour"].Playlist.append(
        GX.FlyTo(
            GX.duration(5),
            GX.flyToMode("bounce"),
            KML.LookAt(
                KML.longitude(feature['lon']),
                KML.latitude(feature['lat']),
开发者ID:recombinant,项目名称:pykml,代码行数:33,代码来源:circle_around_landmarks.py

示例15: set_max_decimal_places

# 需要导入模块: from pykml.factory import KML_ElementMaker [as 别名]
# 或者: from pykml.factory.KML_ElementMaker import altitude [as 别名]
def set_max_decimal_places(doc, max_decimals):
    """Sets the maximum number of decimal places used by KML elements
    
    This method facilitates reducing the file size of a KML document.
    """
    
    def replace_delimited_string_member(
            delimited_str,
            separator,
            index_no,
            decimal_places):
        "Modify the number of decimal places for a delimited string member"
        values = delimited_str.split(separator)
        values[index_no] = str(round(float(values[index_no]), decimal_places))
        return separator.join(values)
    
    if max_decimals.has_key('longitude'):
        data_type = 'longitude'
        index_no = 0 # longitude is in the first position
        # modify <longitude>
        for el in doc.findall(".//{http://www.opengis.net/kml/2.2}longitude"):
            new_val = round(float(el.text), max_decimals[data_type])
            el.getparent().longitude = K.longitude(new_val)
        # modify <coordinates> elements
        for el in doc.findall(".//{http://www.opengis.net/kml/2.2}coordinates"):
            vertex_str_list = []
            for vertex in el.text.strip().split(' '):
                vertex_str_list.append(
                    replace_delimited_string_member(
                        delimited_str=vertex,
                        separator=',',
                        index_no=index_no,
                        decimal_places=max_decimals[data_type]
                    )
                )
            el_new = K.coordinates(' '.join(vertex_str_list).strip())
            el.getparent().replace(el, el_new)
        # modify <gx:coords> elements
        for el in doc.findall(".//{http://www.google.com/kml/ext/2.2}coord"):
            el._setText(
                replace_delimited_string_member(
                    delimited_str=el.text,
                    separator=' ',
                    index_no=index_no,
                    decimal_places=max_decimals[data_type]
                )
            )
    
    if max_decimals.has_key('latitude'):
        data_type = 'latitude'
        index_no = 1 # latitude is in the second position
        # modify <latitude> elements
        for el in doc.findall(".//{http://www.opengis.net/kml/2.2}latitude"):
            new_val = round(float(el.text), max_decimals[data_type])
            el.getparent().latitude = K.latitude(new_val)
        # modify <coordinates> elements
        for el in doc.findall(".//{http://www.opengis.net/kml/2.2}coordinates"):
            vertex_str_list = []
            for vertex in el.text.strip().split(' '):
                vertex_str_list.append(
                    replace_delimited_string_member(
                        delimited_str=vertex,
                        separator=',',
                        index_no=index_no,
                        decimal_places=max_decimals[data_type]
                    )
                )
            el_new = K.coordinates(' '.join(vertex_str_list).strip())
            el.getparent().replace(el, el_new)
        # modify <gx:coords> elements
        for el in doc.findall(".//{http://www.google.com/kml/ext/2.2}coord"):
            el._setText(
                replace_delimited_string_member(
                    delimited_str=el.text,
                    separator=' ',
                    index_no=index_no,
                    decimal_places=max_decimals[data_type]
                )
            )

    if max_decimals.has_key('altitude'):
        data_type = 'altitude'
        index_no = 2 # altitude is in the third position
        # modify <altitude> elements
        for el in doc.findall(".//{http://www.opengis.net/kml/2.2}altitude"):
            new_val = round(float(el.text), max_decimals[data_type])
            el.getparent().altitude = K.altitude(new_val)
        # modify <coordinates> elements
        for el in doc.findall(".//{http://www.opengis.net/kml/2.2}coordinates"):
            vertex_str_list = []
            for vertex in el.text.strip().split(' '):
                vertex_str_list.append(
                    replace_delimited_string_member(
                        delimited_str=vertex,
                        separator=',',
                        index_no=index_no,
                        decimal_places=max_decimals[data_type]
                    )
                )
            el_new = K.coordinates(' '.join(vertex_str_list).strip())
#.........这里部分代码省略.........
开发者ID:123abcde,项目名称:pykml,代码行数:103,代码来源:helpers.py


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