Search in sources :

Example 1 with CoordinateOperationAuthorityFactory

use of org.opengis.referencing.operation.CoordinateOperationAuthorityFactory in project sis by apache.

the class CoordinateOperationSet method createObject.

/**
 * Creates a coordinate operation for the specified EPSG code.
 */
@Override
protected CoordinateOperation createObject(final String code) throws FactoryException {
    final Integer base = projections.get(code);
    if (base != null) {
        /*
             * First case documented in class Javadoc:
             *
             *     SELECT PROJECTION_CONV_CODE FROM "Coordinate Reference System" …
             *
             * The result is usually a ProjectedCRS, but not always.
             */
        CoordinateReferenceSystem crs;
        crs = ((CRSAuthorityFactory) factory).createCoordinateReferenceSystem(String.valueOf(base));
        if (crs instanceof GeneralDerivedCRS) {
            return ((GeneralDerivedCRS) crs).getConversionFromBase();
        }
    }
    /*
         * Following line is either for the second case documented in class Javadoc, or the first case
         * when the result is not a derived CRS. Note that we could create a derived CRS here as below:
         *
         *     CoordinateOperation op = …,
         *     if (crs != null && op instanceof Conversion) {
         *         return DefaultDerivedCRS.create(IdentifiedObjects.getProperties(crs), baseCRS,
         *                 (Conversion) op, crs.getCoordinateSystem()).getConversionFromBase();
         *     }
         *
         * We don't do that for now because because EPSGDataAccess.createCoordinateReferenceSystem(String)
         * would be a better place, by generalizing the work done for ProjectedCRS.
         *
         * https://issues.apache.org/jira/browse/SIS-357
         */
    return ((CoordinateOperationAuthorityFactory) factory).createCoordinateOperation(code);
}
Also used : CoordinateOperationAuthorityFactory(org.opengis.referencing.operation.CoordinateOperationAuthorityFactory) GeneralDerivedCRS(org.opengis.referencing.crs.GeneralDerivedCRS) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem)

Aggregations

CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 GeneralDerivedCRS (org.opengis.referencing.crs.GeneralDerivedCRS)1 CoordinateOperationAuthorityFactory (org.opengis.referencing.operation.CoordinateOperationAuthorityFactory)1