use of org.onlab.util.GeoLocation in project onos by opennetworkinglab.
the class GeoDistanceLinkWeight method weight.
@Override
public Weight weight(TopologyEdge edge) {
GeoLocation src = getLocation(edge.link().src().deviceId());
GeoLocation dst = getLocation(edge.link().dst().deviceId());
return ScalarWeight.toWeight(src != null && dst != null ? src.kilometersTo(dst) : MAX_KM);
}
use of org.onlab.util.GeoLocation in project onos by opennetworkinglab.
the class GeoDistanceLinkWeight method getLocation.
private GeoLocation getLocation(DeviceId deviceId) {
Device d = deviceService.getDevice(deviceId);
Annotations a = d != null ? d.annotations() : null;
double latitude = getDouble(a, AnnotationKeys.LATITUDE);
double longitude = getDouble(a, AnnotationKeys.LONGITUDE);
return latitude == MAX_VALUE || longitude == MAX_VALUE ? null : new GeoLocation(latitude, longitude);
}
Aggregations