Hello Ted,

> I thought dat when DirectPosition2D is given a certain CRS, say
> DirectPosition2D pos = new DirectPosition2D ( DefaultWGS84, x,y);
>
> then setting CRS to a different one pos.setCoordianteReferenceSystem(
> another CRS )
>
> pos.getX() // i got da same X i thought when i change the CRS i ll get
> another point it will be transformed, But i thought wrong..

DirectPosition2D just holds a reference to the CRS for use by other
classes. If you wanted to transform a point location from its original
map projection to a new one you could do it like this:

        // Sydney long-lat coordinates
        CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
        DirectPosition pos = new DirectPosition2D(sourceCRS, 151.1666,
-33.8333);
        System.out.printf("lat-long pos: %.4f %.4f \n",
                pos.getOrdinate(1), pos.getOrdinate(0));

        // Reproject to Map Grid of Australia Zone 56
        CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:28356", true);
        MathTransform tr = CRS.findMathTransform(sourceCRS, targetCRS);

        DirectPosition trPos = tr.transform(pos, null);
        System.out.printf("MGA Zone 56 pos: %d %d \n",
                (int) trPos.getOrdinate(0),
                (int) trPos.getOrdinate(1));

To be honest, there's no advantage in using a DirectPosition object
for this - you might as well use a Point2D object instead.

DirectPosition is more useful is when you are testing the relationship
between a position and some other feature which might be in a
different map projection. For example, you can test whether a
DirectPosition falls within a ReferenceEnvelope (a rectangle which
'knows' its CRS)...

        // box around central Sydney
        ReferencedEnvelope refEnv = new ReferencedEnvelope(-33, -32,
151, 152, sourceCRS);

        // test if UTM point coords from last example fall in this box
        boolean hit = refEnv.contains(trPos);

Note that you didn't have to do any transforming to do that, GeoTools
does it for you.

DirectPosition is used quite a bit when you are working with grid
coverages (GeoTools GridCoverage2D class) but doesn't really appear in
the methods of GeoTools class that deal with vector data. But this
just has to do with the history of GeoTools and may change in the
future.

> i have a question
> http://spatialreference.org/ref/epsg/32636/
> what is the unit of the projected bounds??? (as i understand it s in meters

Yes, that's right.

> and u can apply Pythagoras)
> and 30.0000, 0.0000, 36.0000, 84.0000 are the bounds the long/lat of the
> zone so they are in decimals or in degree min and secs if so?

They are decimal degrees. so the valid area of use for that projection is:
    30 - 36 degrees latitude
    0 - 84 deg longitude

> WHAT ARE THE VALUEs THAT WE CALL THEM EASTING/NORTHING are they
> 166021.4431, 0.0000, 833978.5569, 9329005.1825????????
> In other words is "easting/northing" process is to convert a certain
> location in long/lat estimating the suitable zone UTM zone to get the
> projected crds ..????
> plz confirm

Sorry - I don't understand that bit.

Michael

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to