Make TestShapesGeo a base class and randomize selection of distance calculator instead of testing all of them every time.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3795_lsp_spatial_module@1291615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2012-02-21 06:52:08 +00:00
parent 8fc20e2b77
commit 5db69b3be6
2 changed files with 20 additions and 35 deletions

View File

@ -218,7 +218,7 @@ public abstract class AbstractTestShapes extends LuceneTestCase {
default: fail(""+ic);
}
}
System.out.println("Laps: "+laps);
//System.out.println("Laps: "+laps);
//TODO deliberately test INTERSECTS based on known intersection point
}

View File

@ -19,17 +19,17 @@ package org.apache.lucene.spatial.base.shape;
import org.apache.lucene.spatial.base.context.SpatialContext;
import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContext;
import org.apache.lucene.spatial.base.distance.*;
import org.junit.Ignore;
import org.apache.lucene.spatial.base.distance.DistanceCalculator;
import org.apache.lucene.spatial.base.distance.DistanceUnits;
import org.apache.lucene.spatial.base.distance.GeodesicSphereDistCalc;
import org.junit.Test;
import static org.apache.lucene.spatial.base.shape.SpatialRelation.*;
import static org.junit.Assert.assertEquals;
/**
* @author David Smiley - dsmiley@mitre.org
*/
public abstract class TestShapesGeo extends AbstractTestShapes {
public class TestShapesGeo extends AbstractTestShapes {
@Test
public void testGeoRectangle() {
@ -129,37 +129,22 @@ public abstract class TestShapesGeo extends AbstractTestShapes {
return ctx.getDistCalc().degreesToDistance(deg);
}
@Ignore
public static class TestLawOfCosines extends TestShapesGeo {
@Override
protected SpatialContext getContext() {
DistanceUnits units = DistanceUnits.KILOMETERS;
return new SimpleSpatialContext(units,
new GeodesicSphereDistCalc.LawOfCosines(units.earthRadius()),
SpatialContext.GEO_WORLDBOUNDS);
@Override
protected SpatialContext getContext() {
DistanceUnits units = DistanceUnits.KILOMETERS;
DistanceCalculator distCalc = new GeodesicSphereDistCalc.Haversine(units.earthRadius());//default
switch(random.nextInt(3)) {
case 2:
//TODO ENABLE WHEN WORKING
//distCalc = new GeodesicSphereDistCalc.LawOfCosines(units.earthRadius());
break;
case 1:
distCalc = new GeodesicSphereDistCalc.Vincenty(units.earthRadius());
break;
}
return new SimpleSpatialContext(units,
distCalc,
SpatialContext.GEO_WORLDBOUNDS);
}
public static class TestHaversine extends TestShapesGeo {
@Override
protected SpatialContext getContext() {
DistanceUnits units = DistanceUnits.KILOMETERS;
return new SimpleSpatialContext(units,
new GeodesicSphereDistCalc.Haversine(units.earthRadius()),
SpatialContext.GEO_WORLDBOUNDS);
}
}
public static class TestVincentySphere extends TestShapesGeo {
@Override
protected SpatialContext getContext() {
DistanceUnits units = DistanceUnits.KILOMETERS;
return new SimpleSpatialContext(units,
new GeodesicSphereDistCalc.Vincenty(units.earthRadius()),
SpatialContext.GEO_WORLDBOUNDS);
}
}
}