From 516022ff84318aeecc7e1060819119010340c10a Mon Sep 17 00:00:00 2001 From: Konstantin Dudkov Date: Wed, 30 Mar 2022 23:50:00 +0300 Subject: [PATCH] parent --- cmd/goatak_server/templates/map.html | 36 ++++++++++++-------- cmd/webclient/templates/map.html | 36 ++++++++++++-------- model/http.go | 49 +++++++++++++++------------- model/unit.go | 35 ++++++++++++++++---- 4 files changed, 100 insertions(+), 56 deletions(-) diff --git a/cmd/goatak_server/templates/map.html b/cmd/goatak_server/templates/map.html index e63722c..0a26e4d 100644 --- a/cmd/goatak_server/templates/map.html +++ b/cmd/goatak_server/templates/map.html @@ -114,16 +114,21 @@
UID: {{current_unit.uid}}
- Team: {{current_unit.team}}, Role: {{current_unit.role}}
+
Team: {{current_unit.team}}, Role: + {{current_unit.role}} +
Type: {{current_unit.type}} SIDC: {{current_unit.sidc}}
- coords: {{printCoords(current_unit.lat, current_unit.lon)}} - - ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) -
+
+ coords: {{printCoords(current_unit.lat, current_unit.lon)}} + + ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) +
speed: {{sp(current_unit.speed)}} km/h, hae: {{current_unit.hae.toFixed(1)}}
- ver: {{current_unit.tak_version}}
+
ver: {{current_unit.tak_version}}
+
parent: {{current_unit.parent_callsign}} +
time: {{dt(current_unit.start_time)}} stale: {{dt(current_unit.stale_time)}}
last seen: {{dt(current_unit.last_seen)}}
{{current_unit.text}} @@ -139,12 +144,15 @@
UID: {{current_unit.uid}}
Type: {{current_unit.type}} SIDC: {{current_unit.sidc}}
- coords: {{printCoords(current_unit.lat, current_unit.lon)}} - - ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) -
+
+ coords: {{printCoords(current_unit.lat, current_unit.lon)}} + + ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) +
+
parent: {{current_unit.parent_callsign}} +
{{current_unit.text}}
diff --git a/cmd/webclient/templates/map.html b/cmd/webclient/templates/map.html index c1c7a9d..aeb903a 100644 --- a/cmd/webclient/templates/map.html +++ b/cmd/webclient/templates/map.html @@ -114,16 +114,21 @@
UID: {{current_unit.uid}}
- Team: {{current_unit.team}}, Role: {{current_unit.role}}
+
Team: {{current_unit.team}}, Role: + {{current_unit.role}} +
Type: {{current_unit.type}} SIDC: {{current_unit.sidc}}
- coords: {{printCoords(current_unit.lat, current_unit.lon)}} - - ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) -
+
+ coords: {{printCoords(current_unit.lat, current_unit.lon)}} + + ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) +
speed: {{sp(current_unit.speed)}} km/h, hae: {{current_unit.hae.toFixed(1)}}
- ver: {{current_unit.tak_version}}
+
ver: {{current_unit.tak_version}}
+
parent: {{current_unit.parent_callsign}} +
time: {{dt(current_unit.start_time)}} stale: {{dt(current_unit.stale_time)}}
last seen: {{dt(current_unit.last_seen)}}
{{current_unit.text}} @@ -139,12 +144,15 @@
UID: {{current_unit.uid}}
Type: {{current_unit.type}} SIDC: {{current_unit.sidc}}
- coords: {{printCoords(current_unit.lat, current_unit.lon)}} - - ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) -
+
+ coords: {{printCoords(current_unit.lat, current_unit.lon)}} + + ({{ distBea(latlng(current_unit.lat, current_unit.lon), coords) }} to cursor) +
+
parent: {{current_unit.parent_callsign}} +
{{current_unit.text}}
diff --git a/model/http.go b/model/http.go index 4201375..de9e758 100644 --- a/model/http.go +++ b/model/http.go @@ -10,27 +10,29 @@ import ( ) type WebUnit struct { - Uid string `json:"uid"` - Callsign string `json:"callsign"` - Category string `json:"category"` - Team string `json:"team"` - Role string `json:"role"` - Time time.Time `json:"time"` - LastSeen time.Time `json:"last_seen"` - StaleTime time.Time `json:"stale_time"` - StartTime time.Time `json:"start_time"` - SendTime time.Time `json:"send_time"` - Type string `json:"type"` - Lat float64 `json:"lat"` - Lon float64 `json:"lon"` - Hae float64 `json:"hae"` - Speed float64 `json:"speed"` - Course float64 `json:"course"` - Sidc string `json:"sidc"` - TakVersion string `json:"tak_version"` - Status string `json:"status"` - Text string `json:"text"` - Color string `json:"color"` + Uid string `json:"uid"` + Callsign string `json:"callsign"` + Category string `json:"category"` + Team string `json:"team"` + Role string `json:"role"` + Time time.Time `json:"time"` + LastSeen time.Time `json:"last_seen"` + StaleTime time.Time `json:"stale_time"` + StartTime time.Time `json:"start_time"` + SendTime time.Time `json:"send_time"` + Type string `json:"type"` + Lat float64 `json:"lat"` + Lon float64 `json:"lon"` + Hae float64 `json:"hae"` + Speed float64 `json:"speed"` + Course float64 `json:"course"` + Sidc string `json:"sidc"` + TakVersion string `json:"tak_version"` + Status string `json:"status"` + Text string `json:"text"` + Color string `json:"color"` + ParentCallsign string `json:"parent_callsign"` + ParentUid string `json:"parent_uid"` } type DigitalPointer struct { @@ -62,13 +64,16 @@ func (c *Contact) ToWeb() *WebUnit { func (u *Unit) ToWeb() *WebUnit { w := u.Item.ToWeb() w.Category = "unit" + w.ParentUid = u.parentUid + w.ParentCallsign = u.parentCallsign return w } func (p *Point) ToWeb() *WebUnit { w := p.Item.ToWeb() w.Category = "point" - + w.ParentUid = p.parentUid + w.ParentCallsign = p.parentCallsign return w } diff --git a/model/unit.go b/model/unit.go index edd0136..4ed374e 100644 --- a/model/unit.go +++ b/model/unit.go @@ -32,8 +32,10 @@ type Item struct { type Unit struct { Item - mx sync.RWMutex - track []*Pos + parentCallsign string + parentUid string + mx sync.RWMutex + track []*Pos } type Contact struct { @@ -46,8 +48,8 @@ type Contact struct { type Point struct { Item - authorCallsign string - authorUid string + parentCallsign string + parentUid string } func (c *Contact) String() string { @@ -140,17 +142,32 @@ func UnitFromMsg(msg *cot.Msg) *Unit { speed: msg.TakMessage.GetCotEvent().GetDetail().GetTrack().GetSpeed(), } - return &Unit{ + u := &Unit{ Item: ItemFromMsg(msg), mx: sync.RWMutex{}, track: []*Pos{pos}, } + + link := msg.Detail.GetFirstChild("link") + if link.GetAttr("relation") == "p-p" { + u.parentCallsign = link.GetAttr("parent_callsign") + u.parentUid = link.GetAttr("uid") + } + return u } func PointFromEvent(msg *cot.Msg) *Point { - return &Point{ + p := &Point{ Item: ItemFromMsg(msg), } + + link := msg.Detail.GetFirstChild("link") + if link.GetAttr("relation") == "p-p" { + p.parentCallsign = link.GetAttr("parent_callsign") + p.parentUid = link.GetAttr("uid") + } + + return p } func ItemFromMsg(msg *cot.Msg) Item { @@ -200,6 +217,12 @@ func (u *Unit) Update(msg *cot.Msg) { pos := getPos(u.msg, msg) u.msg = msg + link := msg.Detail.GetFirstChild("link") + if link.GetAttr("relation") == "p-p" { + u.parentCallsign = link.GetAttr("parent_callsign") + u.parentUid = link.GetAttr("uid") + } + if pos != nil { u.track = append(u.track, pos)