//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns the Distance from this <code>GeoPoint</code> to a * specified <code>GeoPoint</code>. * * @param pt the specified point to be measured * against this <code>GeoPoint</code> * @return the Distance between this <code>GeoPoint</code> and * the specified <code>GeoPoint</code>. */ public double Distance(GeoPoint pt) { double px = pt.GetX() - GetX(); double py = pt.GetY() - GetY(); return(MathEx.Sqrt(px * px + py * py)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns the square of the Distance from this * <code>GeoPoint</code> to a specified <code>GeoPoint</code>. * * @param pt the specified point to be measured * against this <code>GeoPoint</code> * @return the square of the Distance between this * <code>GeoPoint</code> to a specified <code>GeoPoint</code>. */ public double DistanceSq(GeoPoint pt) { double px = pt.GetX() - GetX(); double py = pt.GetY() - GetY(); return(px * px + py * py); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Determines whether or not two points are equal. Two instances of * <code>GeoPoint</code> are equal if the values of their * <code>X</code> and <code>Y</code> member fields, representing * their position in the coordinate space, are the same. * @param obj an object to be compared with this <code>GeoPoint</code> * @return <code>true</code> if the object to be compared is * an instance of <code>GeoPoint</code> and has * the same values; <code>false</code> otherwise. */ public new bool Equals(object obj) { if (obj is GeoPoint) { GeoPoint p2d = (GeoPoint)obj; return((GetX() == p2d.GetX()) && (GetY() == p2d.GetY())); } return(base.Equals(obj)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * check if this rectangle Contains given point. * @param p the point to be checked * @return true,it Contains given point. */ public bool Contains(GeoPoint p) { return Contains(p.GetX(), p.GetY()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Adds the <code>GeoPoint</code> object <code>pt</code> to this * <code>GeoBounds</code>. * The resulting <code>GeoBounds</code> is the smallest * <code>GeoBounds</code> that Contains both the original * <code>GeoBounds</code> and the specified <code>GeoPoint</code>. * <p> * After adding a point, a call to <code>Contains</code> with the * added point as an argument does not necessarily return * <code>true</code>. The <code>Contains</code> * method does not return <code>true</code> for points on the right * or bottom edges of a rectangle. Therefore, if the added point falls * on the left or bottom edge of the enlarged rectangle, * <code>Contains</code> returns <code>false</code> for that point. * @param pt the new <code>GeoPoint</code> to Add to this * <code>GeoBounds</code>. */ public void Add(GeoPoint pt) { Add(pt.GetX(), pt.GetY()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Sets the diagonal of the framing rectangle of this <code>IShape</code> * based on two specified <code>GeoPoint</code> objects. The framing * rectangle is used by the subclasses of <code>RectangularShape</code> * to define their geometry. * * @param p1 the start <code>GeoPoint</code> of the specified diagonal * @param p2 the end <code>GeoPoint</code> of the specified diagonal */ public void SetFrameFromDiagonal(GeoPoint p1, GeoPoint p2) { SetFrameFromDiagonal(p1.GetX(), p1.GetY(), p2.GetX(), p2.GetY()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Sets the framing rectangle of this <code>IShape</code> based on a * specified center <code>GeoPoint</code> and corner * <code>GeoPoint</code>. The framing rectangle is used by the subclasses * of <code>RectangularShape</code> to define their geometry. * @param center the specified center <code>GeoPoint</code> * @param corner the specified corner <code>GeoPoint</code> */ public void SetFrameFromCenter(GeoPoint center, GeoPoint corner) { SetFrameFromCenter(center.GetX(), center.GetY(), corner.GetX(), corner.GetY()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Sets the location and size of the framing rectangle of this * <code>IShape</code> to the specified {@link GeoPoint} and * {@link GeoSize}, respectively. The framing rectangle is used * by the subclasses of <code>RectangularShape</code> to define * their geometry. * @param loc the specified <code>GeoPoint</code> * @param size the specified <code>GeoSize</code> */ public void SetFrame(GeoPoint loc, GeoSize size) { SetFrame(loc.GetX(), loc.GetY(), size.GetWidth(), size.GetHeight()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Determines where the specified {@link GeoPoint} lies with * respect to this <code>GeoBounds</code>. * This method computes a binary OR of the appropriate mask values * indicating, for each side of this <code>GeoBounds</code>, * whether or not the specified <code>GeoPoint</code> is on the same * side of the edge as the rest of this <code>GeoBounds</code>. * @param p the specified <code>GeoPoint</code> * @return the logical OR of all appropriate out codes. */ public int Outcode(GeoPoint p) { return Outcode(p.GetX(), p.GetY()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Sets the location of this <code>GeoPoint</code> to the same * coordinates as the specified <code>GeoPoint</code> object. * @param p the specified <code>GeoPoint</code> to which to set * this <code>GeoPoint</code> */ public void SetLocation(GeoPoint p) { SetLocation(p.GetX(), p.GetY()); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns the square of the Distance from this * <code>GeoPoint</code> to a specified <code>GeoPoint</code>. * * @param pt the specified point to be measured * against this <code>GeoPoint</code> * @return the square of the Distance between this * <code>GeoPoint</code> to a specified <code>GeoPoint</code>. */ public double DistanceSq(GeoPoint pt) { double px = pt.GetX() - GetX(); double py = pt.GetY() - GetY(); return (px * px + py * py); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- REVISIONS ------------------------------ // Date Name Tracking # Description // --------- ------------------- ------------- ---------------------- // 18JUN2009 James Shen Initial Creation //////////////////////////////////////////////////////////////////////////// /** * Returns the Distance from this <code>GeoPoint</code> to a * specified <code>GeoPoint</code>. * * @param pt the specified point to be measured * against this <code>GeoPoint</code> * @return the Distance between this <code>GeoPoint</code> and * the specified <code>GeoPoint</code>. */ public double Distance(GeoPoint pt) { double px = pt.GetX() - GetX(); double py = pt.GetY() - GetY(); return MathEx.Sqrt(px * px + py * py); }