Jody Garnett ha scritto:
> On 20/03/2010, at 9:52 PM, Andrea Aime wrote:
> 
>> Hi,
>> today I had a boring hour and implemented the Winkel Tripel
>> projection, which apparently has been chosen as the best
>> world-wide projection by the National Geographic some 12
>> years ago.
> 
> I remember it - is that not like an atlas and things? They peel back the 
> oceans in oder to make the land masses roughly right.
> 
>> Adding the code was easy enough, but there is a catch:
>> the transform is not easily inverted.
> :-P
> 
>> I believe the likeliness of someone using that direct
>> call is low, as CRS.findMathTransform returns a generic
>> MathTransform (which could be a concatenation of
>> MapProjection with something else).
>>
>> In any case, it's an API break. How to deal with that?
>>
>> Evil plan:
>> - on 2.6.x we throw an unsupported operation exception
>>   that wraps the non invertible one
>> - on trunk we actually make the code throw the
>>   NonInvertibleTransformException
>> Opinions?
> 
> Your evil plan is really evil ... I usually throw a wrapping RuntimeException 
> if ever forced into the same corner. 
> Frankly you may wish to just throw the unsupported operation exception...

I really want to throw that exception, the current setup
(MapProjection.inverse() removing a base class exception)
is an over simplification of reality: it is just normal,
imho, to assume some projections are too hard to
invert.

What about a less evil plan: the user on gt-user was looking
for Robinson projection as an alternative. I've just finished
implementing that one as well.

We commit Robinson on 2.6.x, on 2.7.x we have MapProjection.invert()
throw what it should always have thrown and add the Winkel Tripel
only on trunk.

Btw, looked at Proj4j and they do have a nice isInvertible() query
method on each projection. Smart people. Too bad MathTransform
was not designed that way but... oh well, it's GeoApi,
I don't have a pole long enough to be interested in poking it.
Let's just make MapProjection play by the MathTransform rules
instead (that is, don't blindly assume all map projections
are invertible and declare to throw the exception).

Ah, why don't throw UnpportedOperationException? Because it
will break all the MathTransform users, which I believe
are the majority.
You write code assuming MathTransform, prepare for the checked
exception that invert() might throw and boom, invert() throws one you
were not prepared for, and the execution flow goes south.

Cheers
Andrea

-- 
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to