Parsing FITTED_CS WKT with affine transformation fails with ClassCastException

Description

I want to define a coordinate system which "rotates" an existing coordinate system (say, Google Mercator). Please see the following question on GIS StackExchange:

http://gis.stackexchange.com/questions/159037/how-to-define-a-coordinate-reference-system-with-rotation-in-geoserver/159134#159134

This can be done using the FITTED_CS CRS:

Unfortunately, GeoTools fails with the class cast exception.

The reason is that when the inverse transformation is created in ProjectiveTransform, it is always ProjectiveTransform:

https://github.com/geotools/geotools/blob/aa0d0346e4bb4a5a2055559c22d2b12ded7cbd20/modules/library/referencing/src/main/java/org/geotools/referencing/operation/transform/ProjectiveTransform.java#L509

There is a createInverse(...) method, which is overridden by subclasses, but it is not called in inverse(). This is why I get a class cast exception here although the class does override the createInverse(...) method here.

The fix is trivial: use createInverse(matrix) instead of new ProjectiveTransform(matrix).

I'll provide a pull request.

Environment

None

Assignee

Jody Garnett

Reporter

Alexey Valikov

Triage

None

Components

Fix versions

Affects versions

Priority

Low
Configure