-
Notifications
You must be signed in to change notification settings - Fork 0
/
kml_test.go
64 lines (52 loc) · 1.7 KB
/
kml_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package gokml
import (
"fmt"
"testing"
"time"
)
func TestKML(t *testing.T) {
k := NewKML("Test KML")
f := NewFolder("Test Folder", "This is a test folder")
k.AddFeature(f)
places := NewStyle("PlaceStyle", 240, 0, 255, 0)
places.SetIconURL("http://maps.google.com/mapfiles/kml/paddle/wht-circle.png")
f.AddFeature(places)
flights := NewStyle("FlightStyle", 240, 255, 0, 0)
f.AddFeature(flights)
states := NewStyle("StateStyle", 240, 0, 0, 255)
f.AddFeature(states)
manhattan := NewPoint(40.67, -73.9, 0.0)
pm := NewPlacemark("Manhattan", "The Big Apple", manhattan)
pm.SetStyle("PlaceStyle")
f.AddFeature(pm)
london := NewPoint(51.51, 0.1275, 0.0)
pm = NewPlacemark("London", "The City", london)
pm.SetStyle("PlaceStyle")
f.AddFeature(pm)
paris := NewPoint(48.85, 2.35, 0.0)
pm = NewPlacemark("Paris", "The City of Light", paris)
pm.SetStyle("PlaceStyle")
f.AddFeature(pm)
tokyo := NewPoint(35.69, 139.7, 0.0)
pm = NewPlacemark("Tokyo", "東京", tokyo)
pm.SetStyle("PlaceStyle")
f.AddFeature(pm)
flightPath := NewLineString()
flightPath.AddPoint(manhattan)
flightPath.AddPoint(london)
flightPath.AddPoint(paris)
flightPath.AddPoint(tokyo)
pm = NewPlacemark("Flight Path", "", flightPath)
pm.SetStyle("FlightStyle")
f.AddFeature(pm)
colorado := NewPolygon()
colorado.AddPoint(NewPoint(41.071904, -101.868843, 0.0))
colorado.AddPoint(NewPoint(36.926393, -101.868843, 0.0))
colorado.AddPoint(NewPoint(36.926393, -109.279635, 0.0))
colorado.AddPoint(NewPoint(41.071904, -109.279635, 0.0))
pm = NewPlacemark("Colorado", "The Centennial State", colorado)
pm.SetStyle("StateStyle")
pm.SetTime(time.Now().Add(-10*time.Hour), time.Now())
f.AddFeature(pm)
fmt.Printf("%s", k.Render())
}