use of com.bigdata.rdf.model.BigdataLiteral in project wikidata-query-rdf by wikimedia.
the class WikibaseCornerBOp method get.
@Override
public IV get(IBindingSet bindingSet) {
final IV east = getAndCheckLiteral(0, bindingSet);
final IV west = getAndCheckLiteral(1, bindingSet);
final GeoUtils.Box box = new GeoUtils.Box(pointFromIV(east), pointFromIV(west));
WikibasePoint wp;
if (corner() == Corners.NE) {
if (!box.switched()) {
return east;
}
wp = box.northEast();
} else {
if (!box.switched()) {
return west;
}
wp = box.southWest();
}
final BigdataLiteral newpoint = getValueFactory().createLiteral(wp.toString(), new URIImpl(GeoSparql.WKT_LITERAL));
return super.asIV(newpoint, bindingSet);
}
use of com.bigdata.rdf.model.BigdataLiteral 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);
}
use of com.bigdata.rdf.model.BigdataLiteral in project wikidata-query-rdf by wikimedia.
the class BigdataStatementToJenaStatementMapper method convertToJenaRDFNode.
/**
* Convert Bigdata value to Jena RDF Node.
*
* @return Jena RDF node.
*/
public RDFNode convertToJenaRDFNode(final BigdataValue v) {
if (v instanceof BigdataResource)
return convertToJenaResource((BigdataResource) v);
if (!(v instanceof BigdataLiteral))
throw new IllegalArgumentException(v.getClass().getName());
final BigdataLiteral l = (BigdataLiteral) v;
final String lex = l.getLabel();
final URI datatypeURI = l.getDatatype();
final String languageTag = l.getLanguage();
if (datatypeURI != null) {
final RDFDatatype dt = JENA_TYPE_MAPPER.getSafeTypeByName(datatypeURI.stringValue());
return ResourceFactory.createTypedLiteral(lex, dt);
} else if (languageTag != null) {
return ResourceFactory.createLangLiteral(lex, languageTag);
} else {
return ResourceFactory.createPlainLiteral(lex);
}
}
Aggregations