@Override public boolean nearlyEquals(LatLonPoint that, double maxRelDiff) { boolean lonOk = Misc.nearlyEquals(that.getLongitude(), this.lon, maxRelDiff); if (!lonOk) { // We may be in a situation where "this.lon ≈ -180" and "that.lon ≈ +180", or vice versa. // Those longitudes are equivalent, but not "nearlyEquals()". So, we normalize them both to lie in // [0, 360] and compare them again. lonOk = Misc.nearlyEquals(lonNormal360(that.getLongitude()), lonNormal360(this.lon), maxRelDiff); } return lonOk && Misc.nearlyEquals(that.getLatitude(), this.lat, maxRelDiff); }
/** * Check for equality with another point. * * @param pt point to check * @return true if this represents the same point as pt */ public boolean equals(LatLonPoint pt) { boolean lonOk = closeEnough(pt.getLongitude(), this.lon); if (!lonOk) { lonOk = closeEnough(lonNormal360(pt.getLongitude()), lonNormal360(this.lon)); } return lonOk && closeEnough(pt.getLatitude(), this.lat); }
/** * Check for equality with another point. * * @param pt point to check * @return true if this represents the same point as pt */ public boolean equals(LatLonPoint pt) { boolean lonOk = closeEnough(pt.getLongitude(), this.lon); if (!lonOk) { lonOk = closeEnough(lonNormal360(pt.getLongitude()), lonNormal360(this.lon)); } return lonOk && closeEnough(pt.getLatitude(), this.lat); }
/** * Check for equality with another point. * * @param pt point to check * @return true if this represents the same point as pt */ public boolean equals(LatLonPoint pt) { boolean lonOk = closeEnough(pt.getLongitude(), this.lon); if (!lonOk) { lonOk = closeEnough(lonNormal360(pt.getLongitude()), lonNormal360(this.lon)); } return lonOk && closeEnough(pt.getLatitude(), this.lat); }
/** * Construct a lat/lon bounding box from two points. * The order of longitude coord of the two points matters: * pt1.lon is always the "left" point, then points contained within the box * increase (unless crossing the Dateline, in which case they jump to -180, but * then start increasing again) until pt2.lon * The order of lat doesnt matter: smaller will go to "lower" point (further south) * * @param left left corner * @param right right corner */ public LatLonRect(LatLonPoint left, LatLonPoint right) { this(left, right.getLatitude() - left.getLatitude(), LatLonPointImpl.lonNormal360(right.getLongitude() - left.getLongitude())); }
/** * Construct a lat/lon bounding box from two points. * The order of longitude coord of the two points matters: * pt1.lon is always the "left" point, then points contained within the box * increase (unless crossing the Dateline, in which case they jump to -180, but * then start increasing again) until pt2.lon * The order of lat doesnt matter: smaller will go to "lower" point (further south) * * @param left left corner * @param right right corner */ public LatLonRect(LatLonPoint left, LatLonPoint right) { this(left, right.getLatitude() - left.getLatitude(), LatLonPointImpl.lonNormal360(right.getLongitude() - left.getLongitude())); }
/** * Construct a lat/lon bounding box from two points. * The order of longitude coord of the two points matters: * pt1.lon is always the "left" point, then points contained within the box * increase (unless crossing the Dateline, in which case they jump to -180, but * then start increasing again) until pt2.lon * The order of lat doesnt matter: smaller will go to "lower" point (further south) * * @param left left corner * @param right right corner */ public LatLonRect(LatLonPoint left, LatLonPoint right) { this(left, right.getLatitude() - left.getLatitude(), LatLonPointImpl.lonNormal360(right.getLongitude() - left.getLongitude())); }
/** * Construct a lat/lon bounding box from two points. * The order of longitude coord of the two points matters: * pt1.lon is always the "left" point, then points contained within the box * increase (unless crossing the Dateline, in which case they jump to -180, but * then start increasing again) until pt2.lon * The order of lat doesnt matter: smaller will go to "lower" point (further south) * * @param left left corner * @param right right corner */ public LatLonRect(LatLonPoint left, LatLonPoint right) { this(left, right.getLatitude() - left.getLatitude(), LatLonPointImpl.lonNormal360(right.getLongitude() - left.getLongitude())); }