-
Notifications
You must be signed in to change notification settings - Fork 3
/
polyline.go
56 lines (51 loc) · 2.96 KB
/
polyline.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
package czml
// Polyline is a line in the scene composed of multiple segments.
// https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/Polyline
type Polyline struct {
Show *bool `json:"show,omitempty"`
Positions *PositionList `json:"positions"`
ArcType *ArcType `json:"arcType,omitempty"`
Width *float64 `json:"width,omitempty"`
Granularity *float64 `json:"granularity,omitempty"`
Material *PolylineMaterial `json:"material,omitempty"`
FollowSurface *bool `json:"followSurface,omitempty"`
Shadows ShadowMode `json:"shadows,omitempty"`
DepthFailMaterial *PolylineMaterial `json:"depthFailMaterial,omitempty"`
DistanceDisplayCondition *DistanceDisplayCondition `json:"distanceDisplayCondition,omitempty"`
ClampToGround *bool `json:"clampToGround,omitempty"`
ClassificationType ClassificationType `json:"classificationType,omitempty"`
ZIndex *int `json:"zIndex,omitempty"`
}
// PolylineVolume is a polyline with a volume, defined as a 2D shape extruded along a polyline
// that conforms to the curvature of the globe.
// https://github.com/AnalyticalGraphicsInc/czml-writer/wiki/PolylineVolume
type PolylineVolume struct {
Show *bool `json:"show,omitempty"`
Positions *PositionList `json:"positions"`
Shape *Shape `json:"shape"`
CornerType *CornerType `json:"cornerType,omitempty"`
Granularity *float64 `json:"granularity,omitempty"`
Fill *bool `json:"fill,omitempty"`
Material *PolylineMaterial `json:"material,omitempty"`
Outline *bool `json:"outline,omitempty"`
OutlineColor *Color `json:"outlineColor,omitempty"`
OutlineWidth *float64 `json:"outlineWidth,omitempty"`
Shadows ShadowMode `json:"shadows,omitempty"`
DistanceDisplayCondition *DistanceDisplayCondition `json:"distanceDisplayCondition,omitempty"`
}
// UpdateColor adds or updates a solid-colored line specified by rgba value
func (p *Polyline) UpdateColor(rgba []int) {
c := Color{Rgba: rgba}
s := SolidColorMaterial{Color: &c}
m := PolylineMaterial{SolidColor: &s}
p.Material = &m
}
// AddPoint adds a geographical point
func (p *Polyline) AddPoint(lat, lon, ele float64) {
if p.Positions == nil {
p.Positions = &PositionList{}
} else if p.Positions.CartographicDegrees == nil {
p.Positions.CartographicDegrees = []float64{}
}
p.Positions.CartographicDegrees = append(p.Positions.CartographicDegrees, lon, lat, ele)
}