How to use the pykml.factory.KML_ElementMaker.latitude function in pykml

To help you get started, we’ve selected a few pykml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pykml / pykml / src / pykml / helpers.py View on Github external
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  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  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  elements
        for el in doc.findall(".//{http://www.google.com/kml/ext/2.2}coord"):
github grst / geos / pykml_geos / helpers.py View on Github external
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  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  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  elements
        for el in doc.findall(".//{http://www.google.com/kml/ext/2.2}coord"):
github pykml / pykml / src / examples / KmlReference / altitudemode_reference.py View on Github external
References:
http://code.google.com/apis/kml/documentation/kmlreference.html#gxaltitudemode
http://code.google.com/apis/kml/documentation/kmlfiles/altitudemode_reference.kml
'''

from lxml import etree
from pykml.parser import Schema
from pykml.factory import KML_ElementMaker as KML
from pykml.factory import GX_ElementMaker as GX

doc = KML.kml(
    KML.Placemark(
        KML.name("gx:altitudeMode Example"),
        KML.LookAt(
            KML.longitude(146.806),
            KML.latitude(12.219),
            KML.heading(-60),
            KML.tilt(70),
            KML.range(6300),
            GX.altitudeMode("relativeToSeaFloor"),
        ),
        KML.LineString(
            KML.extrude(1),
            GX.altitudeMode("relativeToSeaFloor"),
            KML.coordinates(
              "146.825,12.233,400 "
              "146.820,12.222,400 "
              "146.812,12.212,400 "
              "146.796,12.209,400 "
              "146.788,12.205,400"
            )
        )
github pykml / pykml / src / examples / KmlReference / animatedupdate_example.py View on Github external
KML.name("Pin on a mountaintop"),
      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"
              )
            )
          )
github pykml / pykml / src / examples / Tours / example_spline_camera.py View on Github external
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
github pykml / pykml / src / examples / Tours / circle_around_landmarks.py View on Github external
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']),
          KML.altitude(0),
          KML.heading(0),
          KML.tilt(feature['tilt']),
          KML.range(feature['range']),
          KML.altitudeMode("relativeToGround"),
        )
      ),
    )
    # spin around the feature
    for aspect in range(0,360,10):
        tour_doc.Document[gxns+"Tour"].Playlist.append(
          GX.FlyTo(
            GX.duration(0.25),
            GX.flyToMode("smooth"),
            KML.LookAt(
              KML.longitude(feature['lon']),
github pykml / pykml / src / examples / Tours / example_spline_camera.py View on Github external
'heading{head}'
            'tilt{tilt}'
            'roll{roll}'
            ''.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'),
            )