Hi Ben:

Your pal Michael cornered me on IRC for a chat about this email thread. You are 
at the limits of my knowledge of how to get things done, this is why I have not 
joined in the discussion.

My understanding is that you are asking how to do things correctly, and I am 
interested as we have an oustanding feature request for uDig chasing this same 
goal.

Currently in uDig, and in the sample GeoTools apps, you can see that we are 
faking things.
1. convert from Data+DataCRS to ...
2. World+CRS
3. Take a affine transformation (scale, rotation etc..) from that to a 2D screen

As a side effect our users don't really get to choose "the projection", instead 
they get a bit of the project used for the world crs, mixed in with the affine 
transformation. This is not ideal, or even exacting for use in say editing of 
data.

My understanding is that the correct way to do things is:
1. Convert from Data+DataCRS to ... a solid 3D understanding of the locations
2. Allow the user to choose a projection (selected by user depending on the 
problem they want to solve)
3. Use the projection convert from 3D to the flat screen used for editing and 
display

I am not sure how this maps on to the various classes in GeoTools. As I don't 
understand how to get this done I have not made a utility method in the CRS 
class to make this easy for everyone.

Perhaps Micheal and yourself could dive into the math and classes and come back 
with an answer? I expect some work is needed.

As indicated above, every time I need to dive into the math and classes I 
produce a utility method in the CRS class (mostly so I don't have to think so 
hard next time - and can write test cases for my thinking).

-- 
Jody Garnett

On Thursday, 17 March 2011 at 6:11 PM, Benoît Thiébault wrote: 
> Hi Michael,
> 
> Of course you can :-)
> 
> I need a ProjectedCRS because I have to pass a ProjectedCRS to a helper class 
> of my application.
> This helper class stores the current GeodeticCRS and ProjectedCRS and if the 
> user changes the projection system, it tells all its listeners to convert 
> their coordinates to the new projection.
> Of course, I could in this helper class store only CoordinatesReferenceSystem 
> objects, but this would have an impact on a lot of code...
> Moreover, I prefer using ProjectedCRS than CoordinatesReferenceSystem in 
> order to prevent too many casts.
> 
> This problem is really blocking for me right now and I would be very pleased 
> to find an answer...
> 
> Ben
> 
> Le 17 mars 2011 à 06:38, Michael Bedward a écrit :
> 
> > Hi Ben,
> > 
> > It doesn't look like anyone has an easy answer for this one - unless
> > this bump flushes one out.
> > 
> > Can I ask you why it is important to have a ProjectedCRS rather than
> > working with the DefaultDerivedCRS ?
> > 
> > Michael
> > 
> > 
> > 2011/3/11 Benoît Thiébault <[email protected]>:
> > > Hi everyone,
> > > 
> > > I have created a DefaultDerivedCRS that is a rotation of a ProjectedCRS 
> > > (called selectedCRS) like this:
> > > 
> > > > CoordinateReferenceSystem transformedCRS = selectedCRS;
> > > > 
> > > > if (getAngleRadians() != 0.0) {
> > > >  // Create the rotation transform
> > > >  final AffineTransform rotation = new AffineTransform();
> > > >  rotation.rotate(getAngleRadians(), getRotationProjCenter().x, 
> > > > getRotationProjCenter().y);
> > > > 
> > > >  // Creates the math transform
> > > >  final MathTransform transform = ProjectiveTransform.create(rotation);
> > > > 
> > > >  // Sets the new CRS name
> > > >  String crsName = selectedCRS.getName().toString();
> > > >  if (getAngleRadians() != 0) {
> > > >  final DecimalFormat formatter = new DecimalFormat("#.##");
> > > >  final String rotationText = 
> > > > formatter.format(Math.toDegrees(getAngleRadians()));
> > > >  crsName += " / Rotation: " + rotationText + "°";
> > > >  }
> > > > 
> > > > // Rotates the CRS
> > > > transformedCRS = new DefaultDerivedCRS(crsName, selectedCRS, transform, 
> > > > selectedCRS.getCoordinateSystem());
> > > 
> > > My problem is that this method is expected to return a ProjectedCRS and 
> > > if I simply cast the DefaultDerivedCRS to ProjectedCRS, I get a 
> > > ClassCastException.
> > > 
> > > How can I create such a rotated ProjectedCRS from another ProjectedCRS ?
> > > 
> > > Kind regards,
> > > Ben
> > > 
> > > ----
> > > Dr Benoît Thiébault
> > > Project Manager
> > > 
> > >  Artenum Toulouse - Science & Groupware
> > > http://www.artenum.com
> > > 
> > > Bâtiment Calfocenter
> > > 10, rue Marguerite Long
> > > 31 320 Castanet Tolosan
> > > Phone: +33 (0)5 62 19 32 22
> > > 
> > > 
> > > ------------------------------------------------------------------------------
> > > Colocation vs. Managed Hosting
> > > A question and answer guide to determining the best fit
> > > for your organization - today and in the future.
> > > http://p.sf.net/sfu/internap-sfd2d
> > > _______________________________________________
> > > Geotools-gt2-users mailing list
> > > [email protected]
> > > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> 
> ----
> Dr Benoît Thiébault
> Project Manager
> 
>  Artenum Toulouse - Science & Groupware
> http://www.artenum.com
> 
> Bâtiment Calfocenter
> 10, rue Marguerite Long
> 31 320 Castanet Tolosan
> Phone: +33 (0)5 62 19 32 22
> 
> 
> ------------------------------------------------------------------------------
> Colocation vs. Managed Hosting
> A question and answer guide to determining the best fit
> for your organization - today and in the future.
> http://p.sf.net/sfu/internap-sfd2d
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> 
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to