Index: contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Point2D.java
===================================================================
--- contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Point2D.java	(revision 812248)
+++ contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Point2D.java	Fri Dec 11 13:37:41 CET 2009
@@ -19,119 +19,43 @@
 
 
 /**
- * Point class.  This type is mutable.
+ * Class representing a point consisting simply of an x and y coordinate
  *
- * <p><font color="red"><b>NOTE:</b> This API is still in
- * flux and might change in incompatible ways in the next
- * release.</font>
+ * <p><font color="red"><b>NOTE:</b> This API is still in flux and might change in incompatible ways in the next release.</font>
  */
 public class Point2D {
-  private double x;
-  private double y;
 
+  private final double x;
+  private final double y;
+
+  /**
+   * Constructs a new point consisting of the given x and y coordinates
+   *
+   * @param x x coordinate of point
+   * @param y y coordinate of point
+   */
   public Point2D(double x, double y) {
-    this.x=x;
+    this.x = x;
-    this.y=y;
+    this.y = y;
   }
-  
+
-  public Point2D() {
-    this.x=0;
-    this.y=0;
-  }
+  // =============================================== Getters / Setters ===============================================
-  
+
-  public Point2D(Point2D other) {
-    this.x=other.x;
-    this.y=other.y;
-  }
-  
-  @Override
-  public String toString() {
-    return "(" + x + "," + y + ")";
-  }
-  
+  /**
+   * Returns the x coordinate
+   *
+   * @return x coordinate
+   */
   public double getX() {
     return x;
   }
-  
+
+  /**
+   * Returns the y coordinate
+   *
+   * @return y coordinate
+   */
   public double getY() {
     return y;
   }
-  
-  public double x() {
-    return x;
-  }
+}
-
-  public double y() {
-    return y;
-  }
-
-  public void x(double x) {
-    this.x=x;
-  }
-
-  public void y(double y) {
-    this.y=y;
-  }
-
-  public void setX(double x) {
-    this.x = x;
-  }
-  
-  public void setY(double y) {
-    this.y = y;
-  }
-  
-  public void set(double x, double y) {
-    this.x=x;
-    this.y=y;
-  }
-
-  public void add(Vector2D v) {
-    this.x+=v.getX();
-    this.y+=v.getY();
-  }
-
-  public void set(Point2D p1) {
-    this.x=p1.getX();
-    this.y=p1.getY();
-  }
-
-  public void add(Point2D a) {
-    this.x+=a.getX();
-    this.y+=a.getY();
-  }
-
-  public void set(Vector2D v) {
-    this.x=v.getX();
-    this.y=v.getY();
-  }
-  
-  @Override
-  public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    long temp;
-    temp = Double.doubleToLongBits(x);
-    result = prime * result + (int) (temp ^ (temp >>> 32));
-    temp = Double.doubleToLongBits(y);
-    result = prime * result + (int) (temp ^ (temp >>> 32));
-    return result;
-  }
-
-  @Override
-  public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (obj == null)
-      return false;
-    if (getClass() != obj.getClass())
-      return false;
-    Point2D other = (Point2D) obj;
-    if (Double.doubleToLongBits(x) != Double.doubleToLongBits(other.x))
-      return false;
-    if (Double.doubleToLongBits(y) != Double.doubleToLongBits(other.y))
-      return false;
-    return true;
-  }
-  
-}
Index: contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Ellipse.java
===================================================================
--- contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Ellipse.java	(revision 811070)
+++ contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Ellipse.java	(revision 811070)
@@ -1,234 +0,0 @@
-/**
- * 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.geometry.shape;
-
-
-/**
- * Ellipse shape. From C++ gl.
- *
- * <p><font color="red"><b>NOTE:</b> This API is still in
- * flux and might change in incompatible ways in the next
- * release.</font>
- */
-public class Ellipse implements Geometry2D {
-  private Point2D center;
-
-  /**
-   * Half length of major axis
-   */
-  private double a;
-
-  /**
-   * Half length of minor axis
-   */
-  private double b;
-
-  private double k1, k2, k3;
-
-  /**
-   * sin of rotation angle
-   */
-  private double s;
-
-  /**
-   * cos of rotation angle
-   */
-  private double c;
-
-  public Ellipse() {
-    center = new Point2D(0, 0);
-  }
-
-  private double SQR(double d) {
-    return d * d;
-  }
-
-  /**
-   * Constructor given bounding rectangle and a rotation.
-   */
-  public Ellipse(Point2D p1, Point2D p2, double angle) {
-    center = new Point2D();
-
-    // Set the center
-    center.x((p1.x() + p2.x()) * 0.5f);
-    center.y((p1.y() + p2.y()) * 0.5f);
-
-    // Find sin and cos of the angle
-    double angleRad = Math.toRadians(angle);
-    c = Math.cos(angleRad);
-    s = Math.sin(angleRad);
-
-    // Find the half lengths of the semi-major and semi-minor axes
-    double dx = Math.abs(p2.x() - p1.x()) * 0.5;
-    double dy = Math.abs(p2.y() - p1.y()) * 0.5;
-    if (dx >= dy) {
-      a = dx;
-      b = dy;
-    } else {
-      a = dy;
-      b = dx;
-    }
-
-    // Find k1, k2, k3 - define when a point x,y is on the ellipse
-    k1 = SQR(c / a) + SQR(s / b);
-    k2 = 2 * s * c * ((1 / SQR(a)) - (1 / SQR(b)));
-    k3 = SQR(s / a) + SQR(c / b);
-  }
-
-  /**
-   * Determines if a line segment intersects the ellipse and if so finds the
-   * point(s) of intersection.
-   * 
-   * @param seg
-   *            Line segment to test for intersection
-   * @param pt0
-   *            OUT - intersection point (if it exists)
-   * @param pt1
-   *            OUT - second intersection point (if it exists)
-   * 
-   * @return Returns the number of intersection points (0, 1, or 2).
-   */
-  public int intersect(LineSegment seg, Point2D pt0, Point2D pt1) {
-    if (pt0 == null)
-      pt0 = new Point2D();
-    if (pt1 == null)
-      pt1 = new Point2D();
-
-    // Solution is found by parameterizing the line segment and
-    // substituting those values into the ellipse equation.
-    // Results in a quadratic equation.
-    double x1 = center.x();
-    double y1 = center.y();
-    double u1 = seg.A.x();
-    double v1 = seg.A.y();
-    double u2 = seg.B.x();
-    double v2 = seg.B.y();
-    double dx = u2 - u1;
-    double dy = v2 - v1;
-    double q0 = k1 * SQR(u1 - x1) + k2 * (u1 - x1) * (v1 - y1) + k3
-        * SQR(v1 - y1) - 1;
-    double q1 = (2 * k1 * dx * (u1 - x1)) + (k2 * dx * (v1 - y1))
-        + (k2 * dy * (u1 - x1)) + (2 * k3 * dy * (v1 - y1));
-    double q2 = (k1 * SQR(dx)) + (k2 * dx * dy) + (k3 * SQR(dy));
-
-    // Compare q1^2 to 4*q0*q2 to see how quadratic solves
-    double d = SQR(q1) - (4 * q0 * q2);
-    if (d < 0) {
-      // Roots are complex valued. Line containing the segment does
-      // not intersect the ellipse
-      return 0;
-    }
-
-    if (d == 0) {
-      // One real-valued root - line is tangent to the ellipse
-      double t = -q1 / (2 * q2);
-      if (0 <= t && t <= 1) {
-        // Intersection occurs along line segment
-        pt0.x(u1 + t * dx);
-        pt0.y(v1 + t * dy);
-        return 1;
-      } else
-        return 0;
-    } else {
-      // Two distinct real-valued roots. Solve for the roots and see if
-      // they fall along the line segment
-      int n = 0;
-      double q = Math.sqrt(d);
-      double t = (-q1 - q) / (2 * q2);
-      if (0 <= t && t <= 1) {
-        // Intersection occurs along line segment
-        pt0.x(u1 + t * dx);
-        pt0.y(v1 + t * dy);
-        n++;
-      }
-
-      // 2nd root
-      t = (-q1 + q) / (2 * q2);
-      if (0 <= t && t <= 1) {
-        if (n == 0) {
-          pt0.x(u1 + t * dx);
-          pt0.y(v1 + t * dy);
-          n++;
-        } else {
-          pt1.x(u1 + t * dx);
-          pt1.y(v1 + t * dy);
-          n++;
-        }
-      }
-      return n;
-    }
-  }
-
-  public IntersectCase intersect(Rectangle r) {
-    // Test if all 4 corners of the rectangle are inside the ellipse
-    Point2D ul = new Point2D(r.MinPt().x(), r.MaxPt().y());
-    Point2D ur = new Point2D(r.MaxPt().x(), r.MaxPt().y());
-    Point2D ll = new Point2D(r.MinPt().x(), r.MinPt().y());
-    Point2D lr = new Point2D(r.MaxPt().x(), r.MinPt().y());
-    if (contains(ul) && contains(ur) && contains(ll) && contains(lr))
-      return IntersectCase.CONTAINS;
-
-    // Test if any of the rectangle edges intersect
-    Point2D pt0 = new Point2D(), pt1 = new Point2D();
-    LineSegment bottom = new LineSegment(ll, lr);
-    if (intersect(bottom, pt0, pt1) > 0)
-      return IntersectCase.INTERSECTS;
-
-    LineSegment top = new LineSegment(ul, ur);
-    if (intersect(top, pt0, pt1) > 0)
-      return IntersectCase.INTERSECTS;
-
-    LineSegment left = new LineSegment(ll, ul);
-    if (intersect(left, pt0, pt1) > 0)
-      return IntersectCase.INTERSECTS;
-
-    LineSegment right = new LineSegment(lr, ur);
-    if (intersect(right, pt0, pt1) > 0)
-      return IntersectCase.INTERSECTS;
-
-    // Ellipse does not intersect any edge : since the case for the ellipse
-    // containing the rectangle was considered above then if the center
-    // is inside the ellipse is fully inside and if center is outside
-    // the ellipse is fully outside
-    return (r.contains(center)) ? IntersectCase.WITHIN
-        : IntersectCase.OUTSIDE;
-  }
-
-  public double area() {
-    throw new UnsupportedOperationException();
-  }
-
-  public Point2D centroid() {
-    throw new UnsupportedOperationException();
-  }
-
-  public boolean contains(Point2D pt) {
-    // Plug in equation for ellipse, If evaluates to <= 0 then the
-    // point is in or on the ellipse.
-    double dx = pt.x() - center.x();
-    double dy = pt.y() - center.y();
-    double eq=(((k1 * SQR(dx)) + (k2 * dx * dy) + (k3 * SQR(dy)) - 1));
-    
-    return eq<=0;
-  }
-
-  public void translate(Vector2D v) {
-    throw new UnsupportedOperationException();
-  }
-
-}
Index: contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/LineSegment.java
===================================================================
--- contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/LineSegment.java	(revision 812248)
+++ contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/LineSegment.java	(revision 812248)
@@ -1,117 +0,0 @@
-/**
- * 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.geometry.shape;
-
-
-/**
- * 2d line segment.
- *
- * <p><font color="red"><b>NOTE:</b> This API is still in
- * flux and might change in incompatible ways in the next
- * release.</font>
- */
-public class LineSegment {
-  public final Point2D A = new Point2D();
-  public final Point2D B = new Point2D();
-
-  public LineSegment() {
-    A.set(0, 0);
-    B.set(0, 0);
-  }
-
-  public LineSegment(Point2D p1, Point2D p2) {
-    A.set(p1);
-    B.set(p2);
-  }
-
-  /**
-   * Finds the distance of a specified point from the line segment and the
-   * closest point on the segment to the specified point.
-   * 
-   * @param P
-   *            Test point.
-   * @param closestPt
-   *            (Return) Closest point on the segment to c.
-   * 
-   * @return Returns the distance from P to the closest point on the segment.
-   */
-  public double distance(Point2D P, Point2D /* out */closestPt) {
-    if (closestPt == null)
-      closestPt = new Point2D();
-
-    // Construct vector v (AB) and w (AP)
-    Vector2D v = new Vector2D(A, B);
-    Vector2D w = new Vector2D(A, P);
-
-    // Numerator of the component of w onto v. If <= 0 then A
-    // is the closest point. By separating into the numerator
-    // and denominator of the component we avoid a division unless
-    // it is necessary.
-    double n = w.dot(v);
-    if (n <= 0.0f) {
-      closestPt.set(A);
-      return w.norm();
-    }
-
-    // Get the denominator of the component. If the component >= 1
-    // (d <= n) then point B is the closest point
-    double d = v.dot(v);
-    if (d <= n) {
-      closestPt.set(B);
-      return new Vector2D(B, P).norm();
-    }
-
-    // Closest point is along the segment. The point is the projection of
-    // w onto v.
-    closestPt.set(v.mult(n / d));
-    closestPt.add(A);
-    return new Vector2D(closestPt, P).norm();
-  }
-
-  @Override
-  public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((A == null) ? 0 : A.hashCode());
-    result = prime * result + ((B == null) ? 0 : B.hashCode());
-    return result;
-  }
-
-  @Override
-  public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (obj == null)
-      return false;
-    if (getClass() != obj.getClass())
-      return false;
-    LineSegment other = (LineSegment) obj;
-    if (A == null) {
-      if (other.A != null)
-        return false;
-    } else if (!A.equals(other.A))
-      return false;
-    if (B == null) {
-      if (other.B != null)
-        return false;
-    } else if (!B.equals(other.B))
-      return false;
-    return true;
-  }
-  
-}
Index: contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Rectangle.java
===================================================================
--- contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Rectangle.java	(revision 812248)
+++ contrib/spatial/src/java/org/apache/lucene/spatial/geometry/shape/Rectangle.java	Fri Dec 11 13:35:45 CET 2009
@@ -17,75 +17,36 @@
 
 package org.apache.lucene.spatial.geometry.shape;
 
