Java Code Examples for org.opengis.referencing.operation.TransformException#printStackTrace()

The following examples show how to use org.opengis.referencing.operation.TransformException#printStackTrace() . 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: Projection.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Geometry transform(final Geometry g) {
	// Remove uselessly complicated multigeometries
	if (g instanceof GeometryCollection && g.getNumGeometries() == 1) { return transform(g.getGeometryN(0)); }
	Geometry geom = GeometryUtils.GEOMETRY_FACTORY.createGeometry(g);
	if (transformer != null) {
		try {
			geom = transformer.transform(geom);
		} catch (final TransformException e) {
			e.printStackTrace();
		}
	}
	translate(geom);
	convertUnit(geom);
	return geom;
}
 
Example 2
Source File: GeoUtils.java    From gtfs-validator with MIT License 6 votes vote down vote up
private static ProjectedCoordinate convertLonLatToEuclidean(
		Coordinate lonlat) {

	final MathTransform transform = getTransform(lonlat);
	final Coordinate to = new Coordinate();

	// the transform seems to swap the lat lon pairs
	Coordinate latlon = new Coordinate(lonlat.y, lonlat.x);

	try {
		JTS.transform(latlon, to, transform);
	} catch (final TransformException e) {
		e.printStackTrace();
	}

	return new ProjectedCoordinate(transform, new Coordinate(to.y, to.x), lonlat);
}
 
Example 3
Source File: Projection.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public Geometry transform(final Geometry g, final boolean translate) {
	Geometry geom = GeometryUtils.GEOMETRY_FACTORY.createGeometry(g);
	if (transformer != null) {
		try {
			geom = transformer.transform(g);
		} catch (final TransformException e) {
			e.printStackTrace();
		}
	}
	if (translate) {
		translate(geom);
		convertUnit(geom);
	}
	return geom;
}
 
Example 4
Source File: Projection.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Geometry inverseTransform(final Geometry g) {
	Geometry geom = GeometryUtils.GEOMETRY_FACTORY.createGeometry(g);
	inverseConvertUnit(geom);
	inverseTranslate(geom);
	if (inverseTransformer != null) {
		try {
			geom = inverseTransformer.transform(geom);
		} catch (final TransformException e) {
			e.printStackTrace();
		}
	}
	return geom;
}
 
Example 5
Source File: OmsGeomorphonIM.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void processCell( int readCol, int readRow, int writeCol, int writeRow, int readCols, int readRows, int writeCols,
        int writeRows ) {
    try {
        RandomIter elevIter = inRasterIterators.get(0);
        double classification = OmsGeomorphon.calculateGeomorphon(elevIter, readGridGeometry, pRadius, pThreshold,
                diagonalDelta, readCol, readRow);
        WritableRandomIter outDataIter = outRasterIterators.get(0);
        outDataIter.setSample(writeCol, writeRow, 0, classification);
    } catch (TransformException e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: OmsGeomorphon.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
@Execute
public void process() throws Exception {
    checkNull(inElev);

    if (pRadius <= 0) {
        throw new ModelsIllegalargumentException("The search radius has to be > 0.", this, pm);
    }

    final double diagonalDelta = pRadius / sqrt(2.0);

    final RegionMap regionMap = CoverageUtilities.getRegionParamsFromGridCoverage(inElev);
    int cols = regionMap.getCols();
    final int rows = regionMap.getRows();

    final RandomIter elevIter = CoverageUtilities.getRandomIterator(inElev);
    final GridGeometry2D gridGeometry = inElev.getGridGeometry();

    WritableRaster[] outWRHolder = new WritableRaster[1];
    outRaster = CoverageUtilities.createCoverageFromTemplate(inElev, HMConstants.doubleNovalue, outWRHolder);
    final WritableRandomIter outIter = CoverageUtilities.getWritableRandomIterator(outWRHolder[0]);

    pm.beginTask("Calculate classes...", cols);
    for( int r = 0; r < rows; r++ ) {
        for( int c = 0; c < cols; c++ ) {
            try {
                double classification = calculateGeomorphon(elevIter, gridGeometry, pRadius, pThreshold, diagonalDelta, c, r);
                outIter.setSample(c, r, 0, classification);
            } catch (TransformException e) {
                e.printStackTrace();
            }
        }
        pm.worked(1);
    }
    pm.done();

}
 
Example 7
Source File: GeoUtils.java    From gtfs-validator with MIT License 5 votes vote down vote up
public static Coordinate convertToLonLat(
		MathTransform transform, Coordinate xy) {
	final Coordinate to = new Coordinate();
	final Coordinate yx = new Coordinate(xy.y, xy.x);
	try {
		JTS.transform(yx, to, transform.inverse());
	} catch (final TransformException e) {
		e.printStackTrace();
	}
	return new Coordinate(to.y, to.x);
}
 
Example 8
Source File: CoordinateUtils.java    From collect-earth with MIT License 5 votes vote down vote up
public static void main(String[] args) {
//	Exception when moving point [17.934589857940825, -88.44027673628483] with offset longitude 40.0 and latitude -30.0
	double[] coord = new double[] {17.934589857940825d, -88.44027673628483d};
	try {
		double[] pointWithOffset = getPointWithOffset(
				coord, 
				40.0d, 30.0d );
		System.out.println( Arrays.toString(pointWithOffset) );
	} catch (TransformException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
}
 
Example 9
Source File: OmsSurfaceInterpolator.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
private void processing( final int cols, final STRtree tree, final WritableRandomIter interpolatedIter, final double[] eval,
        final int row ) {
    try {
        for( int c = 0; c < cols; c++ ) {
            final DirectPosition gridToWorld = gridGeometry.gridToWorld(new GridCoordinates2D(c, row));
            // System.out.println(row + "/" + c);
            boolean doProcess = true;
            if (inMask != null) {
                inMask.evaluate(gridToWorld, eval);
                if (isNovalue(eval[0])) {
                    doProcess = false;
                }
            }

            if (doProcess) {
                final Coordinate currentCoord = new Coordinate();
                final double[] coord = gridToWorld.getCoordinate();
                currentCoord.x = coord[0];
                currentCoord.y = coord[1];

                final Envelope env = new Envelope(currentCoord.x - pBuffer, currentCoord.x + pBuffer,
                        currentCoord.y - pBuffer, currentCoord.y + pBuffer);

                @SuppressWarnings("unchecked")
                final List<Coordinate> result = tree.query(env);
                // System.out.println(row + "/" + c + " = " + result.size());

                // we need at least 3 points
                if (result.size() < 4) {
                    continue;
                }

                final double value = interpolator.getValue(result.toArray(new Coordinate[0]), currentCoord);
                synchronized (interpolatedIter) {
                    interpolatedIter.setSample(c, row, 0, value);
                }
            }

        }
        pm.worked(1);
    } catch (TransformException e) {
        e.printStackTrace();
    }
}