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/02/20 23:45:37 UTC

svn commit: r1291499 [1/12] - in /lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/lucene/ src/main/java/org/apache/lucene/s...

Author: dsmiley
Date: Mon Feb 20 22:45:32 2012
New Revision: 1291499

URL: http://svn.apache.org/viewvc?rev=1291499&view=rev
Log:
Initial copy of https://lucene-spatial-playground.googlecode.com/svn/trunk/spatial-lucene

Added:
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/LICENSE.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/pom.xml
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/ParseUtils.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContext.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContextFactory.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContext.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContextFactory.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/AbstractDistanceCalculator.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/CartesianDistCalc.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceCalculator.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceUnits.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceUtils.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/GeodesicSphereDistCalc.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/package-info.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/exception/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/exception/InvalidShapeException.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/exception/InvalidSpatialArgument.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/exception/UnsupportedSpatialOperation.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/LineReader.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/geonames/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/geonames/Geoname.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/geonames/GeonamesReader.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/sample/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/sample/SampleData.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/io/sample/SampleDataReader.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/package-info.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/Node.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/SpatialPrefixTree.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/SpatialPrefixTreeFactory.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/geohash/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/geohash/GeohashPrefixTree.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/geohash/GeohashUtils.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/package-info.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/quad/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/prefix/quad/QuadPrefixTree.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/query/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/query/SpatialArgs.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/query/SpatialArgsParser.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/query/SpatialOperation.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/query/package-info.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/Circle.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/MultiShape.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/Point.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/Rectangle.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/Shape.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/SpatialRelation.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/simple/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/simple/CircleImpl.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/simple/GeoCircleImpl.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/simple/PointImpl.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/shape/simple/RectangleImpl.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/benchmark/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/benchmark/IndexShapeTask.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/benchmark/QueryShapeTask.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/benchmark/ShapeGenerator.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/benchmark/StrategyAware.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/SimpleSpatialFieldInfo.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/SpatialFieldInfo.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/SpatialStrategy.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/package-info.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/PointPrefixTreeFieldCacheProvider.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/PrefixCellsTokenizer.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/PrefixTreeStrategy.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/RecursivePrefixTreeFilter.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/RecursivePrefixTreeStrategy.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/TermQueryPrefixTreeStrategy.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/prefix/package-info.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/CachedDistanceValueSource.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/CachingDoubleValueSource.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/NumericFieldInfo.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/ShapeFieldCache.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/ShapeFieldCacheProvider.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/StringListTokenizer.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/TruncateFilter.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/util/ValueSourceFilter.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/vector/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/vector/DistanceValueSource.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/vector/TwoDoublesFieldInfo.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/strategy/vector/TwoDoublesStrategy.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/resources/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/RandomSeed.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/SpatialMatchConcern.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/SpatialTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/SpatialTestQuery.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/StrategyTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/TestTestFramework.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/context/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/context/BaseSpatialContextTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/context/SpatialContextFactoryTest.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/context/SpatialContextTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/distance/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/distance/TestDistances.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/prefix/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/prefix/SpatialPrefixTreeTest.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/prefix/TestGridMatchInfo.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/prefix/geohash/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/prefix/geohash/TestGeohashUtils.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/shape/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/shape/AbstractTestShapes.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/shape/TestShapes2D.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/base/shape/TestShapesGeo.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/prefix/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/prefix/BaseRecursivePrefixTreeStrategyTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/prefix/RecursivePrefixTreeStrategyTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/prefix/TestSpatialPrefixField.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/prefix/TestTermQueryPrefixGridStrategy.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/vector/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/vector/BaseTwoDoublesStrategyTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/java/org/apache/lucene/spatial/strategy/vector/TwoDoublesStrategyTestCase.java
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/cities-IsWithin-BBox.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/countries-bbox.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/countries-poly.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/geonames-IE.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/states-bbox.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/states-poly.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/data/world-cities-points.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/states-Intersects-BBox.txt
    lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/test/resources/states-IsWithin-BBox.txt

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/LICENSE.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/LICENSE.txt?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/LICENSE.txt (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/LICENSE.txt Mon Feb 20 22:45:32 2012
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/pom.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/pom.xml?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/pom.xml (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/pom.xml Mon Feb 20 22:45:32 2012
@@ -0,0 +1,105 @@
+<!--
+  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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <parent>
+    <artifactId>lucene-spatial-parent</artifactId>
+		<groupId>org.apache.lucene.spatial</groupId>
+		<version>0.1-SNAPSHOT</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+  
+	<groupId>org.apache.lucene.spatial</groupId>
+  <artifactId>spatial-lucene</artifactId>
+	<version>0.1-SNAPSHOT</version>
+	
+  <name>Spatial - Lucene</name>
+  <description>
+    lucene stuff
+  </description>
+  <packaging>jar</packaging>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.5</version>
+    </dependency>
+
+    <!-- LUCENE -->
+    <!--
+    We must put lucene-test-framework before lucene-core.
+    https://issues.apache.org/jira/browse/SOLR-3048
+    -->
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-test-framework</artifactId>
+      <version>${lucene.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-core</artifactId>
+      <version>${lucene.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-queries</artifactId>
+      <version>${lucene.version}</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-analyzers-common</artifactId>
+      <version>${lucene.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.lucene</groupId>
+      <artifactId>lucene-benchmark</artifactId>
+      <version>${lucene.version}</version>
+      <optional>true</optional>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.3.1</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      
+    </plugins>
+  </build>
+</project>

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/ParseUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/ParseUtils.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/ParseUtils.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/ParseUtils.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,157 @@
+/*
+ * 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.base.context;
+
+import org.apache.lucene.spatial.base.exception.InvalidShapeException;
+
+/**
+ * Utility methods related to parsing shapes.
+ * Methods here were formerly in DistanceUtils.
+ */
+public class ParseUtils {
+  private ParseUtils() {
+  }
+
+  /**
+   * Given a string containing <i>dimension</i> values encoded in it, separated by commas, return a String array of length <i>dimension</i>
+   * containing the values.
+   *
+   * @param out         A preallocated array.  Must be size dimension.  If it is not it will be resized.
+   * @param externalVal The value to parse
+   * @param dimension   The expected number of values for the point
+   * @return An array of the values that make up the point (aka vector)
+   * @throws org.apache.lucene.spatial.base.exception.InvalidShapeException if the dimension specified does not match the number of values in the externalValue.
+   */
+  public static String[] parsePoint(String[] out, String externalVal, int dimension) throws InvalidShapeException {
+    //TODO: Should we support sparse vectors?
+    if (out == null || out.length != dimension) out = new String[dimension];
+    int idx = externalVal.indexOf(',');
+    int end = idx;
+    int start = 0;
+    int i = 0;
+    if (idx == -1 && dimension == 1 && externalVal.length() > 0) {//we have a single point, dimension better be 1
+      out[0] = externalVal.trim();
+      i = 1;
+    } else if (idx > 0) {//if it is zero, that is an error
+      //Parse out a comma separated list of point values, as in: 73.5,89.2,7773.4
+      for (; i < dimension; i++) {
+        while (start < end && externalVal.charAt(start) == ' ') start++;
+        while (end > start && externalVal.charAt(end - 1) == ' ') end--;
+        if (start == end) {
+          break;
+        }
+        out[i] = externalVal.substring(start, end);
+        start = idx + 1;
+        end = externalVal.indexOf(',', start);
+        idx = end;
+        if (end == -1) {
+          end = externalVal.length();
+        }
+      }
+    }
+    if (i != dimension) {
+      throw new InvalidShapeException("incompatible dimension (" + dimension +
+              ") and values (" + externalVal + ").  Only " + i + " values specified");
+    }
+    return out;
+  }
+
+  /**
+   * Given a string containing <i>dimension</i> values encoded in it, separated by commas, return a double array of length <i>dimension</i>
+   * containing the values.
+   *
+   * @param out         A preallocated array.  Must be size dimension.  If it is not it will be resized.
+   * @param externalVal The value to parse
+   * @param dimension   The expected number of values for the point
+   * @return An array of the values that make up the point (aka vector)
+   * @throws org.apache.lucene.spatial.base.exception.InvalidShapeException if the dimension specified does not match the number of values in the externalValue.
+   */
+  public static double[] parsePointDouble(double[] out, String externalVal, int dimension) throws InvalidShapeException{
+    if (out == null || out.length != dimension) out = new double[dimension];
+    int idx = externalVal.indexOf(',');
+    int end = idx;
+    int start = 0;
+    int i = 0;
+    if (idx == -1 && dimension == 1 && externalVal.length() > 0) {//we have a single point, dimension better be 1
+      out[0] = Double.parseDouble(externalVal.trim());
+      i = 1;
+    } else if (idx > 0) {//if it is zero, that is an error
+      //Parse out a comma separated list of point values, as in: 73.5,89.2,7773.4
+      for (; i < dimension; i++) {
+        //TODO: abstract common code with other parsePoint
+        while (start < end && externalVal.charAt(start) == ' ') start++;
+        while (end > start && externalVal.charAt(end - 1) == ' ') end--;
+        if (start == end) {
+          break;
+        }
+        out[i] = Double.parseDouble(externalVal.substring(start, end));
+        start = idx + 1;
+        end = externalVal.indexOf(',', start);
+        idx = end;
+        if (end == -1) {
+          end = externalVal.length();
+        }
+      }
+    }
+    if (i != dimension) {
+      throw new InvalidShapeException("incompatible dimension (" + dimension +
+              ") and values (" + externalVal + ").  Only " + i + " values specified");
+    }
+    return out;
+  }
+
+  public static final double[] parseLatitudeLongitude(String latLonStr) throws InvalidShapeException {
+    return parseLatitudeLongitude(null, latLonStr);
+  }
+
+  /**
+   * extract (by calling {@link #parsePoint(String[], String, int)} and validate the latitude and longitude contained
+   * in the String by making sure the latitude is between 90 & -90 and longitude is between -180 and 180.
+   * <p/>
+   * The latitude is assumed to be the first part of the string and the longitude the second part.
+   *
+   * @param latLon    A preallocated array to hold the result
+   * @param latLonStr The string to parse.  Latitude is the first value, longitude is the second.
+   * @return The lat long
+   * @throws org.apache.lucene.spatial.base.exception.InvalidShapeException if there was an error parsing
+   */
+  public static final double[] parseLatitudeLongitude(double[] latLon, String latLonStr) throws InvalidShapeException {
+    if (latLon == null) {
+      latLon = new double[2];
+    }
+    double[] toks = parsePointDouble(null, latLonStr, 2);
+
+    if (toks[0] < -90.0 || toks[0] > 90.0) {
+      throw new InvalidShapeException(
+              "Invalid latitude: latitudes are range -90 to 90: provided lat: ["
+                      + toks[0] + "]");
+    }
+    latLon[0] = toks[0];
+
+
+    if (toks[1] < -180.0 || toks[1] > 180.0) {
+
+      throw new InvalidShapeException(
+              "Invalid longitude: longitudes are range -180 to 180: provided lon: ["
+                      + toks[1] + "]");
+    }
+    latLon[1] = toks[1];
+
+    return latLon;
+  }
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContext.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContext.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContext.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,249 @@
+/*
+ * 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.base.context;
+
+import org.apache.lucene.spatial.base.distance.*;
+import org.apache.lucene.spatial.base.exception.InvalidShapeException;
+import org.apache.lucene.spatial.base.shape.Circle;
+import org.apache.lucene.spatial.base.shape.Point;
+import org.apache.lucene.spatial.base.shape.Rectangle;
+import org.apache.lucene.spatial.base.shape.Shape;
+import org.apache.lucene.spatial.base.shape.simple.RectangleImpl;
+
+import java.text.NumberFormat;
+import java.util.Locale;
+import java.util.StringTokenizer;
+
+/**
+ * This holds things like distance units, distance calculator, and world bounds.
+ * Threadsafe & immutable.
+ */
+public abstract class SpatialContext {
+
+  //These are non-null
+  private final DistanceUnits units;
+  private final DistanceCalculator calculator;
+  private final Rectangle worldBounds;
+
+  public static RectangleImpl GEO_WORLDBOUNDS = new RectangleImpl(-180,180,-90,90);
+  public static RectangleImpl MAX_WORLDBOUNDS;
+  static {
+    double v = Double.MAX_VALUE;
+    MAX_WORLDBOUNDS = new RectangleImpl(-v, v, -v, v);
+  }
+  
+  protected final Double maxCircleDistance;//only for geo
+  protected final boolean NUDGE = false;//TODO document
+
+  /**
+   *
+   * @param units Required; and establishes geo vs cartesian.
+   * @param calculator Optional; defaults to Haversine or cartesian depending on units.
+   * @param worldBounds Optional; defaults to GEO_WORLDBOUNDS or MAX_WORLDBOUNDS depending on units.
+   */
+  protected SpatialContext(DistanceUnits units, DistanceCalculator calculator, Rectangle worldBounds) {
+    if (units == null)
+      throw new IllegalArgumentException("units can't be null");
+    this.units = units;
+
+    if (calculator == null) {
+      calculator = isGeo()
+          ? new GeodesicSphereDistCalc.Haversine(units.earthRadius())
+          : new CartesianDistCalc();
+    }
+    this.calculator = calculator;
+
+    if (worldBounds == null) {
+      worldBounds = isGeo() ? GEO_WORLDBOUNDS : MAX_WORLDBOUNDS;
+    } else {
+      if (isGeo())
+        assert new RectangleImpl(worldBounds).equals(GEO_WORLDBOUNDS);
+      if (worldBounds.getCrossesDateLine())
+        throw new IllegalArgumentException("worldBounds shouldn't cross dateline: "+worldBounds);
+    }
+    //copy so we can ensure we have the right implementation
+    worldBounds = makeRect(worldBounds.getMinX(),worldBounds.getMaxX(),worldBounds.getMinY(),worldBounds.getMaxY());
+    this.worldBounds = worldBounds;
+    
+    this.maxCircleDistance = isGeo() ? calculator.degreesToDistance(180) : null;
+  }
+
+  public DistanceUnits getUnits() {
+    return units;
+  }
+
+  public DistanceCalculator getDistCalc() {
+    return calculator;
+  }
+
+  public Rectangle getWorldBounds() {
+    return worldBounds;
+  }
+
+  public double normX(double x) {
+    if (isGeo()) {
+      return DistanceUtils.normLonDEG(x);
+    } else {
+      return x;
+    }
+  }
+
+  public double normY(double y) {
+    if (isGeo()) {
+      y = DistanceUtils.normLatDEG(y);
+    }
+    return y;
+  }
+
+  /**
+   * Is this a geospatial context (true) or simply 2d spatial (false)
+   * @return
+   */
+  public boolean isGeo() {
+    return getUnits().isGeo();
+  }
+
+  /**
+   * Read a shape from a given string (ie, X Y, XMin XMax... WKT)
+   *
+   * (1) Point: X Y
+   *   1.23 4.56
+   *
+   * (2) BOX: XMin YMin XMax YMax
+   *   1.23 4.56 7.87 4.56
+   *
+   * (3) WKT
+   *   POLYGON( ... )
+   *   http://en.wikipedia.org/wiki/Well-known_text
+   *
+   */
+  public abstract Shape readShape(String value) throws InvalidShapeException;
+
+  public Point readLatCommaLonPoint(String value) throws InvalidShapeException {
+    double[] latLon = ParseUtils.parseLatitudeLongitude(value);
+    return makePoint(latLon[1],latLon[0]);
+  }
+
+  public abstract String toString(Shape shape);
+
+  /** Construct a point. The parameters will be normalized. */
+  public abstract Point makePoint( double x, double y );
+
+  /** Construct a rectangle. The parameters will be normalized. */
+  public abstract Rectangle makeRect(double minX, double maxX, double minY, double maxY);
+
+  /** Construct a circle. The parameters will be normalized. */
+  public Circle makeCircle(double x, double y, double distance) {
+    return makeCircle(makePoint(x,y),distance);
+  }
+
+  /**
+   *
+   * @param ctr
+   * @param distance The units of "distance" should be the same as {@link #getUnits()}.
+   * @return
+   */
+  public abstract Circle makeCircle(Point ctr, double distance);
+
+  protected Shape readStandardShape(String str) {
+    if (str.length() < 1) {
+      throw new InvalidShapeException(str);
+    }
+
+    if(Character.isLetter(str.charAt(0))) {
+      if( str.startsWith( "Circle(" ) ) {
+        int idx = str.lastIndexOf( ')' );
+        if( idx > 0 ) {
+          String body = str.substring( "Circle(".length(), idx );
+          StringTokenizer st = new StringTokenizer(body, " ");
+          String token = st.nextToken();
+          Point pt;
+          if (token.indexOf(',') != -1) {
+            pt = readLatCommaLonPoint(token);
+          } else {
+            double x = Double.parseDouble(token);
+            double y = Double.parseDouble(st.nextToken());
+            pt = makePoint(x,y);
+          }
+          Double d = null;
+
+          String arg = st.nextToken();
+          idx = arg.indexOf( '=' );
+          if( idx > 0 ) {
+            String k = arg.substring( 0,idx );
+            if( k.equals( "d" ) || k.equals( "distance" ) ) {
+              d = Double.parseDouble( arg.substring(idx+1));
+            }
+            else {
+              throw new InvalidShapeException( "unknown arg: "+k+" :: " +str );
+            }
+          }
+          else {
+            d = Double.parseDouble(arg);
+          }
+          if( st.hasMoreTokens() ) {
+            throw new InvalidShapeException( "Extra arguments: "+st.nextToken()+" :: " +str );
+          }
+          if( d == null ) {
+            throw new InvalidShapeException( "Missing Distance: "+str );
+          }
+          //NOTE: we are assuming the units of 'd' is the same as that of the spatial context.
+          return makeCircle(pt, d);
+        }
+      }
+      return null;
+    }
+
+    if (str.indexOf(',') != -1)
+      return readLatCommaLonPoint(str);
+    StringTokenizer st = new StringTokenizer(str, " ");
+    double p0 = Double.parseDouble(st.nextToken());
+    double p1 = Double.parseDouble(st.nextToken());
+    if (st.hasMoreTokens()) {
+      double p2 = Double.parseDouble(st.nextToken());
+      double p3 = Double.parseDouble(st.nextToken());
+      if (st.hasMoreTokens())
+        throw new InvalidShapeException("Only 4 numbers supported (rect) but found more: "+str);
+      return makeRect(p0, p2, p1, p3);
+    }
+    return makePoint(p0, p1);
+  }
+
+  public String writeRect(Rectangle rect) {
+    NumberFormat nf = NumberFormat.getInstance(Locale.US);
+    nf.setGroupingUsed(false);
+    nf.setMaximumFractionDigits(6);
+    nf.setMinimumFractionDigits(6);
+
+    return
+      nf.format(rect.getMinX()) + " " +
+      nf.format(rect.getMinY()) + " " +
+      nf.format(rect.getMaxX()) + " " +
+      nf.format(rect.getMaxY());
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName()+"{" +
+        "units=" + units +
+        ", calculator=" + calculator +
+        ", worldBounds=" + worldBounds +
+        '}';
+  }
+
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContextFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContextFactory.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContextFactory.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/SpatialContextFactory.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,114 @@
+/*
+ * 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.base.context;
+
+import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContext;
+import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContextFactory;
+import org.apache.lucene.spatial.base.distance.*;
+import org.apache.lucene.spatial.base.shape.Rectangle;
+
+import java.util.Map;
+
+/**
+ * Factory for a SpatialContext.
+ * is 
+ * @author dsmiley
+ */
+public abstract class SpatialContextFactory {
+  protected Map<String, String> args;
+  protected ClassLoader classLoader;
+  
+  protected DistanceUnits units;
+  protected DistanceCalculator calculator;
+  protected Rectangle worldBounds;
+
+  /**
+   * The factory class is lookuped up via "spatialContextFactory" in args
+   * then falling back to a Java system property (with initial caps). If neither are specified
+   * then {@link SimpleSpatialContextFactory} is chosen.
+   * @param args
+   * @param classLoader
+   * @return
+   */
+  public static SpatialContext makeSpatialContext(Map<String,String> args, ClassLoader classLoader) {
+    SpatialContextFactory instance;
+    String cname = args.get("spatialContextFactory");
+    if (cname == null)
+      cname = System.getProperty("SpatialContextFactory");
+    if (cname == null)
+      instance = new SimpleSpatialContextFactory();
+    else {
+      try {
+        Class c = classLoader.loadClass(cname);
+        instance = (SpatialContextFactory) c.newInstance();
+      } catch (Exception e) {
+        throw new RuntimeException(e);
+      }
+    }
+    instance.init(args,classLoader);
+    return instance.newSpatialContext();
+  }
+
+  protected void init(Map<String, String> args, ClassLoader classLoader) {
+    this.args = args;
+    this.classLoader = classLoader;
+    initUnits();
+    initCalculator();
+    initWorldBounds();
+  }
+
+  protected void initUnits() {
+    String unitsStr = args.get("units");
+    if (unitsStr != null)
+      units = DistanceUnits.findDistanceUnit(unitsStr);
+    if (units == null)
+      units = DistanceUnits.KILOMETERS;
+  }
+
+  protected void initCalculator() {
+    String calcStr = args.get("distCalculator");
+    if (calcStr == null)
+      return;
+    if (calcStr.equalsIgnoreCase("haversine")) {
+      calculator = new GeodesicSphereDistCalc.Haversine(units.earthRadius());
+    } else if (calcStr.equalsIgnoreCase("lawOfCosines")) {
+      calculator = new GeodesicSphereDistCalc.LawOfCosines(units.earthRadius());
+    } else if (calcStr.equalsIgnoreCase("vincentySphere")) {
+      calculator = new GeodesicSphereDistCalc.Vincenty(units.earthRadius());
+    } else if (calcStr.equalsIgnoreCase("cartesian")) {
+      calculator = new CartesianDistCalc();
+    } else if (calcStr.equalsIgnoreCase("cartesian^2")) {
+      calculator = new CartesianDistCalc(true);
+    } else {
+      throw new RuntimeException("Unknown calculator: "+calcStr);
+    }
+  }
+
+  protected void initWorldBounds() {
+    String worldBoundsStr = args.get("worldBounds");
+    if (worldBoundsStr == null)
+      return;
+    //kinda ugly we do this just to read a rectangle.  TODO refactor
+    SimpleSpatialContext simpleCtx = new SimpleSpatialContext(units, calculator, null);
+    worldBounds = (Rectangle) simpleCtx.readShape(worldBoundsStr);
+  }
+
+  /** Subclasses should simply construct the instance from the initialized configuration. */
+  protected abstract SpatialContext newSpatialContext();
+
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContext.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContext.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContext.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContext.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,139 @@
+/*
+ * 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.base.context.simple;
+
+import org.apache.lucene.spatial.base.context.SpatialContext;
+import org.apache.lucene.spatial.base.distance.DistanceCalculator;
+import org.apache.lucene.spatial.base.distance.DistanceUnits;
+import org.apache.lucene.spatial.base.exception.InvalidShapeException;
+import org.apache.lucene.spatial.base.shape.Circle;
+import org.apache.lucene.spatial.base.shape.Point;
+import org.apache.lucene.spatial.base.shape.Rectangle;
+import org.apache.lucene.spatial.base.shape.Shape;
+import org.apache.lucene.spatial.base.shape.simple.CircleImpl;
+import org.apache.lucene.spatial.base.shape.simple.GeoCircleImpl;
+import org.apache.lucene.spatial.base.shape.simple.PointImpl;
+import org.apache.lucene.spatial.base.shape.simple.RectangleImpl;
+
+import java.text.NumberFormat;
+import java.util.Locale;
+
+public class SimpleSpatialContext extends SpatialContext {
+
+  public static SimpleSpatialContext GEO_KM = new SimpleSpatialContext(DistanceUnits.KILOMETERS);
+
+  public SimpleSpatialContext(DistanceUnits units) {
+    this(units, null, null);
+  }
+
+  public SimpleSpatialContext(DistanceUnits units, DistanceCalculator calculator, Rectangle worldBounds) {
+    super(units, calculator, worldBounds);
+  }
+
+  @Override
+  public Shape readShape(String value) throws InvalidShapeException {
+    Shape s = super.readStandardShape( value );
+    if( s == null ) {
+      throw new InvalidShapeException( "Unable to read: "+value );
+    }
+    return s;
+  }
+
+  @Override
+  public String toString(Shape shape) {
+    if (Point.class.isInstance(shape)) {
+      NumberFormat nf = NumberFormat.getInstance(Locale.US);
+      nf.setGroupingUsed(false);
+      nf.setMaximumFractionDigits(6);
+      nf.setMinimumFractionDigits(6);
+      Point point = (Point) shape;
+      return nf.format(point.getX()) + " " + nf.format(point.getY());
+    } else if (Rectangle.class.isInstance(shape)) {
+      return writeRect((Rectangle) shape);
+    }
+    return shape.toString();
+  }
+
+  @Override
+  public Circle makeCircle(Point point, double distance) {
+    if (distance < 0)
+      throw new InvalidShapeException("distance must be >= 0; got "+distance);
+    if (isGeo())
+      return new GeoCircleImpl( point, Math.min(distance,maxCircleDistance), this );
+    else
+      return new CircleImpl( point, distance, this );
+  }
+
+  @Override
+  public Rectangle makeRect(double minX, double maxX, double minY, double maxY) {
+    //--Normalize parameters
+    if (isGeo()) {
+      double delta = calcWidth(minX,maxX);
+      if (delta >= 360) {
+        //The only way to officially support complete longitude wrap-around is via western longitude = -180. We can't
+        // support any point because 0 is undifferentiated in sign.
+        minX = -180;
+        maxX = 180;
+      } else {
+        minX = normX(minX);
+        maxX = normX(maxX);
+        assert Math.abs(delta - calcWidth(minX,maxX)) < 0.0001;//recompute delta; should be the same
+      }
+      if (minY > maxY) {
+        throw new IllegalArgumentException("maxY must be >= minY");
+      }
+      if (minY < -90 || minY > 90 || maxY < -90 || maxY > 90)
+        throw new IllegalArgumentException("minY or maxY is outside of -90 to 90 bounds. What did you mean?");
+//      debatable what to do in this situation.
+//      if (minY < -90) {
+//        minX = -180;
+//        maxX = 180;
+//        maxY = Math.min(90,Math.max(maxY,-90 + (-90 - minY)));
+//        minY = -90;
+//      }
+//      if (maxY > 90) {
+//        minX = -180;
+//        maxX = 180;
+//        minY = Math.max(-90,Math.min(minY,90 - (maxY - 90)));
+//        maxY = 90;
+//      }
+
+    } else {
+      //these normalizations probably won't do anything since it's not geo but should probably call them any way.
+      minX = normX(minX);
+      maxX = normX(maxX);
+      minY = normY(minY);
+      maxY = normY(maxY);
+    }
+    return new RectangleImpl( minX, maxX, minY, maxY );
+  }
+
+  private double calcWidth(double minX,double maxX) {
+    double w = maxX - minX;
+    if (w < 0) {//only true when minX > maxX (WGS84 assumed)
+      w += 360;
+      assert w >= 0;
+    }
+    return w;
+  }
+
+  @Override
+  public Point makePoint(double x, double y) {
+    return new PointImpl(normX(x),normY(y));
+  }
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContextFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContextFactory.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContextFactory.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/context/simple/SimpleSpatialContextFactory.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,31 @@
+/*
+ * 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.base.context.simple;
+
+import org.apache.lucene.spatial.base.context.SpatialContext;
+import org.apache.lucene.spatial.base.context.SpatialContextFactory;
+
+/**
+* @author dsmiley
+*/
+public class SimpleSpatialContextFactory extends SpatialContextFactory {
+  @Override
+  protected SpatialContext newSpatialContext() {
+    return new SimpleSpatialContext(units,calculator,worldBounds);
+  }
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/AbstractDistanceCalculator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/AbstractDistanceCalculator.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/AbstractDistanceCalculator.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/AbstractDistanceCalculator.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,36 @@
+/*
+ * 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.base.distance;
+
+import org.apache.lucene.spatial.base.shape.Point;
+
+/**
+ * @author David Smiley - dsmiley@mitre.org
+ */
+public abstract class AbstractDistanceCalculator implements DistanceCalculator {
+
+  @Override
+  public double distance(Point from, Point to) {
+    return distance(from, to.getX(), to.getY());
+  }
+
+  @Override
+  public String toString() {
+    return getClass().getSimpleName();
+  }
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/CartesianDistCalc.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/CartesianDistCalc.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/CartesianDistCalc.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/CartesianDistCalc.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,98 @@
+/*
+ * 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.base.distance;
+
+import org.apache.lucene.spatial.base.context.SpatialContext;
+import org.apache.lucene.spatial.base.shape.Point;
+import org.apache.lucene.spatial.base.shape.Rectangle;
+
+public class CartesianDistCalc extends AbstractDistanceCalculator {
+
+  private final boolean squared;
+
+  public CartesianDistCalc() {
+    this.squared = false;
+  }
+
+  public CartesianDistCalc(boolean squared) {
+    this.squared = squared;
+  }
+
+  @Override
+  public double distance(Point from, double toX, double toY) {
+    double result = 0;
+
+    double v = from.getX() - toX;
+    result += (v * v);
+
+    v = from.getY() - toY;
+    result += (v * v);
+
+    if( squared )
+      return result;
+
+    return Math.sqrt(result);
+  }
+
+  @Override
+  public Point pointOnBearing(Point from, double dist, double bearingDEG, SpatialContext ctx) {
+    if (dist == 0)
+      return from;
+    double bearingRAD = Math.toDegrees(bearingDEG);
+    double x = Math.sin(bearingRAD) * dist;
+    double y = Math.cos(bearingRAD) * dist;
+    return ctx.makePoint(from.getX()+x, from.getY()+y);
+  }
+
+  @Override
+  public double distanceToDegrees(double distance) {
+    throw new UnsupportedOperationException("no geo!");
+  }
+
+  @Override
+  public double degreesToDistance(double degrees) {
+    throw new UnsupportedOperationException("no geo!");
+  }
+
+  @Override
+  public Rectangle calcBoxByDistFromPt(Point from, double distance, SpatialContext ctx) {
+    return ctx.makeRect(from.getX()-distance,from.getX()+distance,from.getY()-distance,from.getY()+distance);
+  }
+
+  @Override
+  public double calcBoxByDistFromPtHorizAxis(Point from, double distance, SpatialContext ctx) {
+    return from.getY();
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o) return true;
+    if (o == null || getClass() != o.getClass()) return false;
+
+    CartesianDistCalc that = (CartesianDistCalc) o;
+
+    if (squared != that.squared) return false;
+
+    return true;
+  }
+
+  @Override
+  public int hashCode() {
+    return (squared ? 1 : 0);
+  }
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceCalculator.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceCalculator.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceCalculator.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceCalculator.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,45 @@
+/*
+ * 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.base.distance;
+
+import org.apache.lucene.spatial.base.context.SpatialContext;
+import org.apache.lucene.spatial.base.shape.Point;
+import org.apache.lucene.spatial.base.shape.Rectangle;
+
+public interface DistanceCalculator {
+
+  public double distance(Point from, Point to);
+  public double distance(Point from, double toX, double toY);
+
+  public Point pointOnBearing(Point from, double dist, double bearingDEG, SpatialContext ctx);
+  
+  /**
+   * Converts a distance to radians (multiples of the radius). A spherical
+   * earth model is assumed for geospatial, and non-geospatial is the identity function.
+   */
+  public double distanceToDegrees(double distance);
+
+  public double degreesToDistance(double degrees);
+
+  //public Point pointOnBearing(Point from, double angle);
+
+  public Rectangle calcBoxByDistFromPt(Point from, double distance, SpatialContext ctx);
+
+  public double calcBoxByDistFromPtHorizAxis(Point from, double distance, SpatialContext ctx);
+
+}

Added: lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceUnits.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceUnits.java?rev=1291499&view=auto
==============================================================================
--- lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceUnits.java (added)
+++ lucene/dev/branches/lucene3795_lsp_spatial_module/modules/spatial-lucene/src/main/java/org/apache/lucene/spatial/base/distance/DistanceUnits.java Mon Feb 20 22:45:32 2012
@@ -0,0 +1,120 @@
+/*
+ * 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.base.distance;
+
+/**
+ * Enum representing difference distance units, currently only kilometers and
+ * miles
+ */
+public enum DistanceUnits {
+
+  //TODO do we need circumference?
+  KILOMETERS("km", DistanceUtils.EARTH_MEAN_RADIUS_KM, 40076),
+  MILES("miles", DistanceUtils.EARTH_MEAN_RADIUS_MI, 24902),
+  RADIANS("radians", 1, Math.PI * 2),//experimental
+  CARTESIAN("u", -1, -1);
+
+
+  private final String units;
+
+  private final double earthCircumference;
+
+  private final double earthRadius;
+
+  /**
+   * Creates a new DistanceUnit that represents the given unit
+   *
+   * @param units Distance unit in String form
+   * @param earthRadius Radius of the Earth in the specific distance unit
+   * @param earthCircumfence Circumference of the Earth in the specific distance unit
+   */
+  DistanceUnits(String units, double earthRadius, double earthCircumfence) {
+    this.units = units;
+    this.earthCircumference = earthCircumfence;
+    this.earthRadius = earthRadius;
+  }
+
+  /**
+   * Returns the DistanceUnit which represents the given unit
+   *
+   * @param unit Unit whose DistanceUnit should be found
+   * @return DistanceUnit representing the unit
+   * @throws IllegalArgumentException if no DistanceUnit which represents the given unit is found
+   */
+  public static DistanceUnits findDistanceUnit(String unit) {
+    if (MILES.getUnits().equalsIgnoreCase(unit) || unit.equalsIgnoreCase("mi")) {
+      return MILES;
+    }
+    if (KILOMETERS.getUnits().equalsIgnoreCase(unit)) {
+      return KILOMETERS;
+    }
+    if (CARTESIAN.getUnits().equalsIgnoreCase(unit) || unit.length()==0) {
+      return CARTESIAN;
+    }
+    throw new IllegalArgumentException("Unknown distance unit " + unit);
+  }
+
+  /**
+   * Converts the given distance in given DistanceUnit, to a distance in the unit represented by {@code this}
+   *
+   * @param distance Distance to convert
+   * @param from Unit to convert the distance from
+   * @return Given distance converted to the distance in the given unit
+   */
+  public double convert(double distance, DistanceUnits from) {
+    if (from == this) {
+      return distance;
+    }
+    if (this == CARTESIAN || from == CARTESIAN) {
+      throw new IllegalStateException("Can't convert cartesian distances: "+from+" -> "+this);
+    }
+    return (this == MILES) ? distance * DistanceUtils.KM_TO_MILES : distance * DistanceUtils.MILES_TO_KM;
+  }
+
+  /**
+   * Returns the string representation of the distance unit
+   *
+   * @return String representation of the distance unit
+   */
+  public String getUnits() {
+    return units;
+  }
+
+  /**
+   * Returns the <a href="http://en.wikipedia.org/wiki/Earth_radius">average earth radius</a>
+   *
+   * @return the average earth radius
+   */
+  public double earthRadius() {
+    return earthRadius;
+  }
+
+  /**
+   * Returns the <a href="http://www.lyberty.com/encyc/articles/earth.html">circumference of the Earth</a>
+   *
+   * @return  the circumference of the Earth
+   */
+  public double earthCircumference() {
+    return earthCircumference;
+  }
+  
+  public boolean isGeo() {
+    return earthRadius > 0;
+  }
+}
+