Package org.opengis.referencing.operation

Examples of org.opengis.referencing.operation.Matrix


                translate = 0.0;
            } else {
                throw new IllegalStateException(Errors.format(ErrorKeys.ILLEGAL_ARGUMENT_$2,
                            "gridType", gridType));
            }
            final Matrix matrix = MatrixFactory.create(dimension + 1);
            for (int i=0; i<dimension; i++) {
                // NOTE: i is a dimension in the 'gridRange' space (source coordinates).
                //       j is a dimension in the 'userRange' space (target coordinates).
                int j = i;
                if (swapXY && j<=1) {
                    j = 1-j;
                }
                double scale = userRange.getSpan(j) / gridRange.getSpan(i);
                double offset;
                if (reverse==null || j>=reverse.length || !reverse[j]) {
                    offset = userRange.getMinimum(j);
                } else {
                    scale  = -scale;
                    offset = userRange.getMaximum(j);
                }
                offset -= scale * (gridRange.getLow(i) - translate);
                matrix.setElement(j, j,         0.0   );
                matrix.setElement(j, i,         scale );
                matrix.setElement(j, dimension, offset);
            }
            transform = ProjectiveTransform.create(matrix);
        }
        return transform;
    }
View Full Code Here


    /**
     * Gets the derivative of this function at a value.
     */
    public double derivative(final double value) throws TransformException {
        final DirectPosition1D p = new DirectPosition1D(value);
        final Matrix m = derivative(p);
        assert m.getNumRow()==1 && m.getNumCol()==1;
        return m.getElement(0,0);
    }
View Full Code Here

     * @return A matrix created from this group of parameters.
     */
    public Matrix getMatrix() {
        final int numRow = this.numRow.intValue();
        final int numCol = this.numCol.intValue();
        final Matrix matrix = MatrixFactory.create(numRow, numCol);
        if (matrixValues != null) {
            for (int j=0; j<numRow; j++) {
                final ParameterValue[] row = matrixValues[j];
                if (row != null) {
                    for (int i=0; i<numCol; i++) {
                        final ParameterValue element = row[i];
                        if (element != null) {
                            matrix.setElement(j, i, element.doubleValue());
                        }
                    }
                }
            }
        }
View Full Code Here

         */
        String code;
        CoordinateReferenceSystem crs0, crs1;
        CoordinateOperationFactory opFactory = ReferencingFactoryFinder.getCoordinateOperationFactory(null);
        MathTransform mt;
        Matrix matrix;
        /*
         * Tests a WGS84 geographic CRS (2D) with (NORTH, EAST) axis directions.
         * The factory should reorder the axis with no more operation than an axis swap.
         */
        code = "4326";
View Full Code Here

        final CoordinateReferenceSystem modified = CRS.decode("EPSG:4326", true );
        assertEquals("Expected a left-handed CS.",  -90, getAngle(standard), EPS);
        assertEquals("Expected a right-handed CS.", +90, getAngle(modified), EPS);
        final MathTransform transform = CRS.findMathTransform(standard, modified);
        assertTrue(transform instanceof LinearTransform);
        final Matrix matrix = ((LinearTransform) transform).getMatrix();
        assertEquals(new GeneralMatrix(new double[][] {
            { 010},
            { 100},
            { 001}}), new GeneralMatrix(matrix));
    }
