/** * Returns a SIS formula implementation with the same values than the given arbitrary implementation. * If the given object is {@code null}, then this method returns {@code null}. * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object. * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultFormula castOrCopy(final Formula object) { return (object == null) || (object instanceof DefaultFormula) ? (DefaultFormula) object : new DefaultFormula(object); }
/** * Returns a SIS formula implementation with the same values than the given arbitrary implementation. * If the given object is {@code null}, then this method returns {@code null}. * Otherwise if the given object is already a SIS implementation, then the given object is returned unchanged. * Otherwise a new SIS implementation is created and initialized to the attribute values of the given object. * * @param object the object to get as a SIS implementation, or {@code null} if none. * @return a SIS implementation containing the values of the given object (may be the * given object itself), or {@code null} if the argument was null. */ public static DefaultFormula castOrCopy(final Formula object) { return (object == null) || (object instanceof DefaultFormula) ? (DefaultFormula) object : new DefaultFormula(object); }
/** * 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"); } }
formula = (Formula) value; } else if (value instanceof Citation) { formula = new DefaultFormula((Citation) value); } else if (value instanceof CharSequence) { formula = new DefaultFormula((CharSequence) value); } else { throw new IllegalArgumentException(Errors.getResources(properties)
formula = (Formula) value; } else if (value instanceof Citation) { formula = new DefaultFormula((Citation) value); } else if (value instanceof CharSequence) { formula = new DefaultFormula((CharSequence) value); } else { throw new IllegalArgumentException(Errors.getResources(properties)
/** * Tests {@link DefaultFormula#toWKT()}. */ @Test public void testWKT() { final DefaultFormula formula = new DefaultFormula("Mercator"); assertWktEquals(Convention.WKT2_SIMPLIFIED, "Formula[“Mercator”]", formula); assertWktEquals(Convention.WKT2, "FORMULA[“Mercator”]", formula); } }
/** * Creates the test operation method. */ private static DefaultOperationMethod createMercatorMethod() { final ParameterBuilder builder = new ParameterBuilder(); builder.setCodeSpace(EPSG, "EPSG").setRequired(true); ParameterDescriptor<?>[] parameters = { builder.addIdentifier("8801").addName("Latitude of natural origin" ).create(0, Units.DEGREE), builder.addIdentifier("8802").addName("Longitude of natural origin").create(0, Units.DEGREE) // There is more parameters for a Mercator projection, but 2 is enough for this test. }; builder.addName(null, "Mercator (1SP)"); final ParameterDescriptorGroup descriptor = builder.createGroup(parameters); final Map<String,Object> properties = new HashMap<>(4); properties.put(DefaultOperationMethod.NAME_KEY, descriptor.getName()); properties.put(DefaultOperationMethod.FORMULA_KEY, new DefaultFormula("See EPSG guide.")); return new DefaultOperationMethod(properties, 2, 2, descriptor); }