mirror of https://github.com/apache/lucene.git
LUCENE-4444 Use SpatialContext to read shape strings. Necessary for supporting 3rd party spatial contexts such as the JTS one to use polygons.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1391628 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eacacf449d
commit
6f6884e4ed
|
@ -86,7 +86,7 @@ public class SpatialArgsParser {
|
|||
throw new IllegalArgumentException("missing body : " + v, null);
|
||||
}
|
||||
|
||||
Shape shape = new ShapeReadWriter(ctx).readShape(body);
|
||||
Shape shape = ctx.readShape(body);
|
||||
SpatialArgs args = new SpatialArgs(op, shape);
|
||||
|
||||
if (v.length() > (edx + 1)) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.carrotsearch.randomizedtesting.annotations.Name;
|
|||
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
|
||||
import com.spatial4j.core.context.SpatialContext;
|
||||
import com.spatial4j.core.distance.DistanceUtils;
|
||||
import com.spatial4j.core.io.ShapeReadWriter;
|
||||
import com.spatial4j.core.shape.Point;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
import org.apache.lucene.search.FilteredQuery;
|
||||
|
@ -162,7 +161,7 @@ public class PortedSolr3Test extends StrategyTestCase {
|
|||
|
||||
private void _checkHits(boolean bbox, String ptStr, double distKM, int assertNumFound, int... assertIds) {
|
||||
SpatialOperation op = SpatialOperation.Intersects;
|
||||
Point pt = (Point) new ShapeReadWriter(ctx).readShape(ptStr);
|
||||
Point pt = (Point) ctx.readShape(ptStr);
|
||||
double distDEG = DistanceUtils.dist2Degrees(distKM, DistanceUtils.EARTH_MEAN_RADIUS_KM);
|
||||
Shape shape = ctx.makeCircle(pt, distDEG);
|
||||
if (bbox)
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.spatial;
|
|||
|
||||
import com.spatial4j.core.context.SpatialContext;
|
||||
import com.spatial4j.core.distance.DistanceUtils;
|
||||
import com.spatial4j.core.io.ShapeReadWriter;
|
||||
import com.spatial4j.core.shape.Point;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -111,7 +110,7 @@ public class SpatialExample extends LuceneTestCase {
|
|||
//When parsing a string to a shape, the presence of a comma means it's y-x
|
||||
// order (lon, lat)
|
||||
indexWriter.addDocument(newSampleDocument(
|
||||
4, new ShapeReadWriter(ctx).readShape("-50.7693246, 60.9289094")));
|
||||
4, ctx.readShape("-50.7693246, 60.9289094")));
|
||||
|
||||
indexWriter.addDocument(newSampleDocument(
|
||||
20, ctx.makePoint(0.1,0.1), ctx.makePoint(0, 0)));
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.spatial;
|
|||
*/
|
||||
|
||||
import com.spatial4j.core.context.SpatialContext;
|
||||
import com.spatial4j.core.io.ShapeReadWriter;
|
||||
import com.spatial4j.core.io.sample.SampleData;
|
||||
import com.spatial4j.core.io.sample.SampleDataReader;
|
||||
import com.spatial4j.core.shape.Shape;
|
||||
|
@ -89,7 +88,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
|
|||
Document document = new Document();
|
||||
document.add(new StringField("id", data.id, Field.Store.YES));
|
||||
document.add(new StringField("name", data.name, Field.Store.YES));
|
||||
Shape shape = new ShapeReadWriter(ctx).readShape(data.shape);
|
||||
Shape shape = ctx.readShape(data.shape);
|
||||
shape = convertShapeFromGetDocuments(shape);
|
||||
if (shape != null) {
|
||||
for (Field f : strategy.createIndexableFields(shape)) {
|
||||
|
@ -130,7 +129,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
|
|||
SearchResults got = executeQuery(strategy.makeQuery(q.args), 100);
|
||||
if (storeShape && got.numFound > 0) {
|
||||
//check stored value is there & parses
|
||||
assertNotNull(new ShapeReadWriter(ctx).readShape(got.results.get(0).document.get(strategy.getFieldName())));
|
||||
assertNotNull(ctx.readShape(got.results.get(0).document.get(strategy.getFieldName())));
|
||||
}
|
||||
if (concern.orderIsImportant) {
|
||||
Iterator<String> ids = q.ids.iterator();
|
||||
|
@ -174,7 +173,7 @@ public abstract class StrategyTestCase extends SpatialTestCase {
|
|||
}
|
||||
|
||||
protected void adoc(String id, String shapeStr) throws IOException {
|
||||
Shape shape = shapeStr==null ? null : new ShapeReadWriter(ctx).readShape(shapeStr);
|
||||
Shape shape = shapeStr==null ? null : ctx.readShape(shapeStr);
|
||||
addDocument(newDoc(id, shape));
|
||||
}
|
||||
protected void adoc(String id, Shape shape) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue