Search in sources :

Example 1 with BigdataValue

use of com.bigdata.rdf.model.BigdataValue in project wikidata-query-rdf by wikimedia.

the class BigdataValuesHelper method makeIV.

/**
 * Make IV from a value.
 * @param type Value type.
 */
public static IV makeIV(BigdataValueFactory vf, Value value, VTE type) {
    final BigdataValue l = vf.asValue(value);
    TermId mock = TermId.mockIV(type);
    mock.setValue(l);
    l.setIV(mock);
    return mock;
}
Also used : BigdataValue(com.bigdata.rdf.model.BigdataValue) TermId(com.bigdata.rdf.internal.impl.TermId)

Example 2 with BigdataValue

use of com.bigdata.rdf.model.BigdataValue in project wikidata-query-rdf by wikimedia.

the class GeoService method getGlobeNode.

/**
 * Create globe node with appropriate value for coordSystem.
 */
protected TermNode getGlobeNode(BigdataValueFactory vf, ServiceParams serviceParams) {
    final TermNode globeNode = serviceParams.get(GLOBE_PARAM, null);
    if (globeNode == null) {
        return new DummyConstantNode(vf.createLiteral(WKTSerializer.NO_GLOBE));
    }
    if (!globeNode.isConstant()) {
        // FIXME: add support for this
        throw new IllegalArgumentException("Non-constant globe value is not supported yet.");
    }
    BigdataValue v = globeNode.getValue();
    if (v instanceof BigdataURI) {
        WKTSerializer ser = new WKTSerializer();
        try {
            return new DummyConstantNode(vf.createLiteral(ser.trimCoordURI(v.stringValue())));
        } catch (GeoSpatialSearchException e) {
            // Unexpectedly wrong URI - still pass it along
            return globeNode;
        }
    }
    return globeNode;
}
Also used : BigdataValue(com.bigdata.rdf.model.BigdataValue) DummyConstantNode(com.bigdata.rdf.sparql.ast.DummyConstantNode) WKTSerializer(org.wikidata.query.rdf.blazegraph.inline.literal.WKTSerializer) GeoSpatialSearchException(com.bigdata.service.geospatial.GeoSpatialSearchException) TermNode(com.bigdata.rdf.sparql.ast.TermNode) BigdataURI(com.bigdata.rdf.model.BigdataURI)

Example 3 with BigdataValue

use of com.bigdata.rdf.model.BigdataValue in project wikidata-query-rdf by wikimedia.

the class CoordinatePartBOp method get.

@Override
public IV get(IBindingSet bindingSet) {
    final IV coord = getAndCheckLiteral(0, bindingSet);
    final WikibasePoint point = pointFromIV(coord);
    final BigdataValue result;
    switch(part()) {
        case GLOBE:
            String globe = point.getGlobe();
            if (globe == null) {
                result = getValueFactory().createLiteral("");
            } else {
                result = getValueFactory().createURI(point.getGlobe());
            }
            break;
        case LON:
            result = getValueFactory().createLiteral(Double.parseDouble(point.getLongitude()));
            break;
        case LAT:
            result = getValueFactory().createLiteral(Double.parseDouble(point.getLatitude()));
            break;
        default:
            throw new IllegalArgumentException("Unknown part specified");
    }
    return super.asIV(result, bindingSet);
}
Also used : BigdataValue(com.bigdata.rdf.model.BigdataValue) IV(com.bigdata.rdf.internal.IV) GeoUtils.pointFromIV(org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointFromIV) WikibasePoint(org.wikidata.query.rdf.common.WikibasePoint)

Aggregations

BigdataValue (com.bigdata.rdf.model.BigdataValue)3 IV (com.bigdata.rdf.internal.IV)1 TermId (com.bigdata.rdf.internal.impl.TermId)1 BigdataURI (com.bigdata.rdf.model.BigdataURI)1 DummyConstantNode (com.bigdata.rdf.sparql.ast.DummyConstantNode)1 TermNode (com.bigdata.rdf.sparql.ast.TermNode)1 GeoSpatialSearchException (com.bigdata.service.geospatial.GeoSpatialSearchException)1 GeoUtils.pointFromIV (org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointFromIV)1 WKTSerializer (org.wikidata.query.rdf.blazegraph.inline.literal.WKTSerializer)1 WikibasePoint (org.wikidata.query.rdf.common.WikibasePoint)1