-
 /**
- * Rectangle shape.  
+ * Rectangle shape.
  *
- * <p><font color="red"><b>NOTE:</b> This API is still in
- * flux and might change in incompatible ways in the next
- * release.</font>
+ * <p><font color="red"><b>NOTE:</b> This API is still in flux and might change in incompatible ways in the next release.</font>
  */
-public class Rectangle implements Geometry2D {
-  private Point2D ptMin, ptMax;
+public class Rectangle {
-  
+
-  public Rectangle() {
-    ptMin=new Point2D(-1, 1);
-    ptMax=new Point2D(1, 1);
-  }
+  private Point2D ptMin;
+  private Point2D ptMax;
-  
+
-  public Rectangle(Point2D ptMin, Point2D ptMax) {
-    this.ptMin=new Point2D(ptMin);
-    this.ptMax=new Point2D(ptMax);
-  }
-  
   public Rectangle(double x1, double y1, double x2, double y2) {
-    set(x1, y1, x2, y2);
-  }
-
-  @Override
-  public String toString() {
-    return "[" + ptMin + "," + ptMax + "]";
-  }
-  
-  private void set(double x1, double y1, double x2, double y2) {
-    this.ptMin=new Point2D(Math.min(x1, x2), Math.min(y1, y2));
+    this.ptMin = new Point2D(Math.min(x1, x2), Math.min(y1, y2));
-    this.ptMax=new Point2D(Math.max(x1, x2), Math.max(y1, y2));
+    this.ptMax = new Point2D(Math.max(x1, x2), Math.max(y1, y2));
   }
-  
+
-  public double area() {
-    return (ptMax.getX() - ptMin.getX()) * (ptMax.getY() - ptMin.getY());
+  /**
+   * Determines whether the Rectangle contains the given point
+   *
+   * @param point Point to check if the rectangle contains it
+   * @return {@code true} if the Rectangle contains the point, {@code false} otherwise
+   */
+  public boolean contains(Point2D point) {
+    return point.getX() >= ptMin.getX() &&
+        point.getX() <= ptMax.getX() &&
+        point.getY() >= ptMin.getY() &&
+        point.getY() <= ptMax.getY();
   }
 
-  public Point2D centroid() {
-    return new Point2D( (ptMin.getX() + ptMax.getX()) / 2,
-                  (ptMin.getY() + ptMax.getY()) / 2);
-  }
+  // =============================================== Getters / Setters ===============================================
 
-  public boolean contains(Point2D p) {
-    return p.getX() >= ptMin.getX() && 
-      p.getX() <= ptMax.getX() &&
-      p.getY() >= ptMin.getY() &&
-      p.getY() <= ptMax.getY();
-  }
-
-  public void translate(Vector2D v) {
-    ptMin.add(v);
-    ptMax.add(v);
-  }
-
-  Point2D MinPt() {
-    return ptMin;
-  }
-
-  Point2D MaxPt() {
-    return ptMax;
-  }
-
-  public IntersectCase intersect(Rectangle r) {
-    throw new UnsupportedOperationException();
-    // TODO
-  }
-
   public Point2D getMaxPoint() {
     return ptMax;
   }
@@ -93,36 +54,5 @@
   public Point2D getMinPoint() {
     return ptMin;
   }
-
-  @Override
-  public int hashCode() {
-    final int prime = 31;
-    int result = 1;
-    result = prime * result + ((ptMax == null) ? 0 : ptMax.hashCode());
-    result = prime * result + ((ptMin == null) ? 0 : ptMin.hashCode());
-    return result;
-  }
+}
 
-  @Override
-  public boolean equals(Object obj) {
-    if (this == obj)
-      return true;
-    if (obj == null)
-      return false;
-    if (getClass() != obj.getClass())
-      return false;
-    Rectangle other = (Rectangle) obj;
-    if (ptMax == null) {
-      if (other.ptMax != null)
-        return false;
-    } else if (!ptMax.equals(other.ptMax))
-      return false;
-    if (ptMin == null) {
-      if (other.ptMin != null)
-        return false;
-    } else if (!ptMin.equals(other.ptMin))
-      return false;
-    return true;
-  }
-
-}
