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); }
/** * Instances which have same name, authority and parameters are equal. */ public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof CoordinateTransform)) return false; CoordinateTransform o = (CoordinateTransform) oo; if (!getName().equals(o.getName())) return false; if (!getAuthority().equals(o.getAuthority())) return false; if (!(getTransformType() == o.getTransformType())) return false; List<Parameter> oparams = o.getParameters(); if (params.size() != oparams.size()) return false; for (int i = 0; i < params.size(); i++) { Parameter att = params.get(i); Parameter oatt = oparams.get(i); if (!att.getName().equals(oatt.getName())) return false; //if (!att.getValue().equals(oatt.getValue())) return false; } return true; }
/** * Override Object.hashCode() to be consistent with equals. */ public int hashCode() { if (hashCode == 0) { int result = 17; result = 37 * result + getName().hashCode(); result = 37 * result + getAuthority().hashCode(); result = 37 * result + getTransformType().hashCode(); for (Parameter att : params) { result = 37 * result + att.getName().hashCode(); //result = 37*result + att.getValue().hashCode(); } hashCode = result; } return hashCode; }
@Test public void testCF() throws IOException { try (GridDataset ds = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/cf/twoGridMaps.nc")) { GeoGrid grid = ds.findGridByName("altitude"); GridCoordSystem gcs = grid.getCoordinateSystem(); assert 1 == gcs.getCoordinateTransforms().size(); CoordinateTransform ct = gcs.getCoordinateTransforms().get(0); assert ct.getTransformType() == TransformType.Projection; assert ct.getName().equals("projection_stere"); } }
public int compareTo(Object o) { CoordinateTransform oct = (CoordinateTransform) o; return name.compareTo(oct.getName()); }
/** * Add a Parameter to a CoordinateTransform. * Make sure that the variable exists. If readData is true, read the data and use it as the value of the * parameter, otherwise use the variable name as the value of the parameter. * * @param rs the CoordinateTransform * @param paramName the parameter name * @param ds dataset * @param varNameEscaped escaped variable name * @return true if success, false is failed */ protected boolean addParameter(CoordinateTransform rs, String paramName, NetcdfFile ds, String varNameEscaped) { if (null == (ds.findVariable(varNameEscaped))) { if (null != errBuffer) errBuffer.format("CoordTransBuilder %s: no Variable named %s%n", getTransformName(), varNameEscaped); return false; } rs.addParameter(new Parameter(paramName, varNameEscaped)); return true; }
List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for(CoordinateTransform ct : cctt){ Parameter param = ct.findParameterIgnoreCase( CF.FORMULA_TERMS );
assert tList != null; for (CoordinateTransform ct : tList) { if (ct.getTransformType() == TransformType.Projection) pList.add(ct); assert ct.getTransformType() == TransformType.Projection; assert ct instanceof ProjectionCT;
Variable v = ncd.findVariable(ct.getName()); if (ct.getTransformType() == TransformType.Projection) newV.addAttribute(new Attribute(CF.GRID_MAPPING, v.getFullName()));
@Override public int compareTo(CoordinateTransform oct) { return name.compareTo(oct.getName()); }
/** * Override Object.hashCode() to be consistent with equals. */ public int hashCode() { if (hashCode == 0) { int result = 17; result = 37 * result + getName().hashCode(); result = 37 * result + getAuthority().hashCode(); result = 37 * result + getTransformType().hashCode(); for (Parameter att : params) { result = 37 * result + att.getName().hashCode(); //result = 37*result + att.getValue().hashCode(); } hashCode = result; } return hashCode; }
/** * Add a Parameter to a CoordinateTransform. * Make sure that the variable exists. If readData is true, read the data and use it as the value of the * parameter, otherwise use the variable name as the value of the parameter. * * @param rs the CoordinateTransform * @param paramName the parameter name * @param ds dataset * @param varNameEscaped escaped variable name * @return true if success, false is failed */ protected boolean addParameter(CoordinateTransform rs, String paramName, NetcdfFile ds, String varNameEscaped) { if (null == (ds.findVariable(varNameEscaped))) { if (null != errBuffer) errBuffer.format("CoordTransBuilder %s: no Variable named %s\n", getTransformName(), varNameEscaped); return false; } rs.addParameter(new Parameter(paramName, varNameEscaped)); return true; }
List<CoordinateTransform> cctt = grid.getCoordinateSystem().getCoordinateTransforms(); for (CoordinateTransform ct : cctt) { Parameter param = ct.findParameterIgnoreCase(CF.FORMULA_TERMS);
if (ct.getTransformType() == TransformType.Vertical) vList.add(ct); assert ct.getTransformType() == TransformType.Vertical; assert ct instanceof VerticalCT;
private Element writeCoordTransform(CoordinateTransform ct) { Element ctElem = new Element("coordTransform"); ctElem.setAttribute("name", ct.getName()); ctElem.setAttribute("transformType", ct.getTransformType().toString()); List params = ct.getParameters(); for (int i = 0; i < params.size(); i++) { Parameter param = (Parameter) params.get(i); Element pElem = new Element("parameter"); pElem.setAttribute("name", param.getName()); pElem.setAttribute("value", param.getStringValue()); ctElem.addContent(pElem); } return ctElem; }
/** * Instances which have same name, authority and parameters are equal. */ public boolean equals(Object oo) { if (this == oo) return true; if (!(oo instanceof CoordinateTransform)) return false; CoordinateTransform o = (CoordinateTransform) oo; if (!getName().equals(o.getName())) return false; if (!getAuthority().equals(o.getAuthority())) return false; if (!(getTransformType() == o.getTransformType())) return false; List<Parameter> oparams = o.getParameters(); if (params.size() != oparams.size()) return false; for (int i = 0; i < params.size(); i++) { Parameter att = params.get(i); Parameter oatt = oparams.get(i); if (!att.getName().equals(oatt.getName())) return false; //if (!att.getValue().equals(oatt.getValue())) return false; } return true; }
Variable v = ncd.findVariable(ct.getName()); if (ct.getTransformType() == TransformType.Projection) newV.addAttribute(new Attribute(CF.GRID_MAPPING, v.getFullName()));
@Override public int compareTo(CoordinateTransform oct) { return name.compareTo(oct.getName()); }
/** * Override Object.hashCode() to be consistent with equals. */ public int hashCode() { if (hashCode == 0) { int result = 17; result = 37 * result + getName().hashCode(); result = 37 * result + getAuthority().hashCode(); result = 37 * result + getTransformType().hashCode(); for (Parameter att : params) { result = 37 * result + att.getName().hashCode(); //result = 37*result + att.getValue().hashCode(); } hashCode = result; } return hashCode; }
/** * Add a Parameter to a CoordinateTransform. * Make sure that the variable exists. If readData is true, read the data and use it as the value of the * parameter, otherwise use the variable name as the value of the parameter. * * @param rs the CoordinateTransform * @param paramName the parameter name * @param ds dataset * @param varNameEscaped escaped variable name * @return true if success, false is failed */ protected boolean addParameter(CoordinateTransform rs, String paramName, NetcdfFile ds, String varNameEscaped) { if (null == (ds.findVariable(varNameEscaped))) { if (null != errBuffer) errBuffer.format("CoordTransBuilder %s: no Variable named %s%n", getTransformName(), varNameEscaped); return false; } rs.addParameter(new Parameter(paramName, varNameEscaped)); return true; }