private List<LatLonPoint> calcLatLonBoundaryPointsFromProjection(int maxPointsInYEdge, int maxPointsInXEdge) { List<ProjectionPoint> projPoints = calcProjectionBoundaryPoints(maxPointsInYEdge, maxPointsInXEdge); List<LatLonPoint> latLonPoints = new LinkedList<>(); for (ProjectionPoint projPoint : projPoints) { latLonPoints.add(transform.getProjection().projToLatLon(projPoint)); } return latLonPoints; }
CdmrFeatureProto.CoordTransform.Builder encodeCoordTransform(CoverageTransform gct) { CdmrFeatureProto.CoordTransform.Builder builder = CdmrFeatureProto.CoordTransform.newBuilder(); builder.setIsHoriz(gct.isHoriz()); builder.setName(gct.getName()); for (Attribute att : gct.getAttributes()) builder.addParams(NcStream.encodeAtt(att)); return builder; }
@Override public String toString() { Formatter f = new Formatter(); Indent indent = new Indent(2); toString(f, indent); return f.toString(); }
private void addCoordTransforms(CoverageCollection subsetDataset, NetcdfFileWriter writer) { for (CoverageTransform ct : subsetDataset.getCoordTransforms()) { // scalar coordinate transform variable - container for transform info Variable ctv = writer.addVariable(null, ct.getName(), DataType.INT, ""); for (Attribute att : ct.getAttributes()) ctv.addAttribute(att); } }
public ProjectionImpl getProjection() { for (String ctName : getTransformNames()) { CoverageTransform ct = dataset.findCoordTransform(ctName); if (ct != null && ct.isHoriz()) return ct.getProjection(); } return new LatLonProjection(); }
CoverageTransform decodeCoordTransform(CdmrFeatureProto.CoordTransform proto) { String name = proto.getName(); AttributeContainerHelper atts = new AttributeContainerHelper(name); for (ucar.nc2.stream.NcStreamProto.Attribute patt : proto.getParamsList()) atts.addAttribute(NcStream.decodeAtt(patt)); // public CoverageCoordTransform(String name, AttributeContainerHelper attributes, boolean isHoriz) { return new CoverageTransform(name, atts, proto.getIsHoriz()); }
@Test public void testLatLonCoordTransformAddedToCollection() throws IOException { String filename = TestDir.cdmUnitTestDir + "gribCollections/gfs_2p5deg/GFS_Global_2p5deg_20150301_0000.grib2.ncx4"; try (FeatureDatasetCoverage featDsetCov = CoverageDatasetFactory.open(filename)) { Assert.assertEquals(1, featDsetCov.getCoverageCollections().size()); CoverageCollection covColl = featDsetCov.getCoverageCollections().get(0); Assert.assertEquals(1, covColl.getCoordTransforms().size()); CoverageTransform covTransform = covColl.getCoordTransforms().get(0); Assert.assertTrue(covTransform.getProjection() instanceof LatLonProjection); Attribute gridMappingNameAttrib = covTransform.findAttribute("grid_mapping_name"); Assert.assertNotNull("CoverageTransform didn't contain 'grid_mapping_name' attribute.", gridMappingNameAttrib); Assert.assertEquals("latitude_longitude", gridMappingNameAttrib.getStringValue()); } } }
public CoverageTransform findCoordTransform(String transformName) { for (CoverageTransform ct : transforms) if (ct.getName().equalsIgnoreCase(transformName)) return ct; return null; }
public void toString(Formatter f, Indent indent) { indent.incr(); f.format("%s CoordTransform '%s'", indent, name); f.format(" isHoriz: %s%n", isHoriz()); if (projection != null) f.format(" projection: %s%n", projection); for (Attribute att : attributes.getAttributes()) f.format("%s %s%n", indent, att); f.format("%n"); indent.decr(); }
String transform_name = gct.findAttValueIgnoreCase(CF.GRID_MAPPING_NAME, null); String units = gct.findAttValueIgnoreCase(CDM.UNITS, null); builder.setErrorBuffer( errInfo); ProjectionCT ct = builder.makeCoordinateTransform(gct, units);
for (Parameter p : group.getGdsHorizCoordSys().proj.getProjectionParameters()) projAtts.addAttribute(new Attribute(p)); CoverageTransform projTransform = new CoverageTransform(group.horizCoordSys.getId(), projAtts, true);
public CoverageTransform findCoordTransform(String name) { for (CoverageTransform ct : coordTransforms) if (ct.getName().equalsIgnoreCase(name)) return ct; return null; }
public CoverageTransform getHorizTransform() { for (String name : getTransformNames()) { CoverageTransform ct = dataset.findCoordTransform(name); if (ct != null && ct.isHoriz()) return ct; } return null; }
public LatLonPoint getLatLon(int yindex, int xindex) { if (isProjection) { double x = xAxis.getCoordMidpoint(xindex); double y = yAxis.getCoordMidpoint(xindex); ProjectionImpl proj = transform.getProjection(); return proj.projToLatLon(x, y); } else { double lat = latAxis.getCoordMidpoint(yindex); double lon = lonAxis.getCoordMidpoint(xindex); return new LatLonPointImpl(lat, lon); } }
private Element writeCoordTransform(CoverageTransform ct) { Element ctElem = new Element("coordTransform"); ctElem.setAttribute("name", ct.getName()); ctElem.setAttribute("transformType", ct.isHoriz() ? "Projection" : "Vertical"); for (Attribute param : ct.getAttributes()) { Element pElem = ncmlWriter.makeAttributeElement(param); pElem.setName("parameter"); ctElem.addContent(pElem); } return ctElem; }
private static CoverageTransform makeTransform(ucar.nc2.dataset.CoordinateTransform dt) { AttributeContainerHelper atts = new AttributeContainerHelper(dt.getName()); for (Parameter p : dt.getParameters()) atts.addAttribute(new Attribute(p)); return new CoverageTransform(dt.getName(), atts, dt.getTransformType() == TransformType.Projection); }
@Override public CoverageTransform findCoordTransform(String want) { for (CoverageTransform t : transforms) if (t.getName().equals(want)) return t; return null; }
public void toString(Formatter f) { Indent indent = new Indent(2); f.format("%sGridDatasetCoverage %s%n", indent, name); f.format("%s Global attributes:%n", indent); for (Attribute att : atts.getAttributes()) f.format("%s %s%n", indent, att); f.format("%s Date Range:%s%n", indent, calendarDateRange); f.format("%s LatLon BoundingBox:%s%n", indent, latLonBoundingBox); if (projBoundingBox != null) f.format("%s Projection BoundingBox:%s%n", indent, projBoundingBox); f.format("%n%s Coordinate Systems:%n", indent); for (CoverageCoordSys cs : coordSys) cs.toString(f, indent); f.format("%s Coordinate Transforms:%n", indent); for (CoverageTransform t : coordTransforms) t.toString(f, indent); f.format("%s Coordinate Axes:%n", indent); for (CoverageCoordAxis a : coordAxes) a.toString(f, indent); f.format("%n%s Grids:%n", indent); for (Coverage grid : getCoverages()) grid.toString(f, indent); }
Projection proj = horizCoordSys.getTransform().getProjection(); if (proj instanceof LatLonProjection) { // Projection is a "fake"; we already have lat/lon. return false;