You may want to make a feature request that "getMethod" be implemented by all; 
and for those that don't have a nice human readable description they could 
return null? Although for many cases the "method" could be obvious from the 
class name the that is implementing the work? 

-- 
Jody Garnett


On Wednesday, 10 August 2011 at 3:20 AM, lasun wrote:

> Hi,
> We are using Geotools v2.6.5 to perform coordinate transformation
> operations. We need to display to our users the details of the transform
> method that will be used during the conversion but we can't find a method on
> the CoordinateOperation interface that tells us what transform method(s) it
> uses. We can only get the detailed description by calling toString() on
> CoordinateOperation but this has too much detail (we want a short one-line
> description.) We noticed that some concrete classes implementing
> CoordinateOperation interface have a getMethod() method which returns an
> OperationMethod object which we can call getName().getCode() which returns a
> good description but this relies on casting and isn't available for all
> CoordinateOperations. Is there an alternative way to get a brief
> description of the transform method? 
> 
> The following is the code we used:
> 
> CoordinateOperationFactory coFactory =
> CRS.getCoordinateOperationFactory(true); 
> CoordinateReferenceSystem srcCrs = CRS.decode("EPSG:4267");
> CoordinateReferenceSystem toCrs = CRS.decode("EPSG:4269");
> CoordinateOperation coorOperation = coFactory.createOperation(srcCrs,
> toCrs);
> List<SingleOperation> ops =
> ((DefaultConcatenatedOperation)coorOperation).getOperations();
> String methods = "";
> for (SingleOperation op : ops)
> {
>  methods += op.getName().getCode() + "->"; 
> }
> 
> if (methods.endsWith("->"))
> { methods = methods.substring(0, methods.lastIndexOf("->")); } 
> 
> In this example the output is "Geocentric transform->Datum shift->Geocentric
> transform" but this only works for cases where the transform operations is a
> DefaultConcatenatedOperation.
> 
> --
> View this message in context: 
> http://osgeo-org.1803224.n2.nabble.com/Problem-to-get-the-transform-method-name-tp6668947p6668947.html
> Sent from the geotools-gt2-users mailing list archive at Nabble.com 
> (http://Nabble.com).
> 
> ------------------------------------------------------------------------------
> uberSVN's rich system and user administration capabilities and model 
> configuration take the hassle out of deploying and managing Subversion and 
> the tools developers use with it. Learn more about uberSVN and get a free 
> download at: http://p.sf.net/sfu/wandisco-dev2dev
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected] 
> (mailto:[email protected])
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to