Search in sources :

Example 1 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class TensorValuesTest method testValues.

/**
 * Tests {@link TensorValues#values()}.
 */
@Test
@DependsOnMethod("testParameter")
public void testValues() {
    final ParameterValueGroup group = createWKT1();
    group.parameter(NUM_ROW).setValue(2);
    group.parameter(NUM_COL).setValue(3);
    List<GeneralParameterValue> values = group.values();
    assertValueEquals(NUM_ROW, 2, values.get(0));
    assertValueEquals(NUM_COL, 3, values.get(1));
    assertEquals("size", 2, values.size());
    /*
         * Above list had no explicit parameters, since all of them had their default values.
         * Now set some parameters to different values. Those parameters should now appear in
         * the list.
         */
    group.parameter("elt_0_1").setValue(8);
    group.parameter("elt_1_1").setValue(7);
    group.parameter("elt_1_2").setValue(6);
    values = group.values();
    assertValueEquals(NUM_ROW, 2, values.get(0));
    assertValueEquals(NUM_COL, 3, values.get(1));
    assertValueEquals("elt_0_1", 8.0, values.get(2));
    assertValueEquals("elt_1_1", 7.0, values.get(3));
    assertValueEquals("elt_1_2", 6.0, values.get(4));
    assertEquals("size", 5, values.size());
}
Also used : GeneralParameterValue(org.opengis.parameter.GeneralParameterValue) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 2 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class UnmodifiableParameterValueTest method testGetValue.

/**
 * Verifies that {@link UnmodifiableParameterValue#getValue()} can clone the value.
 */
@Test
@DependsOnMethod("testCreate")
public void testGetValue() {
    final ParameterValue<Date> modifiable = DefaultParameterDescriptorTest.createSimpleOptional("Time reference", Date.class).createValue();
    modifiable.setValue(date("1994-01-01 00:00:00"));
    /*
         * Create and validate an unmodifiable parameter,
         * then verify that the values are not the same.
         */
    final DefaultParameterValue<Date> unmodifiable = assertEquivalent(modifiable);
    final Date t1 = modifiable.getValue();
    final Date t2 = unmodifiable.getValue();
    assertNotSame("Date should be cloned.", t1, t2);
    assertEquals(t1, t2);
    /*
         * Verify that cloning the parameter also clone its value.
         */
    final DefaultParameterValue<Date> clone = unmodifiable.clone();
    assertEquals(DefaultParameterValue.class, clone.getClass());
    final Date t3 = clone.getValue();
    assertNotSame(t1, t3);
    assertNotSame(t2, t3);
    assertEquals(t1, t3);
}
Also used : Date(java.util.Date) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 3 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class AbstractIdentifiedObjectTest method testWithSingleIdentifier.

/**
 * Tests the {@link AbstractIdentifiedObject#AbstractIdentifiedObject(Map)} constructor
 * with only one identifier. The methods of interest for this test are:
 *
 * <ul>
 *   <li>{@link AbstractIdentifiedObject#getIdentifiers()}</li>
 *   <li>{@link AbstractIdentifiedObject#getIdentifier()}</li>
 *   <li>{@link AbstractIdentifiedObject#getID()}</li>
 * </ul>
 */
@Test
@DependsOnMethod("testWithoutIdentifier")
public void testWithSingleIdentifier() {
    final ReferenceIdentifier identifier = new ImmutableIdentifier(null, "EPSG", "7019");
    final Set<ReferenceIdentifier> identifiers = Collections.singleton(identifier);
    final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties(identifiers));
    final ReferenceIdentifier gmlId = validate(object, identifiers, "epsg-7019");
    assertNotNull("gmlId", gmlId);
    assertEquals("gmlId.codespace", "EPSG", gmlId.getCodeSpace());
    assertEquals("gmlId.code", "7019", gmlId.getCode());
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 4 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class AbstractReferenceSystemTest method testWKT.

/**
 * Tests WKT formatting with a name that contains the quote character and optional information.
 * We test that the closing quote character is doubled and the optional information properly formatted.
 */
@Test
@DependsOnMethod("testCreateFromMap")
public void testWKT() {
    final Map<String, Object> properties = new HashMap<>(8);
    assertNull(properties.put(NAME_KEY, "My “object”."));
    assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
    assertNull(properties.put(REMARKS_KEY, "注です。"));
    assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.EPSG, "EPSG", "4326", "8.2", null)));
    assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.", new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77), new DefaultVerticalExtent(10, 1000, VerticalCRSMock.DEPTH), // TODO: needs sis-temporal module for testing that one.
    new DefaultTemporalExtent())));
    final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
    assertTrue(object.toString(Convention.WKT1).startsWith("ReferenceSystem[\"My “object”.\", AUTHORITY[\"EPSG\", \"4326\"]]"));
    assertWktEquals(Convention.WKT1, "ReferenceSystem[“My \"object\".”, AUTHORITY[“EPSG”, “4326”]]", object);
    assertWktEquals(Convention.WKT2, // Quotes replaced
    "ReferenceSystem[“My \"object\".”,\n" + "  SCOPE[“Large scale topographic mapping and cadastre.”],\n" + "  AREA[“Netherlands offshore.”],\n" + "  BBOX[51.43, 2.54, 55.77, 6.40],\n" + "  VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1]],\n" + "  ID[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + "  REMARK[“注です。”]]", object);
    assertWktEquals(Convention.WKT2_SIMPLIFIED, "ReferenceSystem[“My \"object\".”,\n" + "  Scope[“Large scale topographic mapping and cadastre.”],\n" + "  Area[“Netherlands offshore.”],\n" + "  BBox[51.43, 2.54, 55.77, 6.40],\n" + "  VerticalExtent[-1000, -10],\n" + "  Id[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + "  Remark[“注です。”]]", object);
    assertWktEquals(Convention.INTERNAL, // Quote doubled
    "ReferenceSystem[“My “object””.”,\n" + "  Scope[“Large scale topographic mapping and cadastre.”],\n" + "  Area[“Netherlands offshore.”],\n" + "  BBox[51.43, 2.54, 55.77, 6.40],\n" + "  VerticalExtent[-1000, -10],\n" + "  Id[“EPSG”, 4326, “8.2”],\n" + "  Remark[“注です。”]]", object);
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) DefaultExtent(org.apache.sis.metadata.iso.extent.DefaultExtent) DefaultVerticalExtent(org.apache.sis.metadata.iso.extent.DefaultVerticalExtent) HashMap(java.util.HashMap) DefaultTemporalExtent(org.apache.sis.metadata.iso.extent.DefaultTemporalExtent) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 5 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class BuilderTest method testAddNameWithScope.

/**
 * Tests {@link Builder#addName(Citation, CharSequence)} and {@link Builder#addName(CharSequence)} with codespace.
 */
@Test
@DependsOnMethod({ "testAddName", "testSetCodeSpace" })
public void testAddNameWithScope() {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    // Expected values to be used later in the test.
    final String name = "Mercator (variant A)";
    final GenericName alias1 = factory.createLocalName(scope(factory, "EPSG"), "Mercator (1SP)");
    final GenericName alias2 = new NamedIdentifier(Citations.OGC, "Mercator_1SP");
    final GenericName alias3 = new NamedIdentifier(Citations.GEOTIFF, "CT_Mercator");
    assertTrue("That name should not have a scope.", alias3.scope().isGlobal());
    assertTrue("That name should not have a scope.", alias2.scope().isGlobal());
    assertFalse("That name should be in EPSG scope.", alias1.scope().isGlobal());
    assertEquals("EPSG", alias1.scope().name().toString());
    assertEquals("Mercator (1SP)", alias1.toString());
    assertEquals("OGC:Mercator_1SP", alias2.toString());
    assertEquals("GeoTIFF:CT_Mercator", alias3.toString());
    // The test.
    final BuilderMock builder = createMercator(true, false);
    assertEquals(name, builder.getName());
    assertArrayEquals(new GenericName[] { alias1, alias2, alias3 }, builder.getAliases());
}
Also used : GenericName(org.opengis.util.GenericName) NameFactory(org.opengis.util.NameFactory) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

DependsOnMethod (org.apache.sis.test.DependsOnMethod)298 Test (org.junit.Test)296 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)27 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)23 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)21 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)21 Rectangle (java.awt.Rectangle)19 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)19 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)18 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)15 Random (java.util.Random)11 Matrix (org.opengis.referencing.operation.Matrix)11 HashMap (java.util.HashMap)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)8 MathTransform (org.opengis.referencing.operation.MathTransform)8 DefaultFeatureType (org.apache.sis.feature.DefaultFeatureType)7 DefaultFeatureTypeTest (org.apache.sis.feature.DefaultFeatureTypeTest)7 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)7 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7