/** * Creates a new formula with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param formula the formula to copy. * * @see #castOrCopy(Formula) */ protected DefaultFormula(final Formula formula) { ensureNonNull("formula", formula); this.citation = formula.getCitation(); this.formula = formula.getFormula(); }
/** * Invoked by JAXB for marshalling the formula literally. In principle at most one of * {@code getFormulaDescription()} and {@link #getFormulaCitation()} methods can return * a non-null value. However SIS accepts both to coexist (but this is invalid GML). */ @XmlElement(name = "formula") private String getFormulaDescription() { final Formula formula = getFormula(); // Give to users a chance to override. return (formula != null) ? StringAdapter.toString(formula.getFormula()) : null; }
/** * Invoked by JAXB for marshalling a citation to the formula. In principle at most one of * {@code getFormulaCitation()} and {@link #getFormulaDescription()} methods can return a * non-null value. However SIS accepts both coexist (but this is invalid GML). */ @XmlElement(name = "formulaCitation") private Citation getFormulaCitation() { final Formula formula = getFormula(); // Give to users a chance to override. return (formula != null) ? formula.getCitation() : null; }
/** * Invoked by JAXB for marshalling the formula literally. In principle at most one of * {@code getFormulaDescription()} and {@link #getFormulaCitation()} methods can return * a non-null value. However SIS accepts both to coexist (but this is invalid GML). */ @XmlElement(name = "formula") private String getFormulaDescription() { final Formula formula = getFormula(); // Give to users a chance to override. return (formula != null) ? StringAdapter.toString(formula.getFormula()) : null; }
/** * Invoked by JAXB for marshalling a citation to the formula. In principle at most one of * {@code getFormulaCitation()} and {@link #getFormulaDescription()} methods can return a * non-null value. However SIS accepts both coexist (but this is invalid GML). */ @XmlElement(name = "formulaCitation") private Citation getFormulaCitation() { final Formula formula = getFormula(); // Give to users a chance to override. return (formula != null) ? formula.getCitation() : null; }
/** * Creates a new formula with the same values than the specified one. * This copy constructor provides a way to convert an arbitrary implementation into a SIS one * or a user-defined one (as a subclass), usually in order to leverage some implementation-specific API. * * <p>This constructor performs a shallow copy, i.e. the properties are not cloned.</p> * * @param formula the formula to copy. * * @see #castOrCopy(Formula) */ protected DefaultFormula(final Formula formula) { ensureNonNull("formula", formula); this.citation = formula.getCitation(); this.formula = formula.getFormula(); }
/** * Verifies the unmarshalled parameter descriptors. */ private static void verifyMethod(final OperationMethod method) { assertIdentifierEquals("name", null, null, null, "Mercator (1SP)", method.getName()); assertEquals("formula", "See EPSG guide.", method.getFormula().getFormula().toString()); assertEquals("sourceDimensions", Integer.valueOf(2), method.getSourceDimensions()); assertEquals("targetDimensions", Integer.valueOf(2), method.getTargetDimensions()); final ParameterDescriptorGroup parameters = method.getParameters(); assertEquals("parameters.name", "Mercator (1SP)", parameters.getName().getCode()); final Iterator<GeneralParameterDescriptor> it = parameters.descriptors().iterator(); CC_OperationParameterGroupTest.verifyMethodParameter(Mercator1SP.LATITUDE_OF_ORIGIN, (ParameterDescriptor<?>) it.next()); CC_OperationParameterGroupTest.verifyMethodParameter(Mercator1SP.LONGITUDE_OF_ORIGIN, (ParameterDescriptor<?>) it.next()); assertFalse("Unexpected parameter.", it.hasNext()); }
/** * Tests the {@link DefaultOperationMethod#DefaultOperationMethod(Map, Integer, Integer, ParameterDescriptorGroup)} * constructor. */ @Test public void testConstruction() { final OperationMethod method = create("Mercator (variant A)", "9804", "EPSG guidance note #7-2", 2); assertEpsgNameAndIdentifierEqual("Mercator (variant A)", 9804, method); assertTitleEquals("formula", "EPSG guidance note #7-2", method.getFormula().getCitation()); assertEquals("sourceDimensions", Integer.valueOf(2), method.getSourceDimensions()); assertEquals("targetDimensions", Integer.valueOf(2), method.getTargetDimensions()); }
/** * Validates the given formula. * * @param object The object to validate, or {@code null}. */ public void validate(final Formula object) { if (object == null) { return; } container.naming .validate(object.getFormula()); container.citation.validate(object.getCitation()); }
assertEquals ("method.name", "Longitude rotation", method.getName().getCode()); assertEquals ("method.identifier", "9601", getSingleton(method.getIdentifiers()).getCode()); assertEquals ("method.formula", "Target_longitude = Source_longitude + longitude_offset.", method.getFormula().getFormula().toString());
/** * Validates the given formula. * * @param object the object to validate, or {@code null}. */ public void validate(final Formula object) { if (object == null) { return; } container.validate(object.getFormula()); container.validate(object.getCitation()); }
/** * Invoked by JAXB for setting the citation to the formula. */ private void setFormulaCitation(final Citation citation) { if (formula == null || formula.getCitation() == null) { formula = (formula == null) ? new DefaultFormula(citation) : new DefaultFormula(formula.getFormula(), citation); } else { MetadataUtilities.propertyAlreadySet(DefaultOperationMethod.class, "setFormulaCitation", "formulaCitation"); } }
/** * Invoked by JAXB for setting the citation to the formula. */ private void setFormulaCitation(final Citation citation) { if (formula == null || formula.getCitation() == null) { formula = (formula == null) ? new DefaultFormula(citation) : new DefaultFormula(formula.getFormula(), citation); } else { MetadataUtilities.propertyAlreadySet(DefaultOperationMethod.class, "setFormulaCitation", "formulaCitation"); } }
/** * Invoked by JAXB for setting the formula description. */ private void setFormulaDescription(final String description) { if (formula == null || formula.getFormula() == null) { formula = (formula == null) ? new DefaultFormula(description) : new DefaultFormula(new SimpleInternationalString(description), formula.getCitation()); } else { MetadataUtilities.propertyAlreadySet(DefaultOperationMethod.class, "setFormulaDescription", "formula"); } }
/** * Invoked by JAXB for setting the formula description. */ private void setFormulaDescription(final String description) { if (formula == null || formula.getFormula() == null) { formula = (formula == null) ? new DefaultFormula(description) : new DefaultFormula(new SimpleInternationalString(description), formula.getCitation()); } else { MetadataUtilities.propertyAlreadySet(DefaultOperationMethod.class, "setFormulaDescription", "formula"); } }