Hello Simone
Simone Giannecchini a écrit :
> 1>In case I have a general CRS which can be compound but I want to use
> the horizontal part of it which method I can use to get the latter? I
> see CRS#getHorizontalCRS and CRSUtiilites#getCRS2D, which one is the
> best? Is there a better option?
It depends what you want to do:
* getCRS2D returns the 2 first dimensions, no matter what they are. It could
be (vertical, temporal) dimensions. This is uncommited API (everything in
"org.geotools.resource" is uncommited) because I'm not sure that it is a
right thing to do, so I apply Joshua Bloch's precaution principle: "in case
of doubt, leave it out" (at least from public API).
* getHorizontalCRS returns the GeographicCRS or ProjectecCRS part that apply
to the Earth's surface, so at the difference of 'getCRS2D' it has a real
geophysics meaning and for this reason is a commited API. Note however that
if you have a DerivedCRS, this method will unwrap it up to the underyling
GeographicCRS or ProjectedCRS, which may not be what you want (it depends
what you want to do). Note also that current implementation will fail for
3D GeographicCRS with ellipsoidal height.
* If you want that in the context of GridCoverage2D work, it may be better to
rely to GridGeometry2D.getCoordinateReference2D() method, which performs a
much more sophesticated work. Actually GridCoverage2D already accepts n-D CRS
provided that every dimensions except 2 are exactly 1 pixel width. For example
imagine a (x,y,z,t) coverage of size (400 x 500 x 1 x 1). GridCoverage2D will
accepts such size with its associated 4D-CRS because the data can be stocked
in 2D PlanarImage without any special trick, since only the x,y dimensions
need to be stocked. However GridCoverage2D will not accept a coverage of size
(400 x 500 x 2 x 1) for example; this one would require a real GridCoverage3D.
The 2D part don't need to be first. GridCoverage2D will accepts (1x300x100x1)
as well. GridGeometry2D as many methods ending in "2D" which do the same than
the nD methods, but using only the relevant dimensions. For example there is
a getEnvelope2D() method, getGridToCRS2D(), etc.
GridCoverage2D.getGridGeometry() always returns an instance of GridGeometry2D.
On Geotools 2.4, you need to cast the return value. On GeoTools 2.5, this is
not needed anymore thanks to Java 5 covariant return type.
> 2>Same as above for GeneralEnvelope. Let's say I have a
> GeneralEnvelope for a compound crs, Which is the best way to get the
> 2D part out of it in your opinion?
If it is in the context of GridCoverage2D, I suggest
GridGeometry2D.getEnvelope2D(). If it is in other context, the safest way (if
performance is not an issue - but it is usually not unless you have thousands of
Envelope to reduce) is to first get your 2D CRS using the above, then invokes
CRS.transform(MathTransform, Envelope).
Hope it help,
Martin
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel