Module: NSWTopo::Formats::Kmz

Extended by:
Kmz
Included in:
Kmz
Defined in:
lib/nswtopo/formats/kmz.rb

Constant Summary collapse

TILE_SIZE =
512
EARTH_RADIUS =
6378137.0
TILT =

40 * Math::PI / 180.0

0
FOV =
25 * Math::PI / 180.0

Instance Method Summary collapse

Instance Method Details

#lat_lon_box(bounds) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/nswtopo/formats/kmz.rb', line 20

def lat_lon_box(bounds)
  lambda do |box|
    [%w[west east south north], bounds.flatten].transpose.each do |limit, value|
      box.add_element(limit).text = value
    end
  end
end


38
39
40
41
42
43
44
45
46
47
# File 'lib/nswtopo/formats/kmz.rb', line 38

def network_link(bounds, path)
  lambda do |network|
    network.add_element("Region").tap(&region(bounds))
    network.add_element("Link").tap do |link|
      link.add_element("href").text = path
      link.add_element("viewRefreshMode").text = "onRegion"
      link.add_element("viewFormat")
    end
  end
end

#region(bounds, topmost = false) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/nswtopo/formats/kmz.rb', line 28

def region(bounds, topmost = false)
  lambda do |region|
    region.add_element("Lod").tap do |lod|
      lod.add_element("minLodPixels").text = topmost ? 0 : TILE_SIZE / 2
      lod.add_element("maxLodPixels").text = -1
    end
    region.add_element("LatLonAltBox").tap(&lat_lon_box(bounds))
  end
end

#styleObject



12
13
14
15
16
17
18
# File 'lib/nswtopo/formats/kmz.rb', line 12

def style
  lambda do |style|
    style.add_element("ListStyle", "id" => "hideChildren").tap do |list_style|
      list_style.add_element("listItemType").text = "checkHideChildren"
    end
  end
end