/** * Returns the result of {@link #nearlyEquals(LatLonPoint, double)}, with {@link Misc#defaultMaxRelativeDiffDouble}. */ default boolean nearlyEquals(LatLonPoint that) { return nearlyEquals(that, Misc.defaultMaxRelativeDiffDouble); }
public static boolean equals(EarthLocation loc1, EarthLocation loc2) { if (loc1 == loc2) { return true; } else if (loc1 == null || loc2 == null) { return false; } if (!loc1.getLatLon().nearlyEquals(loc2.getLatLon(), 1.0e-8)) { return false; } else if (!Misc.nearlyEquals(loc1.getAltitude(), loc2.getAltitude(), 1.0e-8)) { return false; } else if (!Objects.deepEquals(loc1.isMissing(), loc2.isMissing())) { return false; } return true; }
private void testCoordinates(String filename, double startLat, double startLon, double endLat, double endLon) throws IOException, InvalidRangeException { System.out.printf("%n***Open %s%n", filename); NetcdfDataset ncd = NetcdfDataset.openDataset(filename); GridDataset gds = new GridDataset(ncd); GridCoordSystem gsys = null; ProjectionImpl p = null; for (ucar.nc2.dt.GridDataset.Gridset g : gds.getGridsets()) { gsys = g.getGeoCoordSystem(); for (CoordinateTransform t : gsys.getCoordinateTransforms()) { if (t instanceof ProjectionCT) { p = ((ProjectionCT)t).getProjection(); break; } } } assert p != null; CoordinateAxis1D xaxis = (CoordinateAxis1D) gsys.getXHorizAxis(); CoordinateAxis1D yaxis = (CoordinateAxis1D) gsys.getYHorizAxis(); p.projToLatLon(xaxis.getCoordValue(0), yaxis.getCoordValue(0) ); LatLonPoint start1 = p.projToLatLon(xaxis.getCoordValue(0), yaxis.getCoordValue(0)); LatLonPoint start2 = p.projToLatLon(xaxis.getCoordValue((int)xaxis.getSize()-1), yaxis.getCoordValue((int)yaxis.getSize()-1)); System.out.printf( "start = %f %f%n", start1.getLatitude(), start1.getLongitude()); System.out.printf( "end = %f %f%n", start2.getLatitude(), start2.getLongitude()); assert start1.nearlyEquals(new LatLonPointImpl(startLat, startLon), 2.0E-4); assert start2.nearlyEquals(new LatLonPointImpl(endLat, endLon), 2.0E-4); ncd.close(); }
LatLonPoint p = new LatLonPointImpl(30.0, 30.0); b = testExtend(makeLatLonBoundingBox(10.0, 10.0), p); assert(p.nearlyEquals(b.getUpperRightPoint())); assert(p.nearlyEquals(b.getLowerLeftPoint())); assert(p.nearlyEquals(b.getUpperRightPoint())); assert ( b.crossDateline()); assert(p.nearlyEquals(b.getLowerLeftPoint())); assert ( !b.crossDateline()); assert(p.nearlyEquals(b.getLowerLeftPoint())); assert ( b.crossDateline()); assert(p.nearlyEquals(b.getUpperRightPoint())); assert ( b.crossDateline());