You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/05/14 14:03:04 UTC
[05/42] jena git commit: Merge commit 'refs/pull/143/head' of
github.com:apache/jena
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/DirectionWithPointPFBase.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/DirectionWithPointPFBase.java
index 2f49963,2f49963..29bb81f
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/DirectionWithPointPFBase.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/DirectionWithPointPFBase.java
@@@ -1,146 -1,146 +1,146 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction;
--
--import java.util.List;
--
--import org.apache.jena.datatypes.xsd.XSDDatatype ;
--import org.apache.jena.graph.Node ;
--import org.apache.jena.graph.impl.LiteralLabel ;
--import org.apache.jena.query.QueryBuildException ;
--import org.apache.jena.query.spatial.SpatialIndexException;
--import org.apache.jena.query.spatial.SpatialValueUtil;
--import org.apache.jena.sparql.engine.ExecutionContext ;
--import org.apache.jena.sparql.pfunction.PropFuncArg ;
--import org.apache.jena.sparql.util.NodeFactoryExtra ;
--import org.apache.lucene.spatial.query.SpatialOperation;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--
--public abstract class DirectionWithPointPFBase extends SpatialOperationPFBase {
--
-- private static Logger log = LoggerFactory.getLogger(DirectionWithPointPFBase.class);
--
-- public DirectionWithPointPFBase() {
--
-- }
--
-- @Override
-- public void build(PropFuncArg argSubject, Node predicate,
-- PropFuncArg argObject, ExecutionContext execCxt) {
-- super.build(argSubject, predicate, argObject, execCxt);
--
-- if (!argSubject.isNode())
-- throw new QueryBuildException("Subject is not a single node: "
-- + argSubject);
--
-- if (argObject.isList()) {
-- List<Node> list = argObject.getArgList();
-- if (list.size() < 2)
-- throw new QueryBuildException("Not enough arguments in list");
--
-- if (list.size() > 3)
-- throw new QueryBuildException("Too many arguments in list : "
-- + list);
-- }
-- }
--
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- @Override
-- protected SpatialMatch objectToStruct(PropFuncArg argObject) {
-- if (argObject.isNode()) {
-- log.warn("Object not a List: " + argObject);
-- return null;
-- }
--
-- List<Node> list = argObject.getArgList();
--
-- if (list.size() < 2 || list.size() > 3)
-- throw new SpatialIndexException("Change in object list size");
--
-- int idx = 0;
--
-- Node x = list.get(idx);
-- if (!x.isLiteral()) {
-- log.warn("Latitude is not a literal " + list);
-- return null;
-- }
-- if (!SpatialValueUtil.isDecimal(x)) {
-- log.warn("Latitude is not a decimal " + list);
-- return null;
-- }
-- Double latitude = Double.parseDouble(x.getLiteralLexicalForm());
--
-- idx++;
--
-- x = list.get(idx);
-- if (!x.isLiteral()) {
-- log.warn("Longitude is not a literal " + list);
-- return null;
-- }
-- if (!SpatialValueUtil.isDecimal(x)) {
-- log.warn("Longitude is not a decimal " + list);
-- return null;
-- }
-- Double longitude = Double.parseDouble(x.getLiteralLexicalForm());
--
-- idx++;
--
-- int limit =-1;
--
-- if (idx < list.size()) {
-- x = list.get(idx);
--
-- if (!x.isLiteral()) {
-- log.warn("Limit is not a literal " + list);
-- return null;
-- }
--
-- LiteralLabel lit = x.getLiteral();
--
-- if (!XSDDatatype.XSDinteger.isValidLiteral(lit)) {
-- log.warn("Limit is not an integer " + list);
-- return null;
-- }
--
-- int v = NodeFactoryExtra.nodeToInt(x);
-- limit = (v < 0) ? -1 : v;
--
-- idx++;
-- if (idx < list.size()) {
-- log.warn("Limit is not the last parameter " + list);
-- return null;
-- }
-- }
--
-- SpatialMatch match = this.getSpatialMatch(latitude, longitude, limit);
-- if (log.isDebugEnabled())
-- log.debug("Trying SpatialMatch: " + match.toString());
-- return match;
-- }
--
-- protected abstract SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit);
--
-- @Override
-- protected SpatialOperation getSpatialOperation() {
-- return SpatialOperation.IsWithin;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction;
++
++import java.util.List;
++
++import org.apache.jena.datatypes.xsd.XSDDatatype ;
++import org.apache.jena.graph.Node ;
++import org.apache.jena.graph.impl.LiteralLabel ;
++import org.apache.jena.query.QueryBuildException ;
++import org.apache.jena.query.spatial.SpatialIndexException;
++import org.apache.jena.query.spatial.SpatialValueUtil;
++import org.apache.jena.sparql.engine.ExecutionContext ;
++import org.apache.jena.sparql.pfunction.PropFuncArg ;
++import org.apache.jena.sparql.util.NodeFactoryExtra ;
++import org.apache.lucene.spatial.query.SpatialOperation;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public abstract class DirectionWithPointPFBase extends SpatialOperationPFBase {
++
++ private static Logger log = LoggerFactory.getLogger(DirectionWithPointPFBase.class);
++
++ public DirectionWithPointPFBase() {
++
++ }
++
++ @Override
++ public void build(PropFuncArg argSubject, Node predicate,
++ PropFuncArg argObject, ExecutionContext execCxt) {
++ super.build(argSubject, predicate, argObject, execCxt);
++
++ if (!argSubject.isNode())
++ throw new QueryBuildException("Subject is not a single node: "
++ + argSubject);
++
++ if (argObject.isList()) {
++ List<Node> list = argObject.getArgList();
++ if (list.size() < 2)
++ throw new QueryBuildException("Not enough arguments in list");
++
++ if (list.size() > 3)
++ throw new QueryBuildException("Too many arguments in list : "
++ + list);
++ }
++ }
++
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ @Override
++ protected SpatialMatch objectToStruct(PropFuncArg argObject) {
++ if (argObject.isNode()) {
++ log.warn("Object not a List: " + argObject);
++ return null;
++ }
++
++ List<Node> list = argObject.getArgList();
++
++ if (list.size() < 2 || list.size() > 3)
++ throw new SpatialIndexException("Change in object list size");
++
++ int idx = 0;
++
++ Node x = list.get(idx);
++ if (!x.isLiteral()) {
++ log.warn("Latitude is not a literal " + list);
++ return null;
++ }
++ if (!SpatialValueUtil.isDecimal(x)) {
++ log.warn("Latitude is not a decimal " + list);
++ return null;
++ }
++ Double latitude = Double.parseDouble(x.getLiteralLexicalForm());
++
++ idx++;
++
++ x = list.get(idx);
++ if (!x.isLiteral()) {
++ log.warn("Longitude is not a literal " + list);
++ return null;
++ }
++ if (!SpatialValueUtil.isDecimal(x)) {
++ log.warn("Longitude is not a decimal " + list);
++ return null;
++ }
++ Double longitude = Double.parseDouble(x.getLiteralLexicalForm());
++
++ idx++;
++
++ int limit =-1;
++
++ if (idx < list.size()) {
++ x = list.get(idx);
++
++ if (!x.isLiteral()) {
++ log.warn("Limit is not a literal " + list);
++ return null;
++ }
++
++ LiteralLabel lit = x.getLiteral();
++
++ if (!XSDDatatype.XSDinteger.isValidLiteral(lit)) {
++ log.warn("Limit is not an integer " + list);
++ return null;
++ }
++
++ int v = NodeFactoryExtra.nodeToInt(x);
++ limit = (v < 0) ? -1 : v;
++
++ idx++;
++ if (idx < list.size()) {
++ log.warn("Limit is not the last parameter " + list);
++ return null;
++ }
++ }
++
++ SpatialMatch match = this.getSpatialMatch(latitude, longitude, limit);
++ if (log.isDebugEnabled())
++ log.debug("Trying SpatialMatch: " + match.toString());
++ return match;
++ }
++
++ protected abstract SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit);
++
++ @Override
++ protected SpatialOperation getSpatialOperation() {
++ return SpatialOperation.IsWithin;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java
index 10832ed,10832ed..0d8275c
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialMatch.java
@@@ -1,67 -1,67 +1,67 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction;
--
--import org.apache.jena.query.spatial.DistanceUnitsUtils;
--import org.apache.jena.query.spatial.SpatialQuery;
--import org.apache.lucene.spatial.query.SpatialOperation;
--
--import com.spatial4j.core.shape.Shape;
--
--public class SpatialMatch {
--
-- private final Shape shape;
-- private final int limit;
-- private final SpatialOperation operation;
--
-- public SpatialMatch(Double latitude, Double longitude, Double radius,
-- String units, int limit, SpatialOperation operation) {
--
-- double degrees = DistanceUnitsUtils.dist2Degrees(radius, units);
-- this.shape = SpatialQuery.ctx.makeCircle(longitude, latitude, degrees);
-- //System.out.println( SpatialQuery.ctx.toString(shape) );
-- this.limit = limit;
-- this.operation = operation;
-- }
--
-- public SpatialMatch(Double latitude1, Double longitude1, Double latitude2,
-- Double longitude2, int limit, SpatialOperation operation) {
-- this.shape = SpatialQuery.ctx.makeRectangle(longitude1, longitude2, latitude1, latitude2);
-- this.limit = limit;
-- this.operation = operation;
-- }
--
-- public Shape getShape() {
-- return shape;
-- }
--
-- public int getLimit() {
-- return limit;
-- }
--
-- public SpatialOperation getSpatialOperation() {
-- return operation;
-- }
--
-- @Override
-- public String toString() {
-- return "(" + shape + " " + limit + " " + operation + ")";
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction;
++
++import org.apache.jena.query.spatial.DistanceUnitsUtils;
++import org.apache.jena.query.spatial.SpatialQuery;
++import org.apache.lucene.spatial.query.SpatialOperation;
++
++import com.spatial4j.core.shape.Shape;
++
++public class SpatialMatch {
++
++ private final Shape shape;
++ private final int limit;
++ private final SpatialOperation operation;
++
++ public SpatialMatch(Double latitude, Double longitude, Double radius,
++ String units, int limit, SpatialOperation operation) {
++
++ double degrees = DistanceUnitsUtils.dist2Degrees(radius, units);
++ this.shape = SpatialQuery.ctx.makeCircle(longitude, latitude, degrees);
++ //System.out.println( SpatialQuery.ctx.toString(shape) );
++ this.limit = limit;
++ this.operation = operation;
++ }
++
++ public SpatialMatch(Double latitude1, Double longitude1, Double latitude2,
++ Double longitude2, int limit, SpatialOperation operation) {
++ this.shape = SpatialQuery.ctx.makeRectangle(longitude1, longitude2, latitude1, latitude2);
++ this.limit = limit;
++ this.operation = operation;
++ }
++
++ public Shape getShape() {
++ return shape;
++ }
++
++ public int getLimit() {
++ return limit;
++ }
++
++ public SpatialOperation getSpatialOperation() {
++ return operation;
++ }
++
++ @Override
++ public String toString() {
++ return "(" + shape + " " + limit + " " + operation + ")";
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationPFBase.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationPFBase.java
index 2f8b638,2f8b638..82d7b4f
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationPFBase.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationPFBase.java
@@@ -1,163 -1,163 +1,163 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction;
--
--import java.util.List ;
--
--import org.apache.jena.atlas.iterator.Iter ;
--import org.apache.jena.atlas.lib.InternalErrorException ;
--import org.apache.jena.atlas.logging.Log ;
--import org.apache.jena.graph.Node ;
--import org.apache.jena.query.spatial.DatasetGraphSpatial ;
--import org.apache.jena.query.spatial.SpatialIndex ;
--import org.apache.jena.query.spatial.SpatialQuery ;
--import org.apache.jena.sparql.core.DatasetGraph ;
--import org.apache.jena.sparql.core.Substitute ;
--import org.apache.jena.sparql.core.Var ;
--import org.apache.jena.sparql.engine.ExecutionContext ;
--import org.apache.jena.sparql.engine.QueryIterator ;
--import org.apache.jena.sparql.engine.binding.Binding ;
--import org.apache.jena.sparql.engine.iterator.QueryIterExtendByVar ;
--import org.apache.jena.sparql.engine.iterator.QueryIterSlice ;
--import org.apache.jena.sparql.pfunction.PropFuncArg ;
--import org.apache.jena.sparql.pfunction.PropertyFunctionBase ;
--import org.apache.jena.sparql.util.IterLib ;
--import org.apache.lucene.spatial.query.SpatialOperation ;
--import org.slf4j.Logger ;
--import org.slf4j.LoggerFactory ;
--
--public abstract class SpatialOperationPFBase extends PropertyFunctionBase {
--
-- private static Logger log = LoggerFactory.getLogger(SpatialOperationPFBase.class);
--
-- protected SpatialIndex server = null;
-- private boolean warningIssued = false;
--
-- public SpatialOperationPFBase() {
-- }
--
-- @Override
-- public void build(PropFuncArg argSubject, Node predicate,
-- PropFuncArg argObject, ExecutionContext execCxt) {
-- super.build(argSubject, predicate, argObject, execCxt);
-- DatasetGraph dsg = execCxt.getDataset();
-- server = chooseTextIndex(dsg);
-- }
--
-- protected SpatialIndex chooseTextIndex(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;
-- }
--
-- @Override
-- public QueryIterator exec(Binding binding, PropFuncArg argSubject,
-- Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
-- if (server == null) {
-- if (!warningIssued) {
-- Log.warn(getClass(), "No spatial index - no spatial search performed");
-- warningIssued = true;
-- }
-- // Not a text dataset - no-op
-- return IterLib.result(binding, execCxt);
-- }
--
-- DatasetGraph dsg = execCxt.getDataset();
--
-- argSubject = Substitute.substitute(argSubject, binding) ;
-- argObject = Substitute.substitute(argObject, binding) ;
--
-- if (!argSubject.isNode())
-- throw new InternalErrorException("Subject is not a node (it was earlier!)");
--
-- Node s = argSubject.getArg();
--
-- if (s.isLiteral())
-- // Does not match
-- return IterLib.noResults(execCxt);
--
-- SpatialMatch match = objectToStruct(argObject);
--
-- if (match == null) {
-- // can't match
-- return IterLib.noResults(execCxt);
-- }
--
-- // ----
--
-- QueryIterator qIter = (Var.isVar(s)) ? variableSubject(binding, s,
-- match, execCxt) : concreteSubject(binding, s, match, execCxt);
-- if (match.getLimit() >= 0)
-- qIter = new QueryIterSlice(qIter, 0, match.getLimit(), execCxt);
-- return qIter;
-- }
--
-- private QueryIterator variableSubject(Binding binding, Node s,
-- SpatialMatch match, ExecutionContext execCxt) {
--
-- Var v = Var.alloc(s);
-- List<Node> r = query(match);
-- // Make distinct. Note interaction with limit is imperfect
-- r = Iter.iter(r).distinct().toList();
-- QueryIterator qIter = new QueryIterExtendByVar(binding, v,
-- r.iterator(), execCxt);
-- return qIter;
-- }
--
-- private QueryIterator concreteSubject(Binding binding, Node s,
-- SpatialMatch match, ExecutionContext execCxt) {
-- if (!s.isURI()) {
-- log.warn("Subject not a URI: " + s);
-- return IterLib.noResults(execCxt);
-- }
--
-- List<Node> x = query(match);
-- if (x == null || !x.contains(s))
-- return IterLib.noResults(execCxt);
-- else
-- return IterLib.result(binding, execCxt);
-- }
--
-- private List<Node> query(SpatialMatch match) {
--
-- return server.query(match.getShape(), match.getLimit(),
-- match.getSpatialOperation());
-- }
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- protected abstract SpatialMatch objectToStruct(PropFuncArg argObject);
--
-- protected abstract SpatialOperation getSpatialOperation();
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction;
++
++import java.util.List ;
++
++import org.apache.jena.atlas.iterator.Iter ;
++import org.apache.jena.atlas.lib.InternalErrorException ;
++import org.apache.jena.atlas.logging.Log ;
++import org.apache.jena.graph.Node ;
++import org.apache.jena.query.spatial.DatasetGraphSpatial ;
++import org.apache.jena.query.spatial.SpatialIndex ;
++import org.apache.jena.query.spatial.SpatialQuery ;
++import org.apache.jena.sparql.core.DatasetGraph ;
++import org.apache.jena.sparql.core.Substitute ;
++import org.apache.jena.sparql.core.Var ;
++import org.apache.jena.sparql.engine.ExecutionContext ;
++import org.apache.jena.sparql.engine.QueryIterator ;
++import org.apache.jena.sparql.engine.binding.Binding ;
++import org.apache.jena.sparql.engine.iterator.QueryIterExtendByVar ;
++import org.apache.jena.sparql.engine.iterator.QueryIterSlice ;
++import org.apache.jena.sparql.pfunction.PropFuncArg ;
++import org.apache.jena.sparql.pfunction.PropertyFunctionBase ;
++import org.apache.jena.sparql.util.IterLib ;
++import org.apache.lucene.spatial.query.SpatialOperation ;
++import org.slf4j.Logger ;
++import org.slf4j.LoggerFactory ;
++
++public abstract class SpatialOperationPFBase extends PropertyFunctionBase {
++
++ private static Logger log = LoggerFactory.getLogger(SpatialOperationPFBase.class);
++
++ protected SpatialIndex server = null;
++ private boolean warningIssued = false;
++
++ public SpatialOperationPFBase() {
++ }
++
++ @Override
++ public void build(PropFuncArg argSubject, Node predicate,
++ PropFuncArg argObject, ExecutionContext execCxt) {
++ super.build(argSubject, predicate, argObject, execCxt);
++ DatasetGraph dsg = execCxt.getDataset();
++ server = chooseTextIndex(dsg);
++ }
++
++ protected SpatialIndex chooseTextIndex(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;
++ }
++
++ @Override
++ public QueryIterator exec(Binding binding, PropFuncArg argSubject,
++ Node predicate, PropFuncArg argObject, ExecutionContext execCxt) {
++ if (server == null) {
++ if (!warningIssued) {
++ Log.warn(getClass(), "No spatial index - no spatial search performed");
++ warningIssued = true;
++ }
++ // Not a text dataset - no-op
++ return IterLib.result(binding, execCxt);
++ }
++
++ DatasetGraph dsg = execCxt.getDataset();
++
++ argSubject = Substitute.substitute(argSubject, binding) ;
++ argObject = Substitute.substitute(argObject, binding) ;
++
++ if (!argSubject.isNode())
++ throw new InternalErrorException("Subject is not a node (it was earlier!)");
++
++ Node s = argSubject.getArg();
++
++ if (s.isLiteral())
++ // Does not match
++ return IterLib.noResults(execCxt);
++
++ SpatialMatch match = objectToStruct(argObject);
++
++ if (match == null) {
++ // can't match
++ return IterLib.noResults(execCxt);
++ }
++
++ // ----
++
++ QueryIterator qIter = (Var.isVar(s)) ? variableSubject(binding, s,
++ match, execCxt) : concreteSubject(binding, s, match, execCxt);
++ if (match.getLimit() >= 0)
++ qIter = new QueryIterSlice(qIter, 0, match.getLimit(), execCxt);
++ return qIter;
++ }
++
++ private QueryIterator variableSubject(Binding binding, Node s,
++ SpatialMatch match, ExecutionContext execCxt) {
++
++ Var v = Var.alloc(s);
++ List<Node> r = query(match);
++ // Make distinct. Note interaction with limit is imperfect
++ r = Iter.iter(r).distinct().toList();
++ QueryIterator qIter = new QueryIterExtendByVar(binding, v,
++ r.iterator(), execCxt);
++ return qIter;
++ }
++
++ private QueryIterator concreteSubject(Binding binding, Node s,
++ SpatialMatch match, ExecutionContext execCxt) {
++ if (!s.isURI()) {
++ log.warn("Subject not a URI: " + s);
++ return IterLib.noResults(execCxt);
++ }
++
++ List<Node> x = query(match);
++ if (x == null || !x.contains(s))
++ return IterLib.noResults(execCxt);
++ else
++ return IterLib.result(binding, execCxt);
++ }
++
++ private List<Node> query(SpatialMatch match) {
++
++ return server.query(match.getShape(), match.getLimit(),
++ match.getSpatialOperation());
++ }
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ protected abstract SpatialMatch objectToStruct(PropFuncArg argObject);
++
++ protected abstract SpatialOperation getSpatialOperation();
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithBoxPFBase.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithBoxPFBase.java
index ee44773,ee44773..e200134
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithBoxPFBase.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/SpatialOperationWithBoxPFBase.java
@@@ -1,164 -1,164 +1,164 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction;
--
--import java.util.List;
--
--import org.apache.jena.datatypes.xsd.XSDDatatype ;
--import org.apache.jena.graph.Node ;
--import org.apache.jena.graph.impl.LiteralLabel ;
--import org.apache.jena.query.QueryBuildException ;
--import org.apache.jena.query.spatial.SpatialIndexException;
--import org.apache.jena.query.spatial.SpatialValueUtil;
--import org.apache.jena.sparql.engine.ExecutionContext ;
--import org.apache.jena.sparql.pfunction.PropFuncArg ;
--import org.apache.jena.sparql.util.NodeFactoryExtra ;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--
--public abstract class SpatialOperationWithBoxPFBase extends SpatialOperationPFBase {
-- private static Logger log = LoggerFactory.getLogger(SpatialOperationWithCircleBase.class);
--
-- public SpatialOperationWithBoxPFBase() {
-- }
--
-- @Override
-- public void build(PropFuncArg argSubject, Node predicate,
-- PropFuncArg argObject, ExecutionContext execCxt) {
-- super.build(argSubject, predicate, argObject, execCxt);
--
-- if (!argSubject.isNode())
-- throw new QueryBuildException("Subject is not a single node: "
-- + argSubject);
--
-- if (argObject.isList()) {
-- List<Node> list = argObject.getArgList();
-- if (list.size() < 4)
-- throw new QueryBuildException("Not enough arguments in list");
--
-- if (list.size() > 5)
-- throw new QueryBuildException("Too many arguments in list : "
-- + list);
-- }
-- }
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- @Override
-- protected SpatialMatch objectToStruct(PropFuncArg argObject) {
--
-- if (argObject.isNode()) {
-- log.warn("Object not a List: " + argObject);
-- return null;
-- }
--
-- List<Node> list = argObject.getArgList();
--
-- if (list.size() < 4 || list.size() > 5)
-- throw new SpatialIndexException("Change in object list size");
--
-- int idx = 0;
--
-- Node x = list.get(idx);
-- if (!x.isLiteral()) {
-- log.warn("Latitude 1 is not a literal " + list);
-- return null;
-- }
-- if (!SpatialValueUtil.isDecimal(x)) {
-- log.warn("Latitude 1 is not a decimal " + list);
-- return null;
-- }
-- Double latitude1 = Double.parseDouble(x.getLiteralLexicalForm());
--
-- idx++;
--
-- x = list.get(idx);
-- if (!x.isLiteral()) {
-- log.warn("Longitude 1 is not a literal " + list);
-- return null;
-- }
-- if (!SpatialValueUtil.isDecimal(x)) {
-- log.warn("Longitude 1 is not a decimal " + list);
-- return null;
-- }
-- Double longtitude1 = Double.parseDouble(x.getLiteralLexicalForm());
--
-- idx++;
--
-- x = list.get(idx);
-- if (!x.isLiteral()) {
-- log.warn("Latitude 2 is not a literal " + list);
-- return null;
-- }
-- if (!SpatialValueUtil.isDecimal(x)) {
-- log.warn("Latitude 2 is not a decimal " + list);
-- return null;
-- }
-- Double latitude2 = Double.parseDouble(x.getLiteralLexicalForm());
--
-- idx++;
--
-- x = list.get(idx);
-- if (!x.isLiteral()) {
-- log.warn("Longitude 2 is not a literal " + list);
-- return null;
-- }
-- if (!SpatialValueUtil.isDecimal(x)) {
-- log.warn("Longitude 2 is not a decimal " + list);
-- return null;
-- }
-- Double longtitude2 = Double.parseDouble(x.getLiteralLexicalForm());
--
-- idx++;
-- int limit =-1;
--
-- if (idx < list.size()) {
-- x = list.get(idx);
--
-- if (!x.isLiteral()) {
-- log.warn("Limit is not a literal " + list);
-- return null;
-- }
--
-- LiteralLabel lit = x.getLiteral();
--
-- if (!XSDDatatype.XSDinteger.isValidLiteral(lit)) {
-- log.warn("Limit is not an integer " + list);
-- return null;
-- }
--
-- int v = NodeFactoryExtra.nodeToInt(x);
-- limit = (v < 0) ? -1 : v;
--
-- idx++;
-- if (idx < list.size()) {
-- log.warn("Limit is not the last parameter " + list);
-- return null;
-- }
-- }
--
-- SpatialMatch match = new SpatialMatch(latitude1, longtitude1,
-- latitude2, longtitude2, limit, getSpatialOperation());
--
-- if (log.isDebugEnabled())
-- log.debug("Trying SpatialMatch: " + match.toString());
-- return match;
-- }
--
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction;
++
++import java.util.List;
++
++import org.apache.jena.datatypes.xsd.XSDDatatype ;
++import org.apache.jena.graph.Node ;
++import org.apache.jena.graph.impl.LiteralLabel ;
++import org.apache.jena.query.QueryBuildException ;
++import org.apache.jena.query.spatial.SpatialIndexException;
++import org.apache.jena.query.spatial.SpatialValueUtil;
++import org.apache.jena.sparql.engine.ExecutionContext ;
++import org.apache.jena.sparql.pfunction.PropFuncArg ;
++import org.apache.jena.sparql.util.NodeFactoryExtra ;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public abstract class SpatialOperationWithBoxPFBase extends SpatialOperationPFBase {
++ private static Logger log = LoggerFactory.getLogger(SpatialOperationWithCircleBase.class);
++
++ public SpatialOperationWithBoxPFBase() {
++ }
++
++ @Override
++ public void build(PropFuncArg argSubject, Node predicate,
++ PropFuncArg argObject, ExecutionContext execCxt) {
++ super.build(argSubject, predicate, argObject, execCxt);
++
++ if (!argSubject.isNode())
++ throw new QueryBuildException("Subject is not a single node: "
++ + argSubject);
++
++ if (argObject.isList()) {
++ List<Node> list = argObject.getArgList();
++ if (list.size() < 4)
++ throw new QueryBuildException("Not enough arguments in list");
++
++ if (list.size() > 5)
++ throw new QueryBuildException("Too many arguments in list : "
++ + list);
++ }
++ }
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ @Override
++ protected SpatialMatch objectToStruct(PropFuncArg argObject) {
++
++ if (argObject.isNode()) {
++ log.warn("Object not a List: " + argObject);
++ return null;
++ }
++
++ List<Node> list = argObject.getArgList();
++
++ if (list.size() < 4 || list.size() > 5)
++ throw new SpatialIndexException("Change in object list size");
++
++ int idx = 0;
++
++ Node x = list.get(idx);
++ if (!x.isLiteral()) {
++ log.warn("Latitude 1 is not a literal " + list);
++ return null;
++ }
++ if (!SpatialValueUtil.isDecimal(x)) {
++ log.warn("Latitude 1 is not a decimal " + list);
++ return null;
++ }
++ Double latitude1 = Double.parseDouble(x.getLiteralLexicalForm());
++
++ idx++;
++
++ x = list.get(idx);
++ if (!x.isLiteral()) {
++ log.warn("Longitude 1 is not a literal " + list);
++ return null;
++ }
++ if (!SpatialValueUtil.isDecimal(x)) {
++ log.warn("Longitude 1 is not a decimal " + list);
++ return null;
++ }
++ Double longtitude1 = Double.parseDouble(x.getLiteralLexicalForm());
++
++ idx++;
++
++ x = list.get(idx);
++ if (!x.isLiteral()) {
++ log.warn("Latitude 2 is not a literal " + list);
++ return null;
++ }
++ if (!SpatialValueUtil.isDecimal(x)) {
++ log.warn("Latitude 2 is not a decimal " + list);
++ return null;
++ }
++ Double latitude2 = Double.parseDouble(x.getLiteralLexicalForm());
++
++ idx++;
++
++ x = list.get(idx);
++ if (!x.isLiteral()) {
++ log.warn("Longitude 2 is not a literal " + list);
++ return null;
++ }
++ if (!SpatialValueUtil.isDecimal(x)) {
++ log.warn("Longitude 2 is not a decimal " + list);
++ return null;
++ }
++ Double longtitude2 = Double.parseDouble(x.getLiteralLexicalForm());
++
++ idx++;
++ int limit =-1;
++
++ if (idx < list.size()) {
++ x = list.get(idx);
++
++ if (!x.isLiteral()) {
++ log.warn("Limit is not a literal " + list);
++ return null;
++ }
++
++ LiteralLabel lit = x.getLiteral();
++
++ if (!XSDDatatype.XSDinteger.isValidLiteral(lit)) {
++ log.warn("Limit is not an integer " + list);
++ return null;
++ }
++
++ int v = NodeFactoryExtra.nodeToInt(x);
++ limit = (v < 0) ? -1 : v;
++
++ idx++;
++ if (idx < list.size()) {
++ log.warn("Limit is not the last parameter " + list);
++ return null;
++ }
++ }
++
++ SpatialMatch match = new SpatialMatch(latitude1, longtitude1,
++ latitude2, longtitude2, limit, getSpatialOperation());
++
++ if (log.isDebugEnabled())
++ log.debug("Trying SpatialMatch: " + match.toString());
++ return match;
++ }
++
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/EastPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/EastPF.java
index 96e5519,96e5519..6c40cfa
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/EastPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/EastPF.java
@@@ -1,44 -1,44 +1,44 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.SpatialQuery;
--import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
--import org.apache.jena.query.spatial.pfunction.SpatialMatch;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--
--public class EastPF extends DirectionWithPointPFBase {
--
-- private static Logger log = LoggerFactory.getLogger(EastPF.class);
--
-- public EastPF() {
-- // TODO Auto-generated constructor stub
-- }
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- @Override
-- protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) {
-- SpatialMatch match = new SpatialMatch(SpatialQuery.ctx.getWorldBounds().getMinY(),
-- longitude, SpatialQuery.ctx.getWorldBounds().getMaxY(), SpatialQuery.ctx.getWorldBounds()
-- .getMaxX(), limit, getSpatialOperation());
-- return match;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.SpatialQuery;
++import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
++import org.apache.jena.query.spatial.pfunction.SpatialMatch;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class EastPF extends DirectionWithPointPFBase {
++
++ private static Logger log = LoggerFactory.getLogger(EastPF.class);
++
++ public EastPF() {
++ // TODO Auto-generated constructor stub
++ }
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ @Override
++ protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) {
++ SpatialMatch match = new SpatialMatch(SpatialQuery.ctx.getWorldBounds().getMinY(),
++ longitude, SpatialQuery.ctx.getWorldBounds().getMaxY(), SpatialQuery.ctx.getWorldBounds()
++ .getMaxX(), limit, getSpatialOperation());
++ return match;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IntersectsBoxPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IntersectsBoxPF.java
index 8d6b426,8d6b426..d71f050
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IntersectsBoxPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IntersectsBoxPF.java
@@@ -1,35 -1,35 +1,35 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.pfunction.SpatialOperationWithBoxPFBase;
--import org.apache.lucene.spatial.query.SpatialOperation;
--
--public class IntersectsBoxPF extends SpatialOperationWithBoxPFBase {
--
-- public IntersectsBoxPF() {
-- }
--
--
-- @Override
-- protected SpatialOperation getSpatialOperation() {
-- return SpatialOperation.Intersects;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.pfunction.SpatialOperationWithBoxPFBase;
++import org.apache.lucene.spatial.query.SpatialOperation;
++
++public class IntersectsBoxPF extends SpatialOperationWithBoxPFBase {
++
++ public IntersectsBoxPF() {
++ }
++
++
++ @Override
++ protected SpatialOperation getSpatialOperation() {
++ return SpatialOperation.Intersects;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsNearByPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsNearByPF.java
index 75df1d1,75df1d1..a5a44d4
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsNearByPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsNearByPF.java
@@@ -1,23 -1,23 +1,23 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--public class IsNearByPF extends IsWithinCirclePF {
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++public class IsNearByPF extends IsWithinCirclePF {
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinBoxPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinBoxPF.java
index 048d0b2,048d0b2..078bd10
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinBoxPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinBoxPF.java
@@@ -1,34 -1,34 +1,34 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.pfunction.SpatialOperationWithBoxPFBase;
--import org.apache.lucene.spatial.query.SpatialOperation;
--
--public class IsWithinBoxPF extends SpatialOperationWithBoxPFBase {
--
-- public IsWithinBoxPF() {
-- }
--
-- @Override
-- protected SpatialOperation getSpatialOperation() {
-- return SpatialOperation.IsWithin;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.pfunction.SpatialOperationWithBoxPFBase;
++import org.apache.lucene.spatial.query.SpatialOperation;
++
++public class IsWithinBoxPF extends SpatialOperationWithBoxPFBase {
++
++ public IsWithinBoxPF() {
++ }
++
++ @Override
++ protected SpatialOperation getSpatialOperation() {
++ return SpatialOperation.IsWithin;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinCirclePF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinCirclePF.java
index 322e442,322e442..c10c4e2
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinCirclePF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/IsWithinCirclePF.java
@@@ -1,35 -1,35 +1,35 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.pfunction.SpatialOperationWithCircleBase;
--import org.apache.lucene.spatial.query.SpatialOperation;
--
--public class IsWithinCirclePF extends SpatialOperationWithCircleBase {
--
-- public IsWithinCirclePF() {
-- // TODO Auto-generated constructor stub
-- }
--
-- @Override
-- protected SpatialOperation getSpatialOperation() {
-- return SpatialOperation.IsWithin;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.pfunction.SpatialOperationWithCircleBase;
++import org.apache.lucene.spatial.query.SpatialOperation;
++
++public class IsWithinCirclePF extends SpatialOperationWithCircleBase {
++
++ public IsWithinCirclePF() {
++ // TODO Auto-generated constructor stub
++ }
++
++ @Override
++ protected SpatialOperation getSpatialOperation() {
++ return SpatialOperation.IsWithin;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/NorthPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/NorthPF.java
index 9576fe3,9576fe3..e2cfbb1
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/NorthPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/NorthPF.java
@@@ -1,45 -1,45 +1,45 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.SpatialQuery;
--import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
--import org.apache.jena.query.spatial.pfunction.SpatialMatch;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--
--public class NorthPF extends DirectionWithPointPFBase {
--
-- private static Logger log = LoggerFactory.getLogger(NorthPF.class);
--
-- public NorthPF() {
-- // TODO Auto-generated constructor stub
-- }
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- @Override
-- protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) {
-- SpatialMatch match = new SpatialMatch(latitude, SpatialQuery.ctx
-- .getWorldBounds().getMinX(), SpatialQuery.ctx.getWorldBounds()
-- .getMaxY(), SpatialQuery.ctx.getWorldBounds().getMaxX(), limit,
-- getSpatialOperation());
-- return match;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.SpatialQuery;
++import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
++import org.apache.jena.query.spatial.pfunction.SpatialMatch;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class NorthPF extends DirectionWithPointPFBase {
++
++ private static Logger log = LoggerFactory.getLogger(NorthPF.class);
++
++ public NorthPF() {
++ // TODO Auto-generated constructor stub
++ }
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ @Override
++ protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) {
++ SpatialMatch match = new SpatialMatch(latitude, SpatialQuery.ctx
++ .getWorldBounds().getMinX(), SpatialQuery.ctx.getWorldBounds()
++ .getMaxY(), SpatialQuery.ctx.getWorldBounds().getMaxX(), limit,
++ getSpatialOperation());
++ return match;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/SouthPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/SouthPF.java
index cf8a467,cf8a467..431531b
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/SouthPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/SouthPF.java
@@@ -1,43 -1,43 +1,43 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.SpatialQuery;
--import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
--import org.apache.jena.query.spatial.pfunction.SpatialMatch;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--
--public class SouthPF extends DirectionWithPointPFBase {
--
-- private static Logger log = LoggerFactory.getLogger(SouthPF.class);
--
-- public SouthPF() {
-- // TODO Auto-generated constructor stub
-- }
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- @Override
-- protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) { SpatialMatch match = new SpatialMatch(SpatialQuery.ctx.getWorldBounds().getMinY(),
-- SpatialQuery.ctx.getWorldBounds().getMinX(), latitude, SpatialQuery.ctx.getWorldBounds()
-- .getMaxX(), limit, getSpatialOperation());
-- return match;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.SpatialQuery;
++import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
++import org.apache.jena.query.spatial.pfunction.SpatialMatch;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class SouthPF extends DirectionWithPointPFBase {
++
++ private static Logger log = LoggerFactory.getLogger(SouthPF.class);
++
++ public SouthPF() {
++ // TODO Auto-generated constructor stub
++ }
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ @Override
++ protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) { SpatialMatch match = new SpatialMatch(SpatialQuery.ctx.getWorldBounds().getMinY(),
++ SpatialQuery.ctx.getWorldBounds().getMinX(), latitude, SpatialQuery.ctx.getWorldBounds()
++ .getMaxX(), limit, getSpatialOperation());
++ return match;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/WestPF.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/WestPF.java
index 5b3f568,5b3f568..9ddf6b7
--- a/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/WestPF.java
+++ b/jena-spatial/src/main/java/org/apache/jena/query/spatial/pfunction/library/WestPF.java
@@@ -1,44 -1,44 +1,44 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial.pfunction.library;
--
--import org.apache.jena.query.spatial.SpatialQuery;
--import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
--import org.apache.jena.query.spatial.pfunction.SpatialMatch;
--import org.slf4j.Logger;
--import org.slf4j.LoggerFactory;
--
--public class WestPF extends DirectionWithPointPFBase {
--
-- private static Logger log = LoggerFactory.getLogger(WestPF.class);
--
-- public WestPF() {
-- // TODO Auto-generated constructor stub
-- }
--
-- /** Deconstruct the node or list object argument and make a SpatialMatch */
-- @Override
-- protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) {
-- SpatialMatch match = new SpatialMatch(SpatialQuery.ctx.getWorldBounds().getMinY(),
-- SpatialQuery.ctx.getWorldBounds().getMinX(), SpatialQuery.ctx.getWorldBounds().getMaxY(),
-- longitude, limit, getSpatialOperation());
-- return match;
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial.pfunction.library;
++
++import org.apache.jena.query.spatial.SpatialQuery;
++import org.apache.jena.query.spatial.pfunction.DirectionWithPointPFBase;
++import org.apache.jena.query.spatial.pfunction.SpatialMatch;
++import org.slf4j.Logger;
++import org.slf4j.LoggerFactory;
++
++public class WestPF extends DirectionWithPointPFBase {
++
++ private static Logger log = LoggerFactory.getLogger(WestPF.class);
++
++ public WestPF() {
++ // TODO Auto-generated constructor stub
++ }
++
++ /** Deconstruct the node or list object argument and make a SpatialMatch */
++ @Override
++ protected SpatialMatch getSpatialMatch(Double latitude, Double longitude, int limit) {
++ SpatialMatch match = new SpatialMatch(SpatialQuery.ctx.getWorldBounds().getMinY(),
++ SpatialQuery.ctx.getWorldBounds().getMinX(), SpatialQuery.ctx.getWorldBounds().getMaxY(),
++ longitude, limit, getSpatialOperation());
++ return match;
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java
index 0780961,0780961..3fdeaca
--- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java
+++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/AbstractTestIndexingSpatialData.java
@@@ -1,93 -1,93 +1,93 @@@
--/**
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial;
--
--import java.util.Arrays;
--import java.util.HashSet;
--import java.util.Set;
--
--import org.apache.jena.atlas.lib.StrUtils;
--import org.junit.Test;
--import static org.junit.Assert.fail;
--
--import com.spatial4j.core.exception.InvalidShapeException;
--
--public class AbstractTestIndexingSpatialData extends
-- AbstractTestDatasetWithSpatialIndex {
--
-- @Test
-- public void testIndexingStringLiteral() {
-- final String turtle = StrUtils.strjoinNL(TURTLE_PROLOG, "<"
-- + RESOURCE_BASE + "testIndexingStringLiteral>",
-- " geo:lat '51.3827' ;", " geo:long '-2.71909' ", ".");
-- String queryString = StrUtils
-- .strjoinNL(
-- QUERY_PROLOG,
-- "SELECT ?s",
-- "WHERE {",
-- " ?s spatial:nearby (51.3000 -2.71000 100.0 'miles' -1) .",
-- "}");
-- Set<String> expectedURIs = (new HashSet<String>());
-- expectedURIs
-- .addAll(Arrays
-- .asList((new String[] { "http://example.org/data/resource/testIndexingStringLiteral" })));
-- doTestSearch(turtle, queryString, expectedURIs);
-- }
--
-- @Test
-- public void testIndexingWKTLiteral() {
-- boolean jts_context_ready = false;
-- try {
-- SpatialIndex index = (SpatialIndex) dataset.getContext().get(
-- SpatialQuery.spatialIndex);
-- index.getDocDef().setSpatialContextFactory(
-- SpatialQuery.JTS_SPATIAL_CONTEXT_FACTORY_CLASS);
-- jts_context_ready = true;
-- }catch (NoClassDefFoundError e){
-- //Log.warn(this, "JTS lib is not on the classpath!");
-- }
--
-- final String turtle = StrUtils
-- .strjoinNL(
-- TURTLE_PROLOG,
-- "<" + RESOURCE_BASE + "testIndexingWKTLiteral>",
-- " wkt:asWKT 'POINT(-1.74803 52.4539)'^^wkt:wktLiteral ",
-- ".");
-- String queryString = StrUtils
-- .strjoinNL(
-- QUERY_PROLOG,
-- "SELECT ?s",
-- "WHERE {",
-- " ?s spatial:nearby (51.3000 -2.71000 100.0 'miles' -1) .",
-- "}");
-- Set<String> expectedURIs = (new HashSet<String>());
-- expectedURIs
-- .addAll(Arrays
-- .asList((new String[] { "http://example.org/data/resource/testIndexingWKTLiteral" })));
--
-- try {
-- doTestSearch(turtle, queryString, expectedURIs);
-- }catch (InvalidShapeException e){
-- if (jts_context_ready){
-- fail("The exception is not supposed to be thrown: "+ e.getMessage());
-- }
-- }
-- }
--
--}
++/**
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial;
++
++import java.util.Arrays;
++import java.util.HashSet;
++import java.util.Set;
++
++import org.apache.jena.atlas.lib.StrUtils;
++import org.junit.Test;
++import static org.junit.Assert.fail;
++
++import com.spatial4j.core.exception.InvalidShapeException;
++
++public class AbstractTestIndexingSpatialData extends
++ AbstractTestDatasetWithSpatialIndex {
++
++ @Test
++ public void testIndexingStringLiteral() {
++ final String turtle = StrUtils.strjoinNL(TURTLE_PROLOG, "<"
++ + RESOURCE_BASE + "testIndexingStringLiteral>",
++ " geo:lat '51.3827' ;", " geo:long '-2.71909' ", ".");
++ String queryString = StrUtils
++ .strjoinNL(
++ QUERY_PROLOG,
++ "SELECT ?s",
++ "WHERE {",
++ " ?s spatial:nearby (51.3000 -2.71000 100.0 'miles' -1) .",
++ "}");
++ Set<String> expectedURIs = (new HashSet<String>());
++ expectedURIs
++ .addAll(Arrays
++ .asList((new String[] { "http://example.org/data/resource/testIndexingStringLiteral" })));
++ doTestSearch(turtle, queryString, expectedURIs);
++ }
++
++ @Test
++ public void testIndexingWKTLiteral() {
++ boolean jts_context_ready = false;
++ try {
++ SpatialIndex index = (SpatialIndex) dataset.getContext().get(
++ SpatialQuery.spatialIndex);
++ index.getDocDef().setSpatialContextFactory(
++ SpatialQuery.JTS_SPATIAL_CONTEXT_FACTORY_CLASS);
++ jts_context_ready = true;
++ }catch (NoClassDefFoundError e){
++ //Log.warn(this, "JTS lib is not on the classpath!");
++ }
++
++ final String turtle = StrUtils
++ .strjoinNL(
++ TURTLE_PROLOG,
++ "<" + RESOURCE_BASE + "testIndexingWKTLiteral>",
++ " wkt:asWKT 'POINT(-1.74803 52.4539)'^^wkt:wktLiteral ",
++ ".");
++ String queryString = StrUtils
++ .strjoinNL(
++ QUERY_PROLOG,
++ "SELECT ?s",
++ "WHERE {",
++ " ?s spatial:nearby (51.3000 -2.71000 100.0 'miles' -1) .",
++ "}");
++ Set<String> expectedURIs = (new HashSet<String>());
++ expectedURIs
++ .addAll(Arrays
++ .asList((new String[] { "http://example.org/data/resource/testIndexingWKTLiteral" })));
++
++ try {
++ doTestSearch(turtle, queryString, expectedURIs);
++ }catch (InvalidShapeException e){
++ if (jts_context_ready){
++ fail("The exception is not supposed to be thrown: "+ e.getMessage());
++ }
++ }
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithLucene.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithLucene.java
index 1a1a2bf,1a1a2bf..af3ad7a
--- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithLucene.java
+++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithLucene.java
@@@ -1,42 -1,42 +1,42 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial;
--
--import java.io.File;
--import java.io.IOException;
--import org.junit.After;
--import org.junit.Before;
--
--public class TestIndexingSpatialDataWithLucene extends
-- AbstractTestIndexingSpatialData {
-- private static final String INDEX_PATH = "target/test/IsNearByPFWithLuceneSpatialIndex";
-- private static final File INDEX_DIR = new File(INDEX_PATH);
--
-- @Before
-- public void init() throws IOException {
-- dataset = SpatialSearchUtil
-- .initInMemoryDatasetWithLuceneSpatitalIndex(INDEX_DIR);
-- }
--
-- @After
-- public void destroy() {
-- SpatialSearchUtil.deleteOldFiles(INDEX_DIR);
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial;
++
++import java.io.File;
++import java.io.IOException;
++import org.junit.After;
++import org.junit.Before;
++
++public class TestIndexingSpatialDataWithLucene extends
++ AbstractTestIndexingSpatialData {
++ private static final String INDEX_PATH = "target/test/IsNearByPFWithLuceneSpatialIndex";
++ private static final File INDEX_DIR = new File(INDEX_PATH);
++
++ @Before
++ public void init() throws IOException {
++ dataset = SpatialSearchUtil
++ .initInMemoryDatasetWithLuceneSpatitalIndex(INDEX_DIR);
++ }
++
++ @After
++ public void destroy() {
++ SpatialSearchUtil.deleteOldFiles(INDEX_DIR);
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java
index 3a94f55,3a94f55..d3f70cd
--- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java
+++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestIndexingSpatialDataWithSolr.java
@@@ -1,40 -1,40 +1,40 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial;
--
--import org.junit.After;
--import org.junit.Before;
--
--public class TestIndexingSpatialDataWithSolr extends
-- AbstractTestIndexingSpatialData {
--
-- @Before
-- public void init() {
-- dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex();
-- }
--
-- @After
-- public void destroy() {
-- SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(
-- SpatialQuery.spatialIndex);
-- index.getServer().shutdown();
-- SpatialSearchUtil.deleteOldSolrDataDir();
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial;
++
++import org.junit.After;
++import org.junit.Before;
++
++public class TestIndexingSpatialDataWithSolr extends
++ AbstractTestIndexingSpatialData {
++
++ @Before
++ public void init() {
++ dataset = SpatialSearchUtil.initInMemoryDatasetWithSolrSpatitalIndex();
++ }
++
++ @After
++ public void destroy() {
++ SpatialIndexSolr index = (SpatialIndexSolr) dataset.getContext().get(
++ SpatialQuery.spatialIndex);
++ index.getServer().shutdown();
++ SpatialSearchUtil.deleteOldSolrDataDir();
++ }
++
++}
http://git-wip-us.apache.org/repos/asf/jena/blob/4b5cd267/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestSpatialPredicatePairValue.java
----------------------------------------------------------------------
diff --cc jena-spatial/src/test/java/org/apache/jena/query/spatial/TestSpatialPredicatePairValue.java
index 6e01f71,6e01f71..e98f459
--- a/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestSpatialPredicatePairValue.java
+++ b/jena-spatial/src/test/java/org/apache/jena/query/spatial/TestSpatialPredicatePairValue.java
@@@ -1,59 -1,59 +1,59 @@@
--/*
-- * Licensed to the Apache Software Foundation (ASF) under one
-- * or more contributor license agreements. See the NOTICE file
-- * distributed with this work for additional information
-- * regarding copyright ownership. The ASF licenses this file
-- * to you under the Apache License, Version 2.0 (the
-- * "License"); you may not use this file except in compliance
-- * with the License. You may obtain a copy of the License at
-- *
-- * http://www.apache.org/licenses/LICENSE-2.0
-- *
-- * Unless required by applicable law or agreed to in writing, software
-- * distributed under the License is distributed on an "AS IS" BASIS,
-- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- * See the License for the specific language governing permissions and
-- * limitations under the License.
-- */
--
--package org.apache.jena.query.spatial;
--
--import junit.framework.TestCase;
--
--import org.junit.Test;
--
--public class TestSpatialPredicatePairValue {
--
-- @Test public void testEqualsAndHashcode(){
-- SpatialPredicatePair pair1 = new SpatialPredicatePair(
-- EntityDefinition.geo_latitude.asNode(),
-- EntityDefinition.geo_longitude.asNode());
-- SpatialPredicatePair pair2 = new SpatialPredicatePair(
-- EntityDefinition.geo_latitude.asNode(),
-- EntityDefinition.geo_longitude.asNode());
-- TestCase.assertTrue(pair1.equals(pair2));
-- TestCase.assertTrue(pair1.hashCode() == pair2.hashCode());
--
-- SpatialPredicatePairValue value1 = new SpatialPredicatePairValue(pair1);
-- value1.setValue(EntityDefinition.geo_latitude.asNode(), 12.0);
-- value1.setValue(EntityDefinition.geo_longitude.asNode(), 23.0);
--
-- SpatialPredicatePairValue value2 = new SpatialPredicatePairValue(pair2);
-- value2.setValue(EntityDefinition.geo_latitude.asNode(), 12.0);
-- value2.setValue(EntityDefinition.geo_longitude.asNode(), 23.0);
--
-- TestCase.assertTrue(value1.equals(value2));
-- TestCase.assertTrue(value1.hashCode() == value2.hashCode());
--
-- value1.setValue(EntityDefinition.geo_latitude.asNode(),null);
-- value2.setValue(EntityDefinition.geo_latitude.asNode(),null);
--
-- TestCase.assertTrue(value1.equals(value2));
-- TestCase.assertTrue(value1.hashCode() == value2.hashCode());
--
-- value2.setValue(EntityDefinition.geo_latitude.asNode(),23.0);
-- TestCase.assertFalse(value1.equals(value2));
-- TestCase.assertFalse(value1.hashCode() == value2.hashCode());
-- }
--
--}
++/*
++ * Licensed to the Apache Software Foundation (ASF) under one
++ * or more contributor license agreements. See the NOTICE file
++ * distributed with this work for additional information
++ * regarding copyright ownership. The ASF licenses this file
++ * to you under the Apache License, Version 2.0 (the
++ * "License"); you may not use this file except in compliance
++ * with the License. You may obtain a copy of the License at
++ *
++ * http://www.apache.org/licenses/LICENSE-2.0
++ *
++ * Unless required by applicable law or agreed to in writing, software
++ * distributed under the License is distributed on an "AS IS" BASIS,
++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++ * See the License for the specific language governing permissions and
++ * limitations under the License.
++ */
++
++package org.apache.jena.query.spatial;
++
++import junit.framework.TestCase;
++
++import org.junit.Test;
++
++public class TestSpatialPredicatePairValue {
++
++ @Test public void testEqualsAndHashcode(){
++ SpatialPredicatePair pair1 = new SpatialPredicatePair(
++ EntityDefinition.geo_latitude.asNode(),
++ EntityDefinition.geo_longitude.asNode());
++ SpatialPredicatePair pair2 = new SpatialPredicatePair(
++ EntityDefinition.geo_latitude.asNode(),
++ EntityDefinition.geo_longitude.asNode());
++ TestCase.assertTrue(pair1.equals(pair2));
++ TestCase.assertTrue(pair1.hashCode() == pair2.hashCode());
++
++ SpatialPredicatePairValue value1 = new SpatialPredicatePairValue(pair1);
++ value1.setValue(EntityDefinition.geo_latitude.asNode(), 12.0);
++ value1.setValue(EntityDefinition.geo_longitude.asNode(), 23.0);
++
++ SpatialPredicatePairValue value2 = new SpatialPredicatePairValue(pair2);
++ value2.setValue(EntityDefinition.geo_latitude.asNode(), 12.0);
++ value2.setValue(EntityDefinition.geo_longitude.asNode(), 23.0);
++
++ TestCase.assertTrue(value1.equals(value2));
++ TestCase.assertTrue(value1.hashCode() == value2.hashCode());
++
++ value1.setValue(EntityDefinition.geo_latitude.asNode(),null);
++ value2.setValue(EntityDefinition.geo_latitude.asNode(),null);
++
++ TestCase.assertTrue(value1.equals(value2));
++ TestCase.assertTrue(value1.hashCode() == value2.hashCode());
++
++ value2.setValue(EntityDefinition.geo_latitude.asNode(),23.0);
++ TestCase.assertFalse(value1.equals(value2));
++ TestCase.assertFalse(value1.hashCode() == value2.hashCode());
++ }
++
++}