Search in sources :

Example 1 with GeoSpatialSearchException

use of com.bigdata.service.geospatial.GeoSpatialSearchException in project wikidata-query-rdf by wikimedia.

the class WKTSerializer method fromComponents.

@Override
public String fromComponents(Object[] components) {
    if (components == null)
        return "";
    if (components.length != 3)
        throw new GeoSpatialSearchException("Expected component string of lenth 3, but was " + components.length);
    String[] strComponents = new String[3];
    strComponents[0] = components[0].toString();
    strComponents[1] = components[1].toString();
    strComponents[2] = components[2].toString();
    WikibasePoint point;
    if (strComponents[2].equals(NO_GLOBE)) {
        point = new WikibasePoint(strComponents, null, CoordinateOrder.LONG_LAT);
    } else {
        point = new WikibasePoint(strComponents, URL_PREFIX + strComponents[2], CoordinateOrder.LONG_LAT);
    }
    return point.toString();
}
Also used : GeoSpatialSearchException(com.bigdata.service.geospatial.GeoSpatialSearchException) WikibasePoint(org.wikidata.query.rdf.common.WikibasePoint)

Example 2 with GeoSpatialSearchException

use of com.bigdata.service.geospatial.GeoSpatialSearchException 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)

Aggregations

GeoSpatialSearchException (com.bigdata.service.geospatial.GeoSpatialSearchException)2 BigdataURI (com.bigdata.rdf.model.BigdataURI)1 BigdataValue (com.bigdata.rdf.model.BigdataValue)1 DummyConstantNode (com.bigdata.rdf.sparql.ast.DummyConstantNode)1 TermNode (com.bigdata.rdf.sparql.ast.TermNode)1 WKTSerializer (org.wikidata.query.rdf.blazegraph.inline.literal.WKTSerializer)1 WikibasePoint (org.wikidata.query.rdf.common.WikibasePoint)1