From c406c5dbaf037c3cf8b4a9d41b902d4f9816a7e5 Mon Sep 17 00:00:00 2001
From: Oleksandr Husak <oleksandr.husak@mailbox.tu-dresden.de>
Date: Tue, 26 Apr 2022 10:18:30 +0200
Subject: [PATCH] waypoint: spelling mistake, color and message structure

---
 README.md                               |  2 +-
 src/app/components/map/map.component.ts | 23 ++++++++++++-----------
 src/app/model/base-model.ts             | 10 +++++-----
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/README.md b/README.md
index fb19aa7..b2aa21b 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ Connection settings
             ```
             - More objects can be added to the `"object": []`
             - There are special colours for objects. Config: [MarkerColorList](src/environments/environment.ts)
-    - topic `ipos/client/way`
+    - topic `ipos/client/waypoint`
         - new way points
             - ```json
                 [
diff --git a/src/app/components/map/map.component.ts b/src/app/components/map/map.component.ts
index 200622b..9401b98 100644
--- a/src/app/components/map/map.component.ts
+++ b/src/app/components/map/map.component.ts
@@ -68,12 +68,14 @@ export class MapComponent implements OnInit {
     });
 
 
-    // --- Agent way points
-    this.subsWayPoint = this._mqttService.observe('ipos/client/way').subscribe((message: IMqttMessage) => {
+    // --- Agent waypoints
+    this.subsWayPoint = this._mqttService.observe('ipos/client/waypoint').subscribe((message: IMqttMessage) => {
       try {
         let points: WayPoint[] = <WayPoint[]>JSON.parse(message.payload.toString())
-        
-        console.log(points)
+
+        if (!(Array.isArray(points))) {
+          points = [points]
+        }
 
         points.forEach(wayPoint => {
           if (isWayPoint(wayPoint)) {
@@ -143,21 +145,21 @@ export class MapComponent implements OnInit {
   registerWayPoint(wayPoint: WayPoint) {
     // empty position
     if (wayPoint.position==undefined) {
-      console.log("Error: empty position.")
+      console.log("Error: empty waypoint position.")
       return
     }
 
     // empty position
     if (Object.values(wayPoint.position).every((e)=>{e==undefined})) {
-      console.log("Error: empty point.")
+      console.log("Error: empty position.")
       return;
     }
 
     let key = wayPoint.agentId
 
     // --- Marker config
-    let serialNum = Object.keys(this.markOverlays).indexOf(key)
-    var markerConf = getMarkerConfig(serialNum)
+    // let serialNum = Object.keys(this.markOverlays).indexOf(key) // ref to markers
+    // var markerConf = getMarkerConfig(serialNum)
 
     // --- Layer on the map
     if (!(key in this.wayPointsOverlays)) {
@@ -173,14 +175,13 @@ export class MapComponent implements OnInit {
     }
 
     // --- Marker
-
     let markerDesc = `<p> \
-      <h4>Way point</h4>
+      <h3>Waypoint</h3>
       <strong>Agent</strong>: ${wayPoint.agentId} <br>\
       <strong>Time</strong>: ${wayPoint.time} <br>
     </p>`
 
-    let marker = L.circleMarker(globPos, {radius: 5, color: markerConf.color}).bindPopup(markerDesc).openPopup();
+    let marker = L.circleMarker(globPos, {radius: 5, color: "#d97b16"}).bindPopup(markerDesc).openPopup();
     marker.addTo(this.wayPointsOverlays[key])
   }
 
diff --git a/src/app/model/base-model.ts b/src/app/model/base-model.ts
index 19520ba..0597e70 100644
--- a/src/app/model/base-model.ts
+++ b/src/app/model/base-model.ts
@@ -114,11 +114,11 @@ export function isAgent(obj: any): obj is Agent {
 // --- Way points
 
 export interface WayPoint {
-    "agentId": string
-    "agentType"?: AgentType
-    "publisher"?: string
-    "position": Position
-    "time": string
+    agentId: string
+    agentType?: AgentType
+    publisher?: string
+    position: Position
+    time: string
 }
 
 
-- 
GitLab