You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2012/10/01 20:37:35 UTC
svn commit: r1392506 - in /lucene/dev/branches/lucene_solr_4_0: ./ lucene/
lucene/spatial/ lucene/spatial/src/java/org/apache/lucene/spatial/query/
lucene/spatial/src/test/org/apache/lucene/spatial/
Author: dsmiley
Date: Mon Oct 1 18:37:34 2012
New Revision: 1392506
URL: http://svn.apache.org/viewvc?rev=1392506&view=rev
Log:
LUCENE-4444 Use SpatialContext to read shape strings. Necessary for supporting 3rd party spatial contexts such as the JTS one to use polygons.
Modified:
lucene/dev/branches/lucene_solr_4_0/ (props changed)
lucene/dev/branches/lucene_solr_4_0/lucene/ (props changed)
lucene/dev/branches/lucene_solr_4_0/lucene/spatial/ (props changed)
lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java
lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java
lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
Modified: lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java?rev=1392506&r1=1392505&r2=1392506&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java (original)
+++ lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/query/SpatialArgsParser.java Mon Oct 1 18:37:34 2012
@@ -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)) {
Modified: lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java?rev=1392506&r1=1392505&r2=1392506&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java (original)
+++ lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/PortedSolr3Test.java Mon Oct 1 18:37:34 2012
@@ -21,7 +21,6 @@ import com.carrotsearch.randomizedtestin
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 Str
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)
Modified: lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java?rev=1392506&r1=1392505&r2=1392506&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java (original)
+++ lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialExample.java Mon Oct 1 18:37:34 2012
@@ -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;
@@ -112,7 +111,7 @@ public class SpatialExample extends Luce
//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)));
Modified: lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java?rev=1392506&r1=1392505&r2=1392506&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (original)
+++ lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java Mon Oct 1 18:37:34 2012
@@ -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;
@@ -87,7 +86,7 @@ public abstract class StrategyTestCase e
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)) {
@@ -128,7 +127,7 @@ public abstract class StrategyTestCase e
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();
@@ -168,7 +167,7 @@ public abstract class StrategyTestCase e
}
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 {