Sometime it is good to forget a little bit about a problem, have a good night
and think again about it the day after. I believe that we can handle this issue
in a finer way than brute force.

There is my assumption, please correct me if I'm wrong:

The problem arise because the Envelope to be projected contains a singularity
point in the target CRS (namely the South pole). If the South Pole was not
inside the Envelope to be projected (even if it is very close), the problem
would not arise.

The South Pole is a singularity point in GeographicCRS because we reach the
maximal value allowed on one particular geographic axis, namely latitude. This
point is not a singularity in the stereographic projection, where axis extends
toward infinity in all directions (mathematically). I means, on a pure
mathematic point of view the South pole has nothing special in Stereographic
projection, apart being the origin (0,0).

So what we may want to do is: check if an envelope in *source* CRS contains any
of the singularity point that may exists in the *target* CRS. If such point are
found, add them to the transformed envelope.

Proposed algorithm:

 1) Transform envelope from source to target CRS as we already do.

 2) Inspect the target axis, looking if there is any bounds
    (CoordinateAxis has API for that). If bounds are found,
    get the coordinates of singularity points in target CRS
    and apply the *inverse* projection from target CRS to
    source CRS of those singularity points.

    Example: envelope transformed at step 1 give us
    80°S-85°S, 10°W-50°W. Target CoordinateAxis inspection
    reveal us that latitude in target CRS is bounded at 90°S.
    Project (90°S,30°W) to source CRS (I took arbitrarily
    the center of the envelope longitude range).

 3) If the singularity point computed at point 2 is inside
    the *source* envelope, add that point in the target envelope.


Using this algorith, there is at most 4 points to project in the 2D case and we
should get an accurate result, unless I'm making any wrong assumption.

Will try to implement that in CRS.transform(...), unless someone spot a flaw in
my rational.

        Martin

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to