assert ct != null; return ct.getProjection();
/** Get the Projection for this coordinate system. * If isLatLon(), then returns a LatLonProjection. Otherwise, extracts the * projection from any ProjectionCT CoordinateTransform. * @return ProjectionImpl or null if none. */ public ProjectionImpl getProjection() { if (projection == null) { if (isLatLon()) projection = new LatLonProjection(); ProjectionCT projCT = getProjectionCT(); if (null != projCT) projection = projCT.getProjection(); } return projection; } private ProjectionImpl projection = null;
/** Get the Projection for this coordinate system. * If isLatLon(), then returns a LatLonProjection. Otherwise, extracts the * projection from any ProjectionCT CoordinateTransform. * @return ProjectionImpl or null if none. */ public ProjectionImpl getProjection() { if (projection == null) { if (isLatLon()) projection = new LatLonProjection(); ProjectionCT projCT = getProjectionCT(); if (null != projCT) projection = projCT.getProjection(); } return projection; } private ProjectionImpl projection = null;
/** Get the Projection for this coordinate system. * If isLatLon(), then returns a LatLonProjection. Otherwise, extracts the * projection from any ProjectionCT CoordinateTransform. * @return ProjectionImpl or null if none. */ public ProjectionImpl getProjection() { if (projection == null) { if (isLatLon()) projection = new LatLonProjection(); ProjectionCT projCT = getProjectionCT(); if (null != projCT) projection = projCT.getProjection(); } return projection; } private ProjectionImpl projection = null;
Projection proj = vct.getProjection(); assert proj != null; assert projClass.isInstance(proj) : proj.getClass().getName();
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(); }