@Test public void testParameters() throws Exception { ParameterDescriptorGroup parameters = Mollweide.MollweideProvider.PARAMETERS; assertNotNull(parameters.descriptor(SEMI_MAJOR)); assertNotNull(parameters.descriptor(SEMI_MINOR)); assertNotNull(parameters.descriptor(FALSE_NORTHING)); assertNotNull(parameters.descriptor(FALSE_EASTING)); assertNotNull(parameters.descriptor(CENTRAL_MERIDIAN)); }
assertTrue("contains(p3)", content.contains(p3)); assertFalse("contains(p4)", content.contains(p4)); assertSame("descriptor(\"1\")", p1, descriptor.descriptor("1")); assertSame("descriptor(\"2\")", p2, descriptor.descriptor("2")); assertSame("descriptor(\"3\")", p3, descriptor.descriptor("3")); assertTrue("contains(p2)", content.contains(p2)); assertFalse("contains(p3)", content.contains(p3)); assertSame("descriptor(\"1\")", p1, descriptor.descriptor("1")); assertSame("descriptor(\"2\")", p2, descriptor.descriptor("2")); try { assertSame("p3", p3, descriptor.descriptor("3")); fail("p3 should not exists."); } catch (ParameterNotFoundException e) { assertFalse("contains(p2)", content.contains(p2)); assertTrue("contains(p3)", content.contains(p3)); assertSame("descriptor(\"1\")", p1, descriptor.descriptor("1")); assertSame("descriptor(\"3\")", p3, descriptor.descriptor("3")); try { assertSame("descriptor(\"2\")", p2, descriptor.descriptor("2")); fail("p2 should not exists"); } catch (ParameterNotFoundException e) {
/** * Ensures that ISO 19103 or GeoAPI restrictions apply, then checks for yet more restrictive * Geotk conditions. This method requires the exact same instance where GeoAPI requires only * instances that are {@linkplain Object#equals(Object) equal}. * * @param object The object to validate, or {@code null}. */ @Override public void validate(final ParameterDescriptorGroup object) { super.validate(object); if (object != null) { for (final GeneralParameterDescriptor descriptor : object.descriptors()) { assertSame("ParameterDescriptorGroup: descriptor(String) inconsistent with descriptors().", descriptor, object.descriptor(descriptor.getName().getCode())); } } }
((ParameterDescriptorGroup) descriptor).descriptor(name); if (!(check instanceof ParameterDescriptorGroup)) { throw new ParameterNotFoundException(
/** * Verifies some {@link Mercator1SP} parameter descriptors. */ @Test @DependsOnMethod("testEquirectangular") public void testMercator1SP() { final Iterator<GeneralParameterDescriptor> it = Mercator1SP.PARAMETERS.descriptors().iterator(); assertParamEquals("Mercator (variant A)", "Mercator_1SP", true, Mercator1SP.PARAMETERS); assertParamEquals(null, SEMI_MAJOR, true, it.next()); assertParamEquals(null, SEMI_MINOR, true, it.next()); assertParamEquals("Latitude of natural origin", LATITUDE_OF_ORIGIN, true, it.next()); assertParamEquals("Longitude of natural origin", CENTRAL_MERIDIAN, true, it.next()); assertParamEquals("Scale factor at natural origin", SCALE_FACTOR, true, it.next()); assertParamEquals("False easting", FALSE_EASTING, true, it.next()); assertParamEquals("False northing", FALSE_NORTHING, true, it.next()); assertFalse(it.hasNext()); assertIsForcedToZero((ParameterDescriptor<?>) Mercator1SP.PARAMETERS.descriptor(LATITUDE_OF_ORIGIN)); }
throws ParameterNotFoundException, InvalidParameterCardinalityException { final GeneralParameterDescriptor check = ((ParameterDescriptorGroup) descriptor).descriptor(name); if (!(check instanceof ParameterDescriptorGroup)) { throw new ParameterNotFoundException(
/** * Verifies some {@link Mercator2SP} parameter descriptors. */ @Test @DependsOnMethod("testMercator1SP") public void testMercator2SP() { final Iterator<GeneralParameterDescriptor> it = Mercator2SP.PARAMETERS.descriptors().iterator(); assertParamEquals("Mercator (variant B)", "Mercator_2SP", true, Mercator2SP.PARAMETERS); assertParamEquals(null, SEMI_MAJOR, true, it.next()); assertParamEquals(null, SEMI_MINOR, true, it.next()); assertParamEquals("Latitude of 1st standard parallel", STANDARD_PARALLEL_1, true, it.next()); assertParamEquals("Latitude of natural origin", LATITUDE_OF_ORIGIN, false, it.next()); assertParamEquals("Longitude of natural origin", CENTRAL_MERIDIAN, true, it.next()); assertParamEquals(null, SCALE_FACTOR, false, it.next()); assertParamEquals("False easting", FALSE_EASTING, true, it.next()); assertParamEquals("False northing", FALSE_NORTHING, true, it.next()); assertFalse(it.hasNext()); assertIsForcedToZero((ParameterDescriptor<?>) Mercator1SP.PARAMETERS.descriptor(LATITUDE_OF_ORIGIN)); }
/** * Returns the parameters of the given name declared in the given group. This method * is used for sharing the same parameter instance across different map projections. */ static ParameterDescriptor<?> sameParameterAs(final ParameterDescriptorGroup parameters, final String name) { return (ParameterDescriptor<?>) parameters.descriptor(name); }
/** * Verifies some parameters of {@link Equirectangular}. Note that {@code Equirectangular} is the first projection * to be loaded by {@link org.apache.sis.referencing.operation.transform.DefaultMathTransformFactory} and defines * some parameters which will be reused by other projections. * * <p><b>Note:</b> there is no test for {@code Equirectangular.createMathTransform(…)} in this class because * the math transforms are tested in the {@link org.apache.sis.referencing.operation.projection} package.</p> */ @Test @DependsOnMethod("testSemiAxes") public void testEquirectangular() { final Iterator<GeneralParameterDescriptor> it = Equirectangular.PARAMETERS.descriptors().iterator(); assertParamEquals("Equidistant Cylindrical (Spherical)", "Equirectangular", true, Equirectangular.PARAMETERS); assertParamEquals(null, SEMI_MAJOR, true, it.next()); assertParamEquals(null, SEMI_MINOR, true, it.next()); assertParamEquals("Latitude of 1st standard parallel", STANDARD_PARALLEL_1, true, it.next()); assertParamEquals("Latitude of natural origin", LATITUDE_OF_ORIGIN, false, it.next()); assertParamEquals("Longitude of natural origin", CENTRAL_MERIDIAN, true, it.next()); assertParamEquals("False easting", FALSE_EASTING, true, it.next()); assertParamEquals("False northing", FALSE_NORTHING, true, it.next()); assertFalse(it.hasNext()); assertIsForcedToZero((ParameterDescriptor<?>) Equirectangular.PARAMETERS.descriptor(LATITUDE_OF_ORIGIN)); }
search = group.getDescriptor().descriptor(name); if (search instanceof ParameterDescriptor) { for (final GeneralParameterValue candidate : group.values()) {
descriptor = copy.getDescriptor().descriptor(name); if (descriptor instanceof ParameterDescriptorGroup) { final ParameterValueGroup groups =
/** * Constructs a new map projection from the supplied parameters. * * @param parameters The parameters of the projection to be created. */ Spherical(final OperationMethod method, final Parameters parameters) { super(method, parameters); phi0 = toRadians(parameters.doubleValue((org.opengis.parameter.ParameterDescriptor) org.geotoolkit.referencing.operation.provider.Polyconic.PARAMETERS.descriptor("latitude_of_origin"))); }
/** * Returns all subgroups with the specified name. */ @Override public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException { ArgumentChecks.ensureNonNull("name", name); final List<ParameterValueGroup> groups = new ArrayList<>(4); for (final GeneralParameterValue value : values) { if (value instanceof ParameterValueGroup) { if (IdentifiedObjects.isHeuristicMatchForName(value.getDescriptor(), name)) { groups.add((ParameterValueGroup) value); } } } if (groups.isEmpty()) { if (!(descriptor.descriptor(name) instanceof ParameterDescriptorGroup)) { throw new ParameterNotFoundException(Resources.format(Resources.Keys.ParameterNotFound_2, Verifier.getDisplayName(descriptor), name), name); } } return groups; }
/** * Set the identifier parameter in the map if not present. */ static final Map<String,Serializable> forceIdentifier(DataStoreFactory factory, Map params){ if (!params.containsKey(DataStoreFactory.IDENTIFIER.getName().getCode())) { //identifier is not specified, force it final ParameterDescriptorGroup desc = factory.getOpenParameters(); params = new HashMap<String, Serializable>(params); final Object value = ((ParameterDescriptor)desc.descriptor(DataStoreFactory.IDENTIFIER.getName().getCode())).getDefaultValue(); params.put(DataStoreFactory.IDENTIFIER.getName().getCode(), (Serializable)value); } return params; } }
/** * Returns all subgroups with the specified name. */ @Override public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException { ArgumentChecks.ensureNonNull("name", name); final List<ParameterValueGroup> groups = new ArrayList<>(4); for (final GeneralParameterValue value : values) { if (value instanceof ParameterValueGroup) { if (IdentifiedObjects.isHeuristicMatchForName(value.getDescriptor(), name)) { groups.add((ParameterValueGroup) value); } } } if (groups.isEmpty()) { if (!(descriptor.descriptor(name) instanceof ParameterDescriptorGroup)) { throw new ParameterNotFoundException(Resources.format(Resources.Keys.ParameterNotFound_2, Verifier.getDisplayName(descriptor), name), name); } } return groups; }
final GeneralParameterDescriptor child = descriptor.descriptor(name); if (!(child instanceof ParameterDescriptorGroup)) { throw new ParameterNotFoundException(Resources.format(
/** * Check if the Identifier parameter exist. * if it exist, it must be set to 'value' otherwise return false. * if not present, return true; * @param params * @return */ protected boolean checkIdentifier(final ParameterValueGroup params){ final String expectedId; try{ expectedId = ((ParameterDescriptor<String>)getOpenParameters() .descriptor(IDENTIFIER.getName().getCode())).getDefaultValue(); }catch(ParameterNotFoundException ex){ //this feature store factory does not declare a identifier id return true; } for(GeneralParameterValue val : params.values()){ if(val.getDescriptor().getName().getCode().equals(IDENTIFIER.getName().getCode())){ final Object candidate = ((ParameterValue)val).getValue(); return expectedId.equals(candidate); } } return true; }
/** * Verify a parameter value. The descriptor is expected to be the same instance than the descriptors * defined in the {@link ParameterValueGroup} and in the {@link OperationMethod}. * * @param method the method of the enclosing operation. * @param group the group which contain the given parameter. * @param expectedValue the expected parameter value. * @param parameter the parameter to verify. */ private static void verifyParameter(final OperationMethod method, final ParameterValueGroup group, final double expectedValue, final ParameterValue<?> parameter) { final ParameterDescriptor<?> descriptor = parameter.getDescriptor(); final String name = descriptor.getName().getCode(); assertSame("parameterValues.descriptor", descriptor, group.getDescriptor().descriptor(name)); assertSame("method.descriptor", descriptor, method.getParameters().descriptor(name)); assertEquals("value", expectedValue, parameter.doubleValue(), STRICT); }
@Override public org.apache.sis.storage.DataStore open(StorageConnector connector) throws DataStoreException { GeneralParameterDescriptor desc; try { desc = getOpenParameters().descriptor(LOCATION); } catch (ParameterNotFoundException e) { throw new DataStoreException("Unsupported input"); } if (!(desc instanceof ParameterDescriptor)) { throw new DataStoreException("Unsupported input"); } try { final Object locationValue = connector.getStorageAs(((ParameterDescriptor)desc).getValueClass()); final ParameterValueGroup params = getOpenParameters().createValue(); params.parameter(LOCATION).setValue(locationValue); if (canProcess(params)) { return open(params); } } catch(IllegalArgumentException ex) { throw new DataStoreException("Unsupported input:" + ex.getMessage()); } throw new DataStoreException("Unsupported input"); }
/** * Ensures that ISO 19103 or GeoAPI restrictions apply, then checks for yet more restrictive * Geotk conditions. This method requires the exact same instance where GeoAPI requires only * instances that are {@linkplain Object#equals(Object) equal}. * * @param object The object to validate, or {@code null}. */ @Override public void validate(final ParameterValueGroup object) { super.validate(object); if (object != null) { final ParameterDescriptorGroup descriptors = object.getDescriptor(); for (final GeneralParameterValue value : object.values()) { final GeneralParameterDescriptor descriptor = value.getDescriptor(); final String name = descriptor.getName().getCode(); assertSame("ParameterValueGroup: descriptor(String) inconsistent with value.getDescriptor().", descriptor, descriptors.descriptor(name)); if (value instanceof ParameterValue<?>) { assertSame("ParameterValueGroup: value(String) inconsistent with values().", value, object.parameter(name)); } } } } }