Search in sources :

Example 36 with DependsOnMethod

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

the class TensorParametersTest method testMatrixConversion.

/**
 * Tests {@link TensorParameters#createValueGroup(Map, Matrix)} and its converse
 * {@link TensorParameters#toMatrix(ParameterValueGroup)}.
 */
@Test
@DependsOnMethod("testGetAllDescriptors")
public void testMatrixConversion() {
    final int size = StrictMath.min(6, TensorParameters.CACHE_SIZE);
    final Random random = TestUtilities.createRandomNumberGenerator();
    for (int numRow = 2; numRow <= size; numRow++) {
        for (int numCol = 2; numCol <= size; numCol++) {
            final Matrix matrix = Matrices.createZero(numRow, numCol);
            for (int j = 0; j < numRow; j++) {
                for (int i = 0; i < numCol; i++) {
                    matrix.setElement(j, i, 200 * random.nextDouble() - 100);
                }
            }
            final ParameterValueGroup group = param.createValueGroup(singletonMap(ParameterDescriptor.NAME_KEY, "Test"), matrix);
            assertEquals(NUM_ROW, numRow, group.parameter(NUM_ROW).intValue());
            assertEquals(NUM_COL, numCol, group.parameter(NUM_COL).intValue());
            assertEquals("elements", matrix, param.toMatrix(group));
            assertEquals("elements", matrix, param.toMatrix(new ParameterValueGroupWrapper(group)));
        }
    }
}
Also used : Matrix(org.opengis.referencing.operation.Matrix) Random(java.util.Random) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 37 with DependsOnMethod

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

the class CoordinateSystemsTest method testSwapAndScaleAxes.

/**
 * Tests {@link CoordinateSystems#swapAndScaleAxes(CoordinateSystem, CoordinateSystem)}
 * with a more arbitrary case, which include unit conversions.
 *
 * @throws IncommensurableException if a conversion between incompatible units was attempted.
 */
@Test
@DependsOnMethod("testSwapAndScaleAxes3D")
public void testSwapAndScaleAxes() throws IncommensurableException {
    final CoordinateSystem hxy = new DefaultCartesianCS(singletonMap(NAME_KEY, "(h,x,y)"), HardCodedAxes.HEIGHT_cm, HardCodedAxes.EASTING, HardCodedAxes.NORTHING);
    final CoordinateSystem yxh = new DefaultCartesianCS(singletonMap(NAME_KEY, "(y,x,h)"), HardCodedAxes.SOUTHING, HardCodedAxes.EASTING, HardCodedAxes.DEPTH);
    assertTrue(swapAndScaleAxes(hxy, hxy).isIdentity());
    assertTrue(swapAndScaleAxes(yxh, yxh).isIdentity());
    assertMatrixEquals("(h,x,y) → (y,x,h)", Matrices.create(4, 4, new double[] { 0, 0, -1, 0, 0, 1, 0, 0, -0.01, 0, 0, 0, 0, 0, 0, 1 }), swapAndScaleAxes(hxy, yxh), STRICT);
    assertMatrixEquals("(y,x,h) → (h,x,y)", Matrices.create(4, 4, new double[] { 0, 0, -100, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1 }), swapAndScaleAxes(yxh, hxy), STRICT);
}
Also used : CoordinateSystem(org.opengis.referencing.cs.CoordinateSystem) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 38 with DependsOnMethod

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

the class CoordinateSystemsTest method testScaleAndSwapAxesNonSquare.

/**
 * Tests {@link CoordinateSystems#swapAndScaleAxes(CoordinateSystem, CoordinateSystem)} with a non-square matrix.
 *
 * @throws IncommensurableException if a conversion between incompatible units was attempted.
 */
@Test
@DependsOnMethod("testSwapAndScaleAxes")
public void testScaleAndSwapAxesNonSquare() throws IncommensurableException {
    final DefaultCartesianCS cs = new DefaultCartesianCS(singletonMap(NAME_KEY, "Test"), new DefaultCoordinateSystemAxis(getProperties(HardCodedAxes.SOUTHING), "y", AxisDirection.SOUTH, Units.CENTIMETRE), new DefaultCoordinateSystemAxis(getProperties(HardCodedAxes.EASTING), "x", AxisDirection.EAST, Units.MILLIMETRE));
    Matrix matrix = swapAndScaleAxes(HardCodedCS.CARTESIAN_2D, cs);
    assertMatrixEquals("(x,y) → (y,x)", Matrices.create(3, 3, new double[] { 0, -100, 0, 1000, 0, 0, 0, 0, 1 }), matrix, STRICT);
    matrix = swapAndScaleAxes(HardCodedCS.CARTESIAN_3D, cs);
    assertMatrixEquals("(x,y,z) → (y,x)", Matrices.create(3, 4, new double[] { 0, -100, 0, 0, 1000, 0, 0, 0, 0, 0, 0, 1 }), matrix, STRICT);
}
Also used : Matrix(org.opengis.referencing.operation.Matrix) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 39 with DependsOnMethod

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

the class TreeTableFormatTest method testTreeTableParse.

/**
 * Tests the parsing of a tree table. This method parses and reformats a tree table,
 * and performs its check on the assumption that the tree table formatting is accurate.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
@DependsOnMethod("testTreeTableFormat")
public void testTreeTableParse() throws ParseException {
    final TableColumn<Integer> valueA = new TableColumn<>(Integer.class, "value #1");
    final TableColumn<String> valueB = new TableColumn<>(String.class, "value #2");
    final TreeTableFormat tf = new TreeTableFormat(null, null);
    tf.setColumns(NAME, valueA, valueB);
    tf.setVerticalLinePosition(1);
    final String text = "Node #1………………………… 10…… Value #1B\n" + " ├──Node #2……………… 20\n" + " │   └──Node #4…… 40…… Value #4B\n" + " └──Node #3……………… ………… Value #3B\n";
    final TreeTable table = tf.parseObject(text);
    assertMultilinesEquals(text, tf.format(table));
}
Also used : DefaultInternationalString(org.apache.sis.util.iso.DefaultInternationalString) TableColumn(org.apache.sis.util.collection.TableColumn) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 40 with DependsOnMethod

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

the class TreeTableFormatTest method testTreeParse.

/**
 * Tests the parsing of a tree. This method parses and reformats a tree,
 * and performs its check on the assumption that the tree formatting is
 * accurate.
 *
 * @throws ParseException if the parsing failed.
 */
@Test
@DependsOnMethod("testTreeFormat")
public void testTreeParse() throws ParseException {
    final TreeTableFormat tf = new TreeTableFormat(null, null);
    tf.setVerticalLinePosition(0);
    final String text = "Node #1\n" + "├───Node #2\n" + "│   └───Node #4\n" + "└───Node #3\n";
    final TreeTable table = tf.parseObject(text);
    assertMultilinesEquals(text, tf.format(table));
}
Also used : DefaultInternationalString(org.apache.sis.util.iso.DefaultInternationalString) 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