View Full Code Here

        // Fallback on the general case (others implementations)
        final ParameterValue numRowParam = parameters.parameter(numRow.getName().toString());
        final ParameterValue numColParam = parameters.parameter(numCol.getName().toString());
        final int numRow = numRowParam.intValue();
        final int numCol = numColParam.intValue();
        final Matrix matrix = MatrixFactory.create(numRow, numCol);
        final List<GeneralParameterValue> params = parameters.values();
        if (params != null) {
            for (final GeneralParameterValue param : params) {
                if (param==numRowParam || param==numColParam) {
                    continue;
                }
                RuntimeException cause = null;
                final String name = param.getDescriptor().getName().toString();
                if (name.regionMatches(true, 0, prefix, 0, prefix.length())) {
                    final int split = name.indexOf(separator, prefix.length());
                    if (split >= 0) try {
                        final int row = Integer.parseInt(name.substring(prefix.length(), split));
                        final int col = Integer.parseInt(name.substring(split+1));
                        matrix.setElement(row, col, ((ParameterValue) param).doubleValue());
                        continue;
                    } catch (NumberFormatException exception) {
                        cause = exception;
                    } catch (IndexOutOfBoundsException exception) {
                        cause = exception;
View Full Code Here

        final int numPts = 200;
        for (int pass=0; pass<100; pass++) {
            final int     dimSource = random.nextInt(numDim)+1;
            final int     dimTarget = random.nextInt(numDim)+1;
            final int     dimInterm = random.nextInt(numDim)+1;
            final Matrix    matrix1 = getRandomMatrix(dimSource, dimInterm);
            final Matrix    matrix2 = getRandomMatrix(dimInterm, dimTarget);
            final MathTransform tr1 = factory.createAffineTransform(matrix1);
            final MathTransform tr2 = factory.createAffineTransform(matrix2);
            final double[] sourcePt = new double[dimSource * numPts];
            final double[] intermPt = new double[dimInterm * numPts];
            final double[] targetPt = new double[dimTarget * numPts];
 
View Full Code Here

     *
     * @param transform The transform to test.
     */
    private static void assertInterfaced(final MathTransform transform) {
        if (transform instanceof LinearTransform) {
            final Matrix matrix = ((LinearTransform) transform).getMatrix();
            if (!((XMatrix) matrix).isAffine()) {
                // Special case: Non-affine transforms not yet declared as a 1D or 2D transform.
                return;
            }
        }
View Full Code Here

            start("wcs:GridCRS");
            element("wcs:GridBaseCRS", urnIdentifier(ci.getCRS()));
            element("wcs:GridType", GridType.GT2dGridIn2dCrs.getXmlConstant());
            // TODO: go back to using the metadata once they can be trusted
            final LinearTransform tx = (LinearTransform) ci.getGrid().getGridToCRS();
            final Matrix matrix = tx.getMatrix();
            // origin
            StringBuffer origins = new StringBuffer();
            for (int i = 0; i < matrix.getNumRow() - 1; i++) {
                origins.append(matrix.getElement(i, matrix.getNumCol() - 1));
                if (i < matrix.getNumRow() - 2)
                    origins.append(" ");
            }
            element("wcs:GridOrigin", origins.toString());
            // offsets
            StringBuffer offsets = new StringBuffer();
            for (int i = 0; i < matrix.getNumRow() - 1; i++) {
                for (int j = 0; j < matrix.getNumCol() - 1; j++) {
                    offsets.append(matrix.getElement(i, j));
                    if (j < matrix.getNumCol() - 2)
                        offsets.append(" ");
                }
                if (i < matrix.getNumRow() - 2)
                    offsets.append(" ");

            }
            element("wcs:GridOffsets", offsets.toString());
            element("wcs:GridCS", "urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS");
View Full Code Here

          Errors.format(
              ErrorKeys.ILLEGAL_ARGUMENT_$2,
              "gridType",
              gridType));
    }
    final Matrix matrix = MatrixFactory.create(dimension + 1);
    final double[] minValuesPerDimension = fullBounds.getMinValuesPerDimension();
    final double[] maxValuesPerDimension = fullBounds.getMaxValuesPerDimension();
    for (int i = 0; i < dimension; i++) {
      // NOTE: i is a dimension in the 'gridRange' space (source
      // coordinates).
      // j is a dimension in the 'userRange' space (target coordinates).
      int j = i;
      if (swapXY && (j <= 1)) {
        j = 1 - j;
      }
      double scale = idRangePerDimension[j];
      double offset;
      if ((reverse == null) || (j >= reverse.length) || !reverse[j]) {
        offset = minValuesPerDimension[j];
      }
      else {
        scale = -scale;
        offset = maxValuesPerDimension[j];
      }
      offset -= scale * (-translate);
      matrix.setElement(
          j,
          j,
          0.0);
      matrix.setElement(
          j,
          i,
          scale);
      matrix.setElement(
          j,
          dimension,
          offset);
    }
    return ProjectiveTransform.create(matrix);
View Full Code Here

TOP

Related Classes of org.opengis.referencing.operation.Matrix

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.