Partial fix for ONOS-6767.

- pruning removed annotation tombstones
- processing netcfg only on master node
- swapping priority of processing of geo/grid coordinates

Change-Id: Icade1032f94ea774136d863d388402c79094c5a7
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/BasicElementOperator.java b/core/net/src/main/java/org/onosproject/net/device/impl/BasicElementOperator.java
index 29333e6..a666266 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/BasicElementOperator.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/BasicElementOperator.java
@@ -50,16 +50,22 @@
         }
 
         if (Objects.equals(cfg.locType(), BasicElementConfig.LOC_TYPE_NONE)) {
+            // Wipe-out both grid and geo coordinates.
             builder.remove(AnnotationKeys.GRID_X).remove(AnnotationKeys.GRID_Y);
             builder.remove(AnnotationKeys.LATITUDE).remove(AnnotationKeys.LONGITUDE);
-        } else if (cfg.geoCoordsSet()) {
-            builder.set(AnnotationKeys.LATITUDE, Double.toString(cfg.latitude()));
-            builder.set(AnnotationKeys.LONGITUDE, Double.toString(cfg.longitude()));
-            builder.remove(AnnotationKeys.GRID_X).remove(AnnotationKeys.GRID_Y);
+
         } else if (cfg.gridCoordsSet()) {
+            // Give priority to coordinate-based scheme as it requires explicit
+            // location type. Set grid coordinates and wipe-out geo coordinates.
             builder.set(AnnotationKeys.GRID_Y, Double.toString(cfg.gridY()));
             builder.set(AnnotationKeys.GRID_X, Double.toString(cfg.gridX()));
             builder.remove(AnnotationKeys.LATITUDE).remove(AnnotationKeys.LONGITUDE);
+
+        } else if (cfg.geoCoordsSet()) {
+            // Set geo coordinates and wipe-out grid coordinates.
+            builder.set(AnnotationKeys.LATITUDE, Double.toString(cfg.latitude()));
+            builder.set(AnnotationKeys.LONGITUDE, Double.toString(cfg.longitude()));
+            builder.remove(AnnotationKeys.GRID_X).remove(AnnotationKeys.GRID_Y);
         }
 
         if (cfg.rackAddress() != null) {