public bool equals(LngBounds LngBounds) { return this.isEmpty () ? LngBounds.isEmpty () : (Math.Abs (LngBounds.getSw () - this._swLng) % 360.0f + Math.Abs (LngBounds.getNe () - this._neLng) % 360.0f) <= SphericalGeometry.EQUALS_MARGIN_ERROR; }
public bool intersects(LngBounds LngBounds) { if (this.isEmpty() || LngBounds.isEmpty()) { return false; } else if (this._swLng > this._neLng) { return LngBounds.getSw() > LngBounds.getNe() || LngBounds.getSw() <= this._neLng || LngBounds.getNe() >= this._swLng; } else if (LngBounds.getSw() > LngBounds.getNe()) { return LngBounds.getSw() <= this._neLng || LngBounds.getNe() >= this._swLng; } else { return LngBounds.getSw() <= this._neLng && LngBounds.getNe() >= this._swLng; } }
/** * LatLngSw South West LatLng object * LatLngNe North East LatLng object */ public LatLngBounds(LatLng LatLngSw = null, LatLng LatLngNe = null) { if (LatLngSw != null) { LatLngNe = (LatLngNe!=null) ? LatLngSw : LatLngNe; double sw = SphericalGeometry.clampLatitude(LatLngSw.Lat); double ne = SphericalGeometry.clampLatitude(LatLngNe.Lat); this._LatBounds = new LatBounds(sw, ne); sw = LatLngSw.Lng; ne = LatLngNe.Lng; if (360 <= ne - sw) { this._LngBounds = new LngBounds(-180, 180); } else { sw = SphericalGeometry.wrapLongitude(sw); ne = SphericalGeometry.wrapLongitude(ne); this._LngBounds = new LngBounds(sw, ne); } } else { this._LatBounds = new LatBounds(1, -1); this._LngBounds = new LngBounds(180, -180); } }