Search in sources :

Example 1 with CoordinateDD

use of com.bigdata.rdf.internal.gis.CoordinateDD in project wikidata-query-rdf by wikimedia.

the class WikibaseDistanceBOp method get.

@Override
public IV get(IBindingSet bindingSet) {
    final IV left = getAndCheckLiteral(0, bindingSet);
    final IV right = getAndCheckLiteral(1, bindingSet);
    final CoordinateDD leftPoint = getCoordinateFromIV(left);
    final CoordinateDD rightPoint = getCoordinateFromIV(right);
    // TODO: allow to supply Units
    final double distance;
    if (leftPoint.equals(rightPoint) || veryClose(leftPoint, rightPoint)) {
        distance = 0;
    } else {
        distance = leftPoint.distance(rightPoint, UNITS.Kilometers);
    }
    final BigdataLiteral dist = getValueFactory().createLiteral(distance);
    return super.asIV(dist, bindingSet);
}
Also used : CoordinateDD(com.bigdata.rdf.internal.gis.CoordinateDD) IV(com.bigdata.rdf.internal.IV) BigdataLiteral(com.bigdata.rdf.model.BigdataLiteral)

Aggregations

IV (com.bigdata.rdf.internal.IV)1 CoordinateDD (com.bigdata.rdf.internal.gis.CoordinateDD)1 BigdataLiteral (com.bigdata.rdf.model.BigdataLiteral)1