Search in sources :

Example 1 with BigdataLiteral

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);
}
Also used : GeoUtils(org.wikidata.query.rdf.blazegraph.geo.GeoUtils) URIImpl(org.openrdf.model.impl.URIImpl) IV(com.bigdata.rdf.internal.IV) GeoUtils.pointFromIV(org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointFromIV) BigdataLiteral(com.bigdata.rdf.model.BigdataLiteral) WikibasePoint(org.wikidata.query.rdf.common.WikibasePoint)

Example 2 with BigdataLiteral

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);
}
Also used : CoordinateDD(com.bigdata.rdf.internal.gis.CoordinateDD) IV(com.bigdata.rdf.internal.IV) BigdataLiteral(com.bigdata.rdf.model.BigdataLiteral)

Example 3 with BigdataLiteral

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);
    }
}
Also used : BigdataResource(com.bigdata.rdf.model.BigdataResource) URI(org.openrdf.model.URI) RDFDatatype(org.apache.jena.datatypes.RDFDatatype) BigdataLiteral(com.bigdata.rdf.model.BigdataLiteral)

Aggregations

BigdataLiteral (com.bigdata.rdf.model.BigdataLiteral)3 IV (com.bigdata.rdf.internal.IV)2 CoordinateDD (com.bigdata.rdf.internal.gis.CoordinateDD)1 BigdataResource (com.bigdata.rdf.model.BigdataResource)1 RDFDatatype (org.apache.jena.datatypes.RDFDatatype)1 URI (org.openrdf.model.URI)1 URIImpl (org.openrdf.model.impl.URIImpl)1 GeoUtils (org.wikidata.query.rdf.blazegraph.geo.GeoUtils)1 GeoUtils.pointFromIV (org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointFromIV)1 WikibasePoint (org.wikidata.query.rdf.common.WikibasePoint)1