Java Code Examples for org.opengis.parameter.GeneralParameterValue#getDescriptor()
The following examples show how to use
org.opengis.parameter.GeneralParameterValue#getDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParameterValueList.java From sis with Apache License 2.0 | 5 votes |
/** * Sets the parameter at the given index. The descriptor of the given parameter must be one of those * in the {@link DefaultParameterDescriptorGroup#descriptors()} list, and storing that parameter must * be allowed by the cardinality constraints. */ @Override public GeneralParameterValue set(final int index, final GeneralParameterValue parameter) { ArgumentChecks.ensureValidIndex(size, index); final GeneralParameterValue value = values[index]; ArgumentChecks.ensureNonNull("parameter", parameter); final GeneralParameterDescriptor desc = parameter.getDescriptor(); if (!value.getDescriptor().equals(desc)) { ensureDescriptorExists(desc); ensureCanRemove(desc); ensureCanAdd(desc); } values[index] = parameter; return value; }
Example 2
Source File: ParameterValueList.java From sis with Apache License 2.0 | 5 votes |
/** * Adds a {@link ParameterValue} or an other {@link ParameterValueGroup} to this list. * If an existing parameter is already included for the same name and adding the new * parameter would increase the number past what is allowable by {@code maximumOccurs}, * then an {@link InvalidParameterCardinalityException} will be thrown. * * @param parameter new parameter to be added to this group. * @return always {@code true} since this object changes as a result of this call. * @throws IllegalArgumentException if the specified parameter is not allowable by the groups descriptor. * @throws InvalidParameterCardinalityException if adding this parameter would result in more parameters * than allowed by {@code maximumOccurs}. */ @Override public boolean add(final GeneralParameterValue parameter) { ArgumentChecks.ensureNonNull("parameter", parameter); final GeneralParameterDescriptor desc = parameter.getDescriptor(); ensureDescriptorExists(desc); /* * If we had an uninitialized parameter (a parameter created by the DefaultParameterValueGroup constructor * and never been queried or set by the user), then the given parameter will replace the uninitialized. * The intent is to allow users to set its own parameters by a call to group.values().addAll(myParam). * Otherwise the given parameter will be added, in which case we need to check the cardinality. */ final Identifier name = desc.getName(); int count = 0; for (int i=0; i<size; i++) { final GeneralParameterValue value = values[i]; if (name.equals(value.getDescriptor().getName())) { if (value instanceof UninitializedParameter) { values[i] = parameter; return true; } count++; } } final int max = desc.getMaximumOccurs(); if (count >= max) { throw new InvalidParameterCardinalityException(Errors.format( Errors.Keys.TooManyOccurrences_2, max, name), name.getCode()); } addUnchecked(parameter); modCount++; return true; }
Example 3
Source File: DefaultProjectedCRS.java From sis with Apache License 2.0 | 4 votes |
/** Formats this {@code Conversion} element without the conversion name. */ void append(final Formatter formatter) { final Unit<Length> axisUnit = ellipsoid.getAxisUnit(); formatter.append(DefaultOperationMethod.castOrCopy(conversion.getMethod())); formatter.newLine(); for (final GeneralParameterValue param : conversion.getParameterValues().values()) { final GeneralParameterDescriptor desc = param.getDescriptor(); String name; if (IdentifiedObjects.isHeuristicMatchForName(desc, name = Constants.SEMI_MAJOR) || IdentifiedObjects.isHeuristicMatchForName(desc, name = Constants.SEMI_MINOR)) { /* * Do not format semi-major and semi-minor axis length in most cases, since those * information are provided in the ellipsoid. An exception to this rule occurs if * the lengths are different from the ones declared in the datum. */ if (param instanceof ParameterValue<?>) { final double value; try { value = ((ParameterValue<?>) param).doubleValue(axisUnit); } catch (IllegalStateException e) { /* * May happen if the 'conversionFromBase' parameter group does not provide values * for "semi_major" or "semi_minor" axis length. This should not happen with SIS * implementation, but may happen with user-defined map projection implementations. * Since the intent of this check was to skip those parameters anyway, it is okay * for the purpose of WKT formatting if there is no parameter for axis lengths. */ Logging.recoverableException(Logging.getLogger(Loggers.WKT), DefaultProjectedCRS.class, "formatTo", e); continue; } if (Double.isNaN(value)) { continue; } final double expected = (name == Constants.SEMI_MINOR) // using '==' is okay here. ? ellipsoid.getSemiMinorAxis() : ellipsoid.getSemiMajorAxis(); if (value == expected) { continue; } } } WKTUtilities.append(param, formatter); } }