Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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']),
KML.latitude(feature['lat']),
KML.altitude(0),
KML.heading(aspect),
KML.tilt(feature['tilt']),
KML.range(feature['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"))
# )
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
deltat = 30 # set manually, not sure what is wrong with the previous eqn
#import ipdb; ipdb.set_trace()
# calculate the horizontal and rotational velocities
vy = (loc1['latitude'] - loc0['latitude']) / deltat
vx = (loc1['longitude'] - loc0['longitude']) / deltat
vh = (loc1['heading'] - loc0['heading']) / deltat
vt = (loc1['tilt'] - loc0['tilt']) / deltat
# create a tour object
tour_doc = kml.kml(
kml.Folder(
gx.Tour(
kml.name("Play me!"),
gx.Playlist(),
)
)
)
tstep = 0.1
for t in drange(0,15,tstep):
pm = kml.Placemark(
kml.name(str(t)),
kml.Point(
kml.altitudeMode("absolute"),
kml.coordinates("{lon},{lat},{alt}".format(
lon=loc0['longitude'] + vx*t,
lat=loc0['latitude'] + vy*t,
alt=loc0['altitude'] + vz*t + 0.5*g*t**2,
)),
},
{
'name':"Racetrack Playa",
'desc':'Death Valley, California, USA',
'lon':-117.56, 'lat':36.679, 'tilt':45, 'range':8000
},
{
'name':"Matterhorn",
'desc':'Pennine Alps, Switzerland/Italy',
'lon':7.6584, 'lat':45.9766, 'tilt':60, 'range':6000,
},
]
# 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('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"),
'name':"Racetrack Playa",
'desc':'Death Valley, California, USA',
'lon':-117.56, 'lat':36.679, 'tilt':45, 'range':8000
},
{
'name':"Matterhorn",
'desc':'Pennine Alps, Switzerland/Italy',
'lon':7.6584, 'lat':45.9766, 'tilt':60, 'range':6000,
},
]
# 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('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']),
fld1 = KML.Folder(KML.name('original'))
for loc in known_positions:
fld1.append(create_placemarks(loc))
# create a folder of interpolated placemarks
fld2 = KML.Folder(KML.name('interpolated'))
for loc in interp_positions:
fld2.append(create_placemarks(loc))
# create a folder of models showing camera positions/orientations
fld3 = KML.Folder(KML.name('cameras'))
for loc in interp_positions:
fld3.append(create_camera_model_placemark(loc))
# create a tour of camera positions
playlist = GX.Playlist()
for loc in interp_positions:
playlist.append(create_flyto_camera(loc))
fld = KML.Folder(
fld1,
fld2,
fld3,
GX.Tour(playlist),
)
print etree.tostring(fld, pretty_print=True)
id="mystyle"
),
id="pushpin"
),
KML.Placemark(
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(
z1 = loc1['altitude']
deltat = (-vz - math.sqrt(vz**2 - 2*g*(z0-z1))) / g
deltat = 30 # set manually, not sure what is wrong with the previous eqn
#import ipdb; ipdb.set_trace()
# calculate the horizontal and rotational velocities
vy = (loc1['latitude'] - loc0['latitude']) / deltat
vx = (loc1['longitude'] - loc0['longitude']) / deltat
vh = (loc1['heading'] - loc0['heading']) / deltat
vt = (loc1['tilt'] - loc0['tilt']) / deltat
# create a tour object
tour_doc = kml.kml(
kml.Folder(
gx.Tour(
kml.name("Play me!"),
gx.Playlist(),
)
)
)
tstep = 0.1
for t in drange(0,15,tstep):
pm = kml.Placemark(
kml.name(str(t)),
kml.Point(
kml.altitudeMode("absolute"),
kml.coordinates("{lon},{lat},{alt}".format(
lon=loc0['longitude'] + vx*t,
lat=loc0['latitude'] + vy*t,
alt=loc0['altitude'] + vz*t + 0.5*g*t**2,
# create a folder of models showing camera positions/orientations
fld3 = KML.Folder(KML.name('cameras'))
for loc in interp_positions:
fld3.append(create_camera_model_placemark(loc))
# create a tour of camera positions
playlist = GX.Playlist()
for loc in interp_positions:
playlist.append(create_flyto_camera(loc))
fld = KML.Folder(
fld1,
fld2,
fld3,
GX.Tour(playlist),
)
print etree.tostring(fld, pretty_print=True)