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/09/22 20:42:32 UTC

svn commit: r1388867 - in /lucene/dev/branches/lucene_solr_4_0: ./ lucene/ lucene/spatial/ lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/ solr/ solr/core/ solr/core/src/java/org/apache/solr/schema/ solr/core/src/test-files/solr/collecti...

Author: dsmiley
Date: Sat Sep 22 18:42:32 2012
New Revision: 1388867

URL: http://svn.apache.org/viewvc?rev=1388867&view=rev
Log:
SOLR-3864 maxDetailDist -> maxDistErr and make units='degrees' mandatory

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/prefix/tree/SpatialPrefixTreeFactory.java
    lucene/dev/branches/lucene_solr_4_0/solr/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/core/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
    lucene/dev/branches/lucene_solr_4_0/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
    lucene/dev/branches/lucene_solr_4_0/solr/example/   (props changed)
    lucene/dev/branches/lucene_solr_4_0/solr/example/solr/collection1/conf/schema.xml

Modified: lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java?rev=1388867&r1=1388866&r2=1388867&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java (original)
+++ lucene/dev/branches/lucene_solr_4_0/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java Sat Sep 22 18:42:32 2012
@@ -31,6 +31,9 @@ import java.util.Map;
 public abstract class SpatialPrefixTreeFactory {
 
   private static final double DEFAULT_GEO_MAX_DETAIL_KM = 0.001;//1m
+  public static final String PREFIX_TREE = "prefixTree";
+  public static final String MAX_LEVELS = "maxLevels";
+  public static final String MAX_DIST_ERR = "maxDistErr";
 
   protected Map<String, String> args;
   protected SpatialContext ctx;
@@ -42,7 +45,7 @@ public abstract class SpatialPrefixTreeF
    */
   public static SpatialPrefixTree makeSPT(Map<String,String> args, ClassLoader classLoader, SpatialContext ctx) {
     SpatialPrefixTreeFactory instance;
-    String cname = args.get("prefixTree");
+    String cname = args.get(PREFIX_TREE);
     if (cname == null)
       cname = ctx.isGeo() ? "geohash" : "quad";
     if ("geohash".equalsIgnoreCase(cname))
@@ -68,14 +71,14 @@ public abstract class SpatialPrefixTreeF
   }
 
   protected void initMaxLevels() {
-    String mlStr = args.get("maxLevels");
+    String mlStr = args.get(MAX_LEVELS);
     if (mlStr != null) {
       maxLevels = Integer.valueOf(mlStr);
       return;
     }
 
     double degrees;
-    String maxDetailDistStr = args.get("maxDetailDist");
+    String maxDetailDistStr = args.get(MAX_DIST_ERR);
     if (maxDetailDistStr == null) {
       if (!ctx.isGeo()) {
         return;//let default to max
@@ -83,9 +86,6 @@ public abstract class SpatialPrefixTreeF
       degrees = DistanceUtils.dist2Degrees(DEFAULT_GEO_MAX_DETAIL_KM, DistanceUtils.EARTH_MEAN_RADIUS_KM);
     } else {
       degrees = Double.parseDouble(maxDetailDistStr);
-      if (ctx.isGeo()) {
-        degrees = DistanceUtils.dist2Degrees(Double.parseDouble(maxDetailDistStr), DistanceUtils.EARTH_MEAN_RADIUS_KM);
-      }
     }
     maxLevels = getLevelForDistance(degrees);
   }

Modified: lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java?rev=1388867&r1=1388866&r2=1388867&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java (original)
+++ lucene/dev/branches/lucene_solr_4_0/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java Sat Sep 22 18:42:32 2012
@@ -62,6 +62,11 @@ public abstract class AbstractSpatialFie
   protected void init(IndexSchema schema, Map<String, String> args) {
     super.init(schema, args);
 
+    String units = args.remove("units");
+    if (!"degrees".equals(units))
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
+          "Must specify units=\"degrees\" on field types with class "+getClass().getSimpleName());
+
     //Solr expects us to remove the parameters we've used.
     MapListener<String, String> argsWrap = new MapListener<String, String>(args);
     ctx = SpatialContextFactory.makeSpatialContext(argsWrap, schema.getResourceLoader().getClassLoader());

Modified: lucene/dev/branches/lucene_solr_4_0/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml?rev=1388867&r1=1388866&r2=1388867&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml (original)
+++ lucene/dev/branches/lucene_solr_4_0/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml Sat Sep 22 18:42:32 2012
@@ -27,22 +27,22 @@
     <fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
 
     <fieldType name="srpt_geohash"   class="solr.SpatialRecursivePrefixTreeFieldType"
-               prefixTree="geohash"
+               prefixTree="geohash" units="degrees"
         />
     <fieldType name="srpt_quad"   class="solr.SpatialRecursivePrefixTreeFieldType"
-              prefixTree="quad"
+              prefixTree="quad" units="degrees"
         />
     <fieldType name="srpt_100km"   class="solr.SpatialRecursivePrefixTreeFieldType"
-              maxDetailDist="0.9"
+              maxDistErr="0.9" units="degrees"
         />
     <fieldType name="stqpt_geohash"   class="solr.SpatialTermQueryPrefixTreeFieldType"
-              prefixTree="geohash" />
+              prefixTree="geohash" units="degrees" />
 
     <fieldType name="stqpt_u"  class="solr.SpatialTermQueryPrefixTreeFieldType"
-        geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000"/>
+        geo="false" distCalculator="cartesian^2" worldBounds="0 0 1000 1000" units="degrees"/>
 
     <fieldType name="twodoubles" class="solr.SpatialTwoDoublesFieldType"
-               numberType="tdouble"/>
+               numberType="tdouble" units="degrees"/>
 
   </types>
 

Modified: lucene/dev/branches/lucene_solr_4_0/solr/example/solr/collection1/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_0/solr/example/solr/collection1/conf/schema.xml?rev=1388867&r1=1388866&r2=1388867&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_0/solr/example/solr/collection1/conf/schema.xml (original)
+++ lucene/dev/branches/lucene_solr_4_0/solr/example/solr/collection1/conf/schema.xml Sat Sep 22 18:42:32 2012
@@ -686,7 +686,7 @@
       http://wiki.apache.org/solr/SolrAdaptersForLuceneSpatial4
     -->
     <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
-        geo="true" distErrPct="0.025" maxDetailDist="0.000009" />
+        geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
 
    <!-- Money/currency field type. See http://wiki.apache.org/solr/MoneyFieldType
         Parameters: