Apache Lucene open-source search software
LUCENE-1508 -- using the tierPrefix constructors by default
Ryan McKinley4978391e93ea
diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.javaindex 24ffe7dff0d..212dc518253 100644--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java+++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/CartesianPolyFilterBuilder.java@@ -36,6 +36,12 @@ public class CartesianPolyFilterBuilder {private IProjector projector = new SinusoidalProjector();private Logger log = Logger.getLogger(getClass().getName());+ private final String tierPrefix;++ public CartesianPolyFilterBuilder( String tierPrefix ) {+ this.tierPrefix = tierPrefix;+ }+public Shape getBoxShape(double latitude, double longitude, int miles){Rectangle box = DistanceUtils.getInstance().getBoundary(latitude, longitude, miles);@@ -46,11 +52,11 @@ public class CartesianPolyFilterBuilder {double longY = box.getMaxPoint().getX(); ///box.getX();double longX = box.getMinPoint().getX();//box.getMaxX();- CartesianTierPlotter ctp = new CartesianTierPlotter(2, projector);+ CartesianTierPlotter ctp = new CartesianTierPlotter(2, projector,tierPrefix);int bestFit = ctp.bestFit(miles);log.info("Best Fit is : " + bestFit);- ctp = new CartesianTierPlotter(bestFit, projector);+ ctp = new CartesianTierPlotter(bestFit, projector,tierPrefix);Shape shape = new Shape(ctp.getTierFieldName());// generate shapediff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.javaindex d1929974f8c..355ecd8f4f5 100644--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java+++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/DistanceQueryBuilder.java@@ -47,14 +47,15 @@ public class DistanceQueryBuilder {* @param lng* @param miles*/- public DistanceQueryBuilder (double lat, double lng, double miles, String latField, String lngField, boolean needPrecise){+ public DistanceQueryBuilder (double lat, double lng, double miles,+ String latField, String lngField, String tierFieldPrefix, boolean needPrecise){this.lat = lat;this.lng = lng;this.miles = miles;- CartesianPolyFilterBuilder cpf = new CartesianPolyFilterBuilder();+ CartesianPolyFilterBuilder cpf = new CartesianPolyFilterBuilder(tierFieldPrefix);cartesianFilter = cpf.getBoundingArea(lat, lng, (int)miles);/* create precise distance filter */diff --git a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.javaindex e639bb0b3e1..17dd6708e50 100644--- a/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java+++ b/contrib/spatial/src/java/org/apache/lucene/spatial/tier/projections/CartesianTierPlotter.java@@ -21,6 +21,7 @@ package org.apache.lucene.spatial.tier.projections;**/public class CartesianTierPlotter {+ public static final String DEFALT_FIELD_PREFIX = "_tier_";final int tierLevel;int tierLength;@@ -40,10 +41,6 @@ public class CartesianTierPlotter {setTierBoxes();setTierVerticalPosDivider();}-- public CartesianTierPlotter (int tierLevel, IProjector projector) {- this( tierLevel, projector, "_localTier" );- }private void setTierLength (){this.tierLength = (int) Math.pow(2 , this.tierLevel);diff --git a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/PolyShape.java b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/PolyShape.javaindex 9bb8a80191b..d9ae39817d1 100644--- a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/PolyShape.java+++ b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/PolyShape.java@@ -1 +1 @@-/** * 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.lucene.spatial.tier; /** * */ public class PolyShape { private static double lat = 38.969398; private static double lng= -77.386398; private static int miles = 1000; /** * @param args */ public static void main(String[] args) { CartesianPolyFilterBuilder cpf = new CartesianPolyFilterBuilder(); cpf.getBoxShape(lat, lng, miles); } }\ No newline at end of file+/** * 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.lucene.spatial.tier; /** * */ public class PolyShape { private static double lat = 38.969398; private static double lng= -77.386398; private static int miles = 1000; /** * @param args */ public static void main(String[] args) { CartesianPolyFilterBuilder cpf = new CartesianPolyFilterBuilder( "_localTier" ); cpf.getBoxShape(lat, lng, miles); } }\ No newline at end of filediff --git a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.javaindex d17141191fb..6db1bccdd2d 100644--- a/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java+++ b/contrib/spatial/src/test/org/apache/lucene/spatial/tier/TestCartesian.java@@ -88,8 +88,8 @@ public class TestCartesian extends TestCase{private void setUpPlotter(int base, int top) {for (; base <= top; base ++){- ctps.add(new CartesianTierPlotter(base,project ));-+ ctps.add(new CartesianTierPlotter(base,project,+ CartesianTierPlotter.DEFALT_FIELD_PREFIX));}}@@ -149,7 +149,8 @@ public class TestCartesian extends TestCase{final double miles = 6.0;// create a distance query- final DistanceQueryBuilder dq = new DistanceQueryBuilder(lat, lng, miles, latField, lngField, true);+ final DistanceQueryBuilder dq = new DistanceQueryBuilder(lat, lng, miles,+ latField, lngField, CartesianTierPlotter.DEFALT_FIELD_PREFIX, true);System.out.println(dq);//create a term query to search against all documents