Search in sources :

Example 1 with SpatialIndex

use of org.apache.jena.query.spatial.SpatialIndex in project jena by apache.

the class SpatialDatasetAssembler method open.

//    private DatasetAssembler datasetAssembler = new DatasetAssembler() ;
//    
//    public static Resource getType() { return textDataset ; }
/*
<#spatial_dataset> rdf:type     spatial:SpatialDataset ;
    spatial:dataset <#dataset> ;
    spatial:index   <#index> ;
    .

    */
@Override
public Dataset open(Assembler a, Resource root, Mode mode) {
    Resource dataset = GraphUtils.getResourceValue(root, pDataset);
    Resource index = GraphUtils.getResourceValue(root, pIndex);
    Dataset ds = (Dataset) a.open(dataset);
    SpatialIndex textIndex = (SpatialIndex) a.open(index);
    Dataset dst = SpatialDatasetFactory.create(ds, textIndex);
    return dst;
}
Also used : SpatialVocab.pDataset(org.apache.jena.query.spatial.assembler.SpatialVocab.pDataset) Dataset(org.apache.jena.query.Dataset) SpatialIndex(org.apache.jena.query.spatial.SpatialIndex) Resource(org.apache.jena.rdf.model.Resource)

Example 2 with SpatialIndex

use of org.apache.jena.query.spatial.SpatialIndex in project jena by apache.

the class SpatialOperationPFBase method chooseTextIndex.

protected SpatialIndex chooseTextIndex(ExecutionContext execCxt, DatasetGraph dsg) {
    Object obj = dsg.getContext().get(SpatialQuery.spatialIndex);
    if (obj != null) {
        try {
            return (SpatialIndex) obj;
        } catch (ClassCastException ex) {
            Log.warn(SpatialOperationWithCircleBase.class, "Context setting '" + SpatialQuery.spatialIndex + "'is not a SpatialIndex");
        }
    }
    if (dsg instanceof DatasetGraphSpatial) {
        DatasetGraphSpatial x = (DatasetGraphSpatial) dsg;
        return x.getSpatialIndex();
    }
    Log.warn(SpatialOperationWithCircleBase.class, "Failed to find the spatial index : tried context and as a spatial-enabled dataset");
    return null;
}
Also used : SpatialIndex(org.apache.jena.query.spatial.SpatialIndex) DatasetGraphSpatial(org.apache.jena.query.spatial.DatasetGraphSpatial)

Aggregations

SpatialIndex (org.apache.jena.query.spatial.SpatialIndex)2 Dataset (org.apache.jena.query.Dataset)1 DatasetGraphSpatial (org.apache.jena.query.spatial.DatasetGraphSpatial)1 SpatialVocab.pDataset (org.apache.jena.query.spatial.assembler.SpatialVocab.pDataset)1 Resource (org.apache.jena.rdf.model.Resource)1