/** * Constructs an exception with the specified detail message. * * @param cause The cause for this exception. The cause is saved for later retrieval by the * {@link #getCause()} method. */ public TransformPathNotFoundException(FactoryException cause) { super(cause.getLocalizedMessage(), cause); }
public static MathTransform getMathTransform( CoordinateReferenceSystem sourceCRS, CoordinateReferenceSystem destCRS) { try { return CRS.findMathTransform(sourceCRS, destCRS, true); } catch (OperationNotFoundException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } catch (FactoryException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } return null; }
/** * Get Math Transform based on control points * * @return MathTransform */ public synchronized MathTransform getTransform() { AffineTransformBuilder builder = new AffineTransformBuilder(controlPoints); try { return builder.getMathTransform(); } catch (FactoryException e) { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); return null; } }
/** * Returns a new bounding box which contains the transformed shape of this bounding box. This is * a convenience method that delegate its work to the {@link #transform transform} method. */ public BoundingBox toBounds(final CoordinateReferenceSystem targetCRS) throws TransformException { try { return transform(targetCRS, true); } catch (FactoryException e) { throw new TransformException(e.getLocalizedMessage(), e); } }
/** * Read the {@link CoordinateReferenceSystem crs} from the location. * * @return the crs of the location containing the map. * @throws Exception */ public CoordinateReferenceSystem getCoordinateReferenceSystem() throws Exception { File projWtkFile = getPROJ_WKT(); if (projWtkFile.exists()) { BufferedReader crsReader = new BufferedReader(new FileReader(projWtkFile)); StringBuffer wtkString = new StringBuffer(); try { String line = null; while ((line = crsReader.readLine()) != null) { wtkString.append(line.trim()); } } finally { crsReader.close(); } CoordinateReferenceSystem readCrs = null; try { readCrs = CRS.parseWKT(wtkString.toString()); } catch (FactoryException e) { throw new IOException(e.getLocalizedMessage()); } return readCrs; } else { return null; } }
/** * Returns a new bounding box which contains the transformed shape of this bounding box. This is * a convenience method that delegate its work to the {@link #transform transform} method. * * @since 2.4 */ public BoundingBox toBounds(final CoordinateReferenceSystem targetCRS) throws TransformException { try { return transform(targetCRS, true); } catch (FactoryException e) { throw new TransformException(e.getLocalizedMessage(), e); } }
/** * Parses the specified Well Know Text without restriction on the expected type. The default * implementation delegates the work to <code> * {@link #parseObject(String,Class) parseObject}(wkt, Object.class)</code>. * * @param wkt The text to parse. * @return The parsed object. * @throws ParseException if the text can't be parsed. */ @Override public Object parseObject(final String wkt) throws ParseException { try { return parseObject(wkt, Object.class); } catch (FactoryException cause) { final ParseException e = new ParseException(cause.getLocalizedMessage(), 0); e.initCause(cause); throw e; } }
readCrs = CRS.parseWKT(wtkString.toString()); } catch (FactoryException e) { throw new IOException(e.getLocalizedMessage());
readCrs = CRS.parseWKT(wtkString.toString()); } catch (FactoryException e) { throw new IOException(e.getLocalizedMessage());
LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } finally { if (projReader != null)
/** * Set the data source for the EPSG database. If an other EPSG database was already in use, it * will be disconnected. Users should not invoke this method on the factory returned by {@link * ReferencingFactoryFinder}, since it could have a system-wide effect. * * @param datasource The new datasource. * @throws SQLException if an error occured. */ public synchronized void setDataSource(final DataSource datasource) throws SQLException { if (datasource != this.datasource) { try { dispose(); } catch (FactoryException exception) { final Throwable cause = exception.getCause(); if (cause instanceof SQLException) { throw (SQLException) cause; } if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } // Not really an SQL exception, but we should not reach this point anyway. final SQLException e = new SQLException(exception.getLocalizedMessage()); e.initCause(exception); // TODO: inline when we will be allowed to target Java 6. throw e; } this.datasource = datasource; } }
createCoordinateReferenceSystem(code); } catch (FactoryException exception) { failures.put(code, exception.getLocalizedMessage());
/** * Sets the {@link #sourceCRS} field and create the associated {@link #forward} transform. This * method do not create yet the {@link #inverse} transform, since it may not be needed. */ private void setSourceCRS(final CoordinateReferenceSystem crs) throws TransformException { final CoordinateReferenceSystem targetCRS = getCoordinateReferenceSystem(); final CoordinateOperation operation; try { operation = factory.createOperation(crs, targetCRS); } catch (FactoryException exception) { throw new TransformException(exception.getLocalizedMessage(), exception); } /* * Note: 'sourceCRS' must be set last, when we are sure that all other fields * are set to their correct value. This is in order to keep this instance in * a consistent state in case an exception is thrown. */ forward = operation.getMathTransform(); inverse = null; sourceCRS = crs; }
final IOException io = new GeoTiffException(metadata, fe.getLocalizedMessage(), fe); throw io;
coverageRequestedRasterArea = null; } catch (FactoryException e) { LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); requestedBBox = null; coverageRequestedRasterArea = null;
.createCoordinateSystemAxis(map, axisName, direction, unit); } catch (FactoryException e) { throw new FactoryException(e.getLocalizedMessage());
description = ((AbstractAuthorityFactory) factory).getBackingStoreDescription(); } catch (FactoryException e) { description = e.getLocalizedMessage();
} catch (FactoryException exception) { out.flush(); arguments.err.println(exception.getLocalizedMessage()); } catch (Exception exception) { out.flush();
/** Returns a projected CRS for test purpose. */ private static CoordinateReferenceSystem getProjectedCRS(final GridCoverage2D coverage) { try { final GeographicCRS base = (GeographicCRS) coverage.getCoordinateReferenceSystem(); final Ellipsoid ellipsoid = base.getDatum().getEllipsoid(); final DefaultMathTransformFactory factory = new DefaultMathTransformFactory(); final ParameterValueGroup parameters = factory.getDefaultParameters("Oblique_Stereographic"); parameters.parameter("semi_major").setValue(ellipsoid.getSemiMajorAxis()); parameters.parameter("semi_minor").setValue(ellipsoid.getSemiMinorAxis()); parameters.parameter("central_meridian").setValue(5); parameters.parameter("latitude_of_origin").setValue(-5); final MathTransform mt; try { mt = factory.createParameterizedTransform(parameters); } catch (FactoryException exception) { fail(exception.getLocalizedMessage()); return null; } // create the projected crs return new DefaultProjectedCRS( java.util.Collections.singletonMap("name", "Stereographic"), base, mt, DefaultCartesianCS.PROJECTED); } catch (NoSuchIdentifierException exception) { fail(exception.getLocalizedMessage()); return null; } }