Apache Solr open-source search software
SOLR-3864 maxDetailDist -> maxDistErr and make units='degrees' mandatory
David Wayne Smiley255e8f1aa8da
diff --git a/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java b/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.javaindex bbb01df0d22..f5a4bc49426 100644--- a/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java+++ b/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeFactory.java@@ -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 SpatialPrefixTreeFactory {*/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 SpatialPrefixTreeFactory {}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 SpatialPrefixTreeFactory {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);}diff --git a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.javaindex 90c9b943736..7ed8640910e 100644--- a/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java+++ b/solr/core/src/java/org/apache/solr/schema/AbstractSpatialFieldType.java@@ -62,6 +62,11 @@ public abstract class AbstractSpatialFieldType<T extends SpatialStrategy> extendprotected 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());diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml b/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xmlindex e094c7238f4..266873b6004 100644--- a/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml+++ b/solr/core/src/test-files/solr/collection1/conf/schema-spatial.xml@@ -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>diff --git a/solr/example/solr/collection1/conf/schema.xml b/solr/example/solr/collection1/conf/schema.xmlindex b34f9969075..caaf5036dce 100755--- a/solr/example/solr/collection1/conf/schema.xml+++ b/solr/example/solr/collection1/conf/schema.xml@@ -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/MoneyFieldTypeParameters: