Hello,

I am trying to convert lat long into utm, when executing the following code:

double utmZoneCenterLongitude = -123; // Center lon of zone, example: zone 10 = -123
                        int zoneNumber = 55;                                // 
zone number, example: 10
                        double latitude=-37.13298390;
                        double longitude = 144.47529813;    // lat, lon in 
degrees
MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null); ReferencingFactoryContainer factories = new ReferencingFactoryContainer(null);
                        
GeographicCRS geoCRS = org.geotools.referencing.crs.DefaultGeographicCRS.WGS84; CartesianCS cartCS = org.geotools.referencing.cs.DefaultCartesianCS.GENERIC_2D;

ParameterValueGroup parameters = mtFactory.getDefaultParameters("Transverse_Mercator"); parameters .parameter("central_meridian").setValue(utmZoneCenterLongitude);
                        
parameters.parameter("latitude_of_origin").setValue(0.0);
                        parameters.parameter("scale_factor").setValue(0.9996);
                        
parameters.parameter("false_easting").setValue(500000.0);
                        parameters.parameter("false_northing").setValue(0.0);

Map properties = Collections.singletonMap("name", "WGS 84 / UTM Zone " + zoneNumber); ProjectedCRS projCRS = factories.createProjectedCRS(properties, geoCRS, null, parameters, cartCS);

                        MathTransform transform = CRS.findMathTransform(geoCRS, 
projCRS);

                        double[] dest = new double[2];
transform.transform(new double[] {longitude, latitude}, 0, dest, 0, 1);

                        int easting = (int)Math.round(dest[0]);
                        int northing = (int)Math.round(dest[1]);


        i get an error:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Implementing class

        when executing the line:

MathTransformFactory mtFactory = ReferencingFactoryFinder.getMathTransformFactory(null);

can anybody give me some guidance?

thanks

------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to