/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
private Element makeCoordTransform( CoordinateTransform coordTransform) { Element elem = new Element("coordinateTransform", ncNS); elem.setAttribute("name", coordTransform.getName()); elem.setAttribute("authority", coordTransform.getAuthority()); if (coordTransform.getTransformType() != null) elem.setAttribute("transformType", coordTransform.getTransformType().toString()); List<Parameter> params = coordTransform.getParameters(); for (Parameter p : params) { elem.addContent(makeAttribute(p, "parameter")); } return elem; }
private Element makeCoordTransform( CoordinateTransform coordTransform) { Element elem = new Element("coordinateTransform", ncNS); elem.setAttribute("name", coordTransform.getName()); elem.setAttribute("authority", coordTransform.getAuthority()); if (coordTransform.getTransformType() != null) elem.setAttribute("transformType", coordTransform.getTransformType().toString()); List<Parameter> params = coordTransform.getParameters(); for (Parameter p : params) { elem.addContent(makeAttribute(p, "parameter")); } return elem; }
private Element makeCoordTransform( CoordinateTransform coordTransform) { Element elem = new Element("coordinateTransform", thredds.client.catalog.Catalog.ncmlNS); elem.setAttribute("name", coordTransform.getName()); elem.setAttribute("authority", coordTransform.getAuthority()); if (coordTransform.getTransformType() != null) elem.setAttribute("transformType", coordTransform.getTransformType().toString()); List<Parameter> params = coordTransform.getParameters(); for (Parameter p : params) { elem.addContent(makeAttribute(p, "parameter")); } return elem; }
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; }
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; }
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; }
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); }
@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"); } }
private Element writeCoordTransform(CoordinateTransform ct) { Element ctElem = new Element("coordTransform"); ctElem.setAttribute("name", ct.getName()); ctElem.setAttribute("transformType", ct.getTransformType().toString()); for (Parameter param : ct.getParameters()) { Element pElem = new Element("parameter"); pElem.setAttribute("name", param.getName()); pElem.setAttribute("value", param.getStringValue()); ctElem.addContent(pElem); } return ctElem; }
private Element writeCoordTransform(CoordinateTransform ct) { Element ctElem = new Element("coordTransform"); ctElem.setAttribute("name", ct.getName()); ctElem.setAttribute("transformType", ct.getTransformType().toString()); for (Parameter param : ct.getParameters()) { Element pElem = new Element("parameter"); pElem.setAttribute("name", param.getName()); pElem.setAttribute("value", param.getStringValue()); ctElem.addContent(pElem); } return ctElem; }
private Element writeCoordTransform(CoordinateTransform ct) { Element ctElem = new Element("coordTransform"); ctElem.setAttribute("name", ct.getName()); ctElem.setAttribute("transformType", ct.getTransformType().toString()); for (Parameter param : ct.getParameters()) { Element pElem = new Element("parameter"); pElem.setAttribute("name", param.getName()); pElem.setAttribute("value", param.getStringValue()); ctElem.addContent(pElem); } return ctElem; }
/** * Create a "dummy" Coordinate Transform Variable based on the given CoordinateTransform. * This creates a scalar Variable with dummy data, and adds the Parameters of the CoordinateTransform * as attributes. * @param ds for this dataset * @param ct based on the CoordinateTransform * @return the Coordinate Transform Variable. You must add it to the dataset. */ static public VariableDS makeDummyTransformVariable(NetcdfDataset ds, CoordinateTransform ct) { VariableDS v = new VariableDS( ds, null, null, ct.getName(), DataType.CHAR, "", null, null); List<Parameter> params = ct.getParameters(); for (Parameter p : params) { if (p.isString()) v.addAttribute(new Attribute(p.getName(), p.getStringValue())); else { double[] data = p.getNumericValues(); Array dataA = Array.factory(DataType.DOUBLE, new int[]{data.length}, data); v.addAttribute(new Attribute(p.getName(), dataA)); } } v.addAttribute( new Attribute(_Coordinate.TransformType, ct.getTransformType().toString())); // fake data Array data = Array.factory(DataType.CHAR, new int[] {}, new char[] {' '}); v.setCachedData(data, true); return v; }
/** * Create a "dummy" Coordinate Transform Variable based on the given CoordinateTransform. * This creates a scalar Variable with dummy data, and adds the Parameters of the CoordinateTransform * as attributes. * @param ds for this dataset * @param ct based on the CoordinateTransform * @return the Coordinate Transform Variable. You must add it to the dataset. */ static public VariableDS makeDummyTransformVariable(NetcdfDataset ds, CoordinateTransform ct) { VariableDS v = new VariableDS( ds, null, null, ct.getName(), DataType.CHAR, "", null, null); List<Parameter> params = ct.getParameters(); for (Parameter p : params) { if (p.isString()) v.addAttribute(new Attribute(p.getName(), p.getStringValue())); else { double[] data = p.getNumericValues(); Array dataA = Array.factory(double.class, new int[]{data.length}, data); v.addAttribute(new Attribute(p.getName(), dataA)); } } v.addAttribute( new Attribute(_Coordinate.TransformType, ct.getTransformType().toString())); // fake data Array data = Array.factory(DataType.CHAR.getPrimitiveClassType(), new int[] {}, new char[] {' '}); v.setCachedData(data, true); return v; }
/** * Create a "dummy" Coordinate Transform Variable based on the given CoordinateTransform. * This creates a scalar Variable with dummy data, and adds the Parameters of the CoordinateTransform * as attributes. * @param ds for this dataset * @param ct based on the CoordinateTransform * @return the Coordinate Transform Variable. You must add it to the dataset. */ static public VariableDS makeDummyTransformVariable(NetcdfDataset ds, CoordinateTransform ct) { VariableDS v = new VariableDS( ds, null, null, ct.getName(), DataType.CHAR, "", null, null); List<Parameter> params = ct.getParameters(); for (Parameter p : params) { if (p.isString()) v.addAttribute(new Attribute(p.getName(), p.getStringValue())); else { double[] data = p.getNumericValues(); Array dataA = Array.factory(double.class, new int[]{data.length}, data); v.addAttribute(new Attribute(p.getName(), dataA)); } } v.addAttribute( new Attribute(_Coordinate.TransformType, ct.getTransformType().toString())); // fake data Array data = Array.factory(DataType.CHAR.getPrimitiveClassType(), new int[] {}, new char[] {' '}); v.setCachedData(data, true); return v; }