Search in sources :

Example 6 with WikibasePoint

use of org.wikidata.query.rdf.common.WikibasePoint 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

WikibasePoint (org.wikidata.query.rdf.common.WikibasePoint)6 IV (com.bigdata.rdf.internal.IV)2 URIImpl (org.openrdf.model.impl.URIImpl)2 GeoUtils (org.wikidata.query.rdf.blazegraph.geo.GeoUtils)2 GeoUtils.pointFromIV (org.wikidata.query.rdf.blazegraph.geo.GeoUtils.pointFromIV)2 BigdataLiteral (com.bigdata.rdf.model.BigdataLiteral)1 BigdataValue (com.bigdata.rdf.model.BigdataValue)1 BigdataValueFactory (com.bigdata.rdf.model.BigdataValueFactory)1 ConstantNode (com.bigdata.rdf.sparql.ast.ConstantNode)1 DummyConstantNode (com.bigdata.rdf.sparql.ast.DummyConstantNode)1 JoinGroupNode (com.bigdata.rdf.sparql.ast.JoinGroupNode)1 StatementPatternNode (com.bigdata.rdf.sparql.ast.StatementPatternNode)1 TermNode (com.bigdata.rdf.sparql.ast.TermNode)1 AbstractTripleStore (com.bigdata.rdf.store.AbstractTripleStore)1 Vocabulary (com.bigdata.rdf.vocab.Vocabulary)1 GeoSpatialSearchException (com.bigdata.service.geospatial.GeoSpatialSearchException)1