src/com/wherehoo/WHPolygon.java
/**
     * Calculates the geographical distance between this <tt>WHPolygon</tt> and a location described by <tt>origin</tt>.
     * @param origin some point on Earth
     * @return the geographical distance from this <tt>WHPolygon</tt> to <tt>origin</tt>, in meters.  
     *If <tt>origin</tt> lies within this <tt>WHPolygon</tt>, return 0.
     */
Calculates the geographical distance between this WHPolygon and a location described by origin.
@param origin some point on Earth
@return the geographical distance from this WHPolygon to origin, in meters.
If origin lies within this WHPolygon, return 0.
Calculates the geographical distance between this WHPolygon and a location described by origin . @param origin some point on Earth @return the geographical distance from this WHPolygon to origin in meters . If origin lies within this WHPolygon return 0 .
public double distance(Point2D.Double origin){
	if (coordinates.length == 1){
	    return WHGeo.distance(origin, coordinates[0]);
	} else {
	    if (this.contains(origin)){
		return 0;
	    }
	    else {
		double d=WHGeo.distance(origin, new Line2D.Double(coordinates[coordinates.length-1],coordinates[0]));
		double temp_d;
		for (int i=1;i<coordinates.length;i++){
		    temp_d=WHGeo.distance(origin, new Line2D.Double(coordinates[i-1],coordinates[i]));
		    if (temp_d<d)
			d=temp_d;
		}
		return d;
	    }
	}
    }
public double distance ( Point2D . Double origin ) { if ( coordinates . length == 1 ) { return WHGeo . distance ( origin , coordinates [ 0 ] ) ; } else { if ( this . contains ( origin ) ) { return 0 ; } else { double d = WHGeo . distance ( origin , new Line2D . Double ( coordinates [ coordinates . length - 1 ] , coordinates [ 0 ] ) ) ; double temp_d ; for ( int i = 1 ; i < coordinates . length ; i ++ ) { temp_d = WHGeo . distance ( origin , new Line2D . Double ( coordinates [ i - 1 ] , coordinates [ i ] ) ) ; if ( temp_d < d ) d = temp_d ; } return d ; } } }
Calculates the geographical distance between this <tt>WHPolygon</tt> and a location described by <tt>origin</tt>.
Calculates the geographical distance between this <tt > WHPolygon< / tt > and a location described by <tt > origin< / tt > .
//if this <tt>WHPolygon</tt> has one vertex => return the distance to that vertex
 //if origin inside this <tt>WHPolygon</tt> => return 0
 //System.out.println("contained");
 //find the distance by calculating the distance to all the sides and taking the minimum
 //System.out.println("temp_d: "+d);
 //System.out.println("temp_d: "+temp_d);
