Top Level Namespace

Defined Under Namespace

Modules: Kamelopard Classes: Geocoder, NDPointList, OneDPointList, ThreeDPointList, TwoDPointList, YahooGeocoder

Instance Method Summary collapse

Instance Method Details

#fly_to(p, d = 0, r = 100, m = nil) ⇒ Object

vim:ts=4:sw=4:et:smartindent:nowrap



2
3
4
5
# File 'lib/kamelopard/functions.rb', line 2

def fly_to(p, d = 0, r = 100, m = nil)
    m = Kamelopard::Document.instance.flyto_mode if m.nil?
    Kamelopard::FlyTo.new(p, r, d, m)
end

#get_kmlObject

Returns the KML that makes up the current Kamelopard::Document, as a string.



39
40
41
# File 'lib/kamelopard/functions.rb', line 39

def get_kml
    Kamelopard::Document.instance.get_kml_document
end

#get_kml_stringObject



43
44
45
# File 'lib/kamelopard/functions.rb', line 43

def get_kml_string
    get_kml.to_s
end

#hide_popup_for(p) ⇒ Object



26
27
28
# File 'lib/kamelopard/functions.rb', line 26

def hide_popup_for(p)
    mod_popup_for(p, 0)
end

#mod_popup_for(p, v) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/kamelopard/functions.rb', line 11

def mod_popup_for(p, v)
    au = Kamelopard::AnimatedUpdate.new
    if ! p.is_a? Kamelopard::Placemark then
        raise "Can't show popups for things that aren't placemarks"
    end
    a = XML::Node.new 'Change'
    b = XML::Node.new 'Placemark'
    b.attributes['targetId'] = p.obj_id
    c = XML::Node.new 'visibility'
    c << XML::Node.new_text(v.to_s)
    b << c
    a << b
    au << a
end

#name_folder(a) ⇒ Object



59
60
61
# File 'lib/kamelopard/functions.rb', line 59

def name_folder(a)
    Kamelopard::Document.instance.folder.name = a
end

#name_tour(a) ⇒ Object



51
52
53
# File 'lib/kamelopard/functions.rb', line 51

def name_tour(a)
    Kamelopard::Document.instance.tour.name = a
end

#new_folder(name) ⇒ Object



55
56
57
# File 'lib/kamelopard/functions.rb', line 55

def new_folder(name)
    Kamelopard::Folder.new(name)
end

#orbit(center, range = 100, tilt = 0, startHeading = 0, endHeading = 360) ⇒ Object

Creates a list of FlyTo elements to orbit and look at a given point (center), at a given range (in meters), starting and ending at given angles (in degrees) from the center, where 0 and 360 (and -360, and 720, and -980, etc.) are north. To orbit clockwise, make startHeading less than endHeading. Otherwise, it will orbit counter-clockwise. To orbit multiple times, add or subtract 360 from the endHeading. The tilt argument matches the KML LookAt tilt argument



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/kamelopard/functions.rb', line 77

def orbit(center, range = 100, tilt = 0, startHeading = 0, endHeading = 360)
    fly_to Kamelopard::LookAt.new(center, startHeading, tilt, range), 2, nil

    # We want at least 5 points (arbitrarily chosen value), plus at least 5 for
    # each full revolution

    # When I tried this all in one step, ruby told me 360 / 10 = 1805. I'm sure
    # there's some reason why this is a feature and not a bug, but I'd rather
    # not look it up right now.
    num = (endHeading - startHeading).abs
    den = ((endHeading - startHeading) / 360.0).to_i.abs * 5 + 5
    step = num / den
    step = 1 if step < 1
    step = step * -1 if startHeading > endHeading

    lastval = startHeading
    startHeading.step(endHeading, step) do |theta|
        lastval = theta
        fly_to Kamelopard::LookAt.new(center, theta, tilt, range), 2, nil, 'smooth'
    end
    if lastval != endHeading then
        fly_to Kamelopard::LookAt.new(center, endHeading, tilt, range), 2, nil, 'smooth'
    end
end

#pause(p) ⇒ Object



47
48
49
# File 'lib/kamelopard/functions.rb', line 47

def pause(p)
    Kamelopard::Wait.new p
end

#point(lo, la, alt = 0, mode = nil, extrude = false) ⇒ Object



34
35
36
# File 'lib/kamelopard/functions.rb', line 34

def point(lo, la, alt=0, mode=nil, extrude = false)
    Kamelopard::Point.new(lo, la, alt, mode.nil? ? :clampToGround : mode, extrude)
end

#set_flyto_mode_to(a) ⇒ Object



7
8
9
# File 'lib/kamelopard/functions.rb', line 7

def set_flyto_mode_to(a)
    Kamelopard::Document.instance.flyto_mode = a
end

#show_popup_for(p) ⇒ Object



30
31
32
# File 'lib/kamelopard/functions.rb', line 30

def show_popup_for(p)
    mod_popup_for(p, 1)
end

#sound_cue(href, ds = nil) ⇒ Object



102
103
104
# File 'lib/kamelopard/functions.rb', line 102

def sound_cue(href, ds = nil)
    Kamelopard::SoundCue.new href, ds
end

#zoom_out(dist = 1000, dur = 0, mode = nil) ⇒ Object



63
64
65
66
67
68
# File 'lib/kamelopard/functions.rb', line 63

def zoom_out(dist = 1000, dur = 0, mode = nil)
    l = Kamelopard::Document.instance.tour.last_abs_view
    raise "No current position to zoom out from\n" if l.nil?
    l.range += dist
    Kamelopard::FlyTo.new(l, nil, dur, mode)
end