Search in sources :

Example 1 with GeoLocation

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);
}
Also used : GeoLocation(org.onlab.util.GeoLocation)

Example 2 with GeoLocation

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);
}
Also used : Annotations(org.onosproject.net.Annotations) Device(org.onosproject.net.Device) GeoLocation(org.onlab.util.GeoLocation)

Aggregations

GeoLocation (org.onlab.util.GeoLocation)2 Annotations (org.onosproject.net.Annotations)1 Device (org.onosproject.net.Device)1