/** * Returns a hash value for this derived CRS. * * @return The hash code value. This value doesn't need to be the same in past or future * versions of this class. */ @Override @SuppressWarnings("PMD.OverrideBothEqualsAndHashcode") public int hashCode() { /* * Do not invoke 'conversionFromBase.hashCode()' in order to avoid a never-ending loop. * This is because Conversion has a 'sourceCRS' field (in the AbstractCoordinateOperation * super-class), which is set to this AbstractDerivedCRS. Checking the identifier should * be enough. */ return (int) serialVersionUID ^ baseCRS.hashCode() ^ conversionFromBase.getName().hashCode(); }
/** * Returns an error message for "Can not invert operation XYZ.". * This is used for the construction of {@link OperationNotFoundException}. * * @param crs the CRS having a conversion that can not be inverted. * @return a default error message. */ private static String canNotInvert(final GeneralDerivedCRS crs) { return Resources.format(Resources.Keys.NonInvertibleOperation_1, crs.getConversionFromBase().getName().getCode()); } }
/** * Returns an error message for "Can not invert operation XYZ.". * This is used for the construction of {@link OperationNotFoundException}. * * @param crs the CRS having a conversion that can not be inverted. * @return a default error message. */ private static String canNotInvert(final GeneralDerivedCRS crs) { return Resources.format(Resources.Keys.NonInvertibleOperation_1, crs.getConversionFromBase().getName().getCode()); } }
/** * Creates the conversion instance to associate with this {@code AbstractDerivedCRS}. * * <p><b>WARNING:</b> this method is invoked at construction time and will invoke indirectly * (through {@link DefaultConversion}) the {@link #getCoordinateSystem()} method on {@code this}. * Consequently this method shall be invoked only after the construction of this {@code AbstractDerivedCRS} * instance is advanced enough for allowing the {@code getCoordinateSystem()} method to execute. * Subclasses may consider to make the {@code getCoordinateSystem()} method final for better guarantees.</p> */ private C createConversionFromBase(final Map<String,?> properties, final SingleCRS baseCRS, final Conversion conversion) { MathTransformFactory factory = null; if (properties != null) { factory = (MathTransformFactory) properties.get(ReferencingServices.MT_FACTORY); } if (factory == null) { factory = DefaultFactories.forBuildin(MathTransformFactory.class); } try { return DefaultConversion.castOrCopy(conversion).specialize(getConversionType(), baseCRS, this, factory); } catch (FactoryException e) { throw new IllegalArgumentException(Errors.getResources(properties).getString( Errors.Keys.IllegalArgumentValue_2, "conversion", conversion.getName()), e); } }
/** * Creates the conversion instance to associate with this {@code AbstractDerivedCRS}. * * <p><b>WARNING:</b> this method is invoked at construction time and will invoke indirectly * (through {@link DefaultConversion}) the {@link #getCoordinateSystem()} method on {@code this}. * Consequently this method shall be invoked only after the construction of this {@code AbstractDerivedCRS} * instance is advanced enough for allowing the {@code getCoordinateSystem()} method to execute. * Subclasses may consider to make the {@code getCoordinateSystem()} method final for better guarantees.</p> */ private C createConversionFromBase(final Map<String,?> properties, final SingleCRS baseCRS, final Conversion conversion) { MathTransformFactory factory = null; if (properties != null) { factory = (MathTransformFactory) properties.get(ReferencingServices.MT_FACTORY); } if (factory == null) { factory = DefaultFactories.forBuildin(MathTransformFactory.class); } try { return DefaultConversion.castOrCopy(conversion).specialize(getConversionType(), baseCRS, this, factory); } catch (FactoryException e) { throw new IllegalArgumentException(Errors.getResources(properties).getString( Errors.Keys.IllegalArgumentValue_2, "conversion", conversion.getName()), e); } }
lastName = c.getName(); return c;
@Override public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters, GeodeticDatum datum) throws FactoryException { final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null); // in some cases, depending on the parameters set, the effective transformation can be different // from the transformation given by the OperationMethod. // So we create a new one final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null); final MathTransform transform = mtFactory.createParameterizedTransform(parameters); final DefaultOperationMethod operationMethod = new DefaultOperationMethod(transform); final Conversion conversion = new DefiningConversion(AbstractIdentifiedObject.getProperties(operationMethod), operationMethod, transform); final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>(); baseCrsProperties.put("name", datum.getName().getCode()); GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties, datum, DefaultEllipsoidalCS.GEODETIC_2D); final HashMap<String, Object> projProperties = new HashMap<String, Object>(); projProperties.put("name", conversion.getName().getCode() + " / " + datum.getName().getCode()); return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED); } }
@Override public CoordinateReferenceSystem getCRS(final GeoPos referencePos, ParameterValueGroup parameters, GeodeticDatum datum) throws FactoryException { final CRSFactory crsFactory = ReferencingFactoryFinder.getCRSFactory(null); // in some cases, depending on the parameters set, the effective transformation can be different // from the transformation given by the OperationMethod. // So we create a new one final MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null); final MathTransform transform = mtFactory.createParameterizedTransform(parameters); final DefaultOperationMethod operationMethod = new DefaultOperationMethod(transform); final Conversion conversion = new DefiningConversion(AbstractIdentifiedObject.getProperties(operationMethod), operationMethod, transform); final HashMap<String, Object> baseCrsProperties = new HashMap<String, Object>(); baseCrsProperties.put("name", datum.getName().getCode()); GeographicCRS baseCrs = crsFactory.createGeographicCRS(baseCrsProperties, datum, DefaultEllipsoidalCS.GEODETIC_2D); final HashMap<String, Object> projProperties = new HashMap<String, Object>(); projProperties.put("name", conversion.getName().getCode() + " / " + datum.getName().getCode()); return crsFactory.createProjectedCRS(projProperties, baseCrs, conversion, DefaultCartesianCS.PROJECTED); } }
final String conversionName = conversion.getName().getCode(); metadata.addGeoShortParam(GeoTiffPCSCodes.ProjectionGeoKey, 32767); metadata.addGeoAscii(GeoTiffPCSCodes.PCSCitationGeoKey, conversionName);