LUCENE-1508 -- using the tierPrefix constructors by default

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@730662 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2009-01-02 03:21:23 +00:00
parent 0958d83354
commit 4978391e93
5 changed files with 17 additions and 12 deletions

View File

@ -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 shape

View File

@ -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 */

View File

@ -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);

View File

@ -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); } }
/** * 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); } }

View File

@ -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