1

This system is used in Italy. I came across this:

It says that lambda zero is 9° if it's to epsg:3003 otherwise if it's to epsg:3004 it's 15° enter image description here

I came up with this Java code, but the result is wrong:

public static Posizione fromGeo2MonteMario(Posizione from, String srid)
{
    double fi = from.getLatitude();
    double la = from.getLongitude();
    double b = la - (srid.equals("EPSG:3003") ? 9d : 15d);
    fi = convert2Rad(fi);
    la = convert2Rad(la);
    b = convert2Rad(b);
    double w = Math.sqrt(1 + (0.0067681702 * Math.pow(Math.cos(fi),2)) );
    double a = Math.atan( Math.tan(fi) / Math.cos(w * b));
    double v = Math.sqrt(1 + (0.0067681702 * Math.pow(Math.cos(a),2)) );
    double y = 6397376.633 * asinh( Math.cos(a) * Math.tan(b) / v);

    Posizione to = new Posizione();
    to.setNorth( (111092.08210 * a) - (16100.59187 * Math.sin(2*a)) + (16.96942 * Math.sin(4*a)) - (0.02226 * Math.sin(6*a)) );
    to.setEast( y + 500000);

    return to;
}

public static double asinh(double x)
{
    return Math.log(x + Math.sqrt(x*x + 1.0));
}

public static double convert2Rad(double degAngle)
{
    return degAngle * Math.PI / 180;
}   

For example, latitude 42 and longitude 11, is EPSG:3003 so it should be around: East: 1665646.4 North: 4651793.5 You can test it here (or check the example in the pdf)

2
  • My code review :) No source for convert2Rad(). But let's say, it's OK. You convert from.getLatitude(),getLongitude() to radians, so I assume underlying units in Posizione are degrees. Then you do math in radians and pass them to methods setLongitude()/setLatitude() without converting to degrees. Commented Feb 28, 2018 at 15:54
  • Latitude and Longitude are usually expressed in degree (in google map for example). You have right, the output value are not in degree, but just because I was lazy to refine the method. I will edit it. Commented Mar 1, 2018 at 8:41

1 Answer 1

1

Not sure if you're experiencing some sort of localization issues with those particular coordinate systems in Italy, but maybe you should look into GeoTools, and in particular reprojecting geometries. They provide a maven repo as well. I have never used this but it appears to support coordinate systems registered with the EPSG, so it would probably work in this case?

Also, see this post on reprojecting geometries with GeoTools.

2
  • I tried it, but I've to use java 6, and I get various errors with the old version 10 of GeoTools Commented Feb 28, 2018 at 15:39
  • Ok, I got it. I mixed the jts.jar from the 18.2 library with the 10.8 library. I used ten files .jar (6MB) to make a simple math operation. I up-voted you, but would be nice do the math in the old style, without libraries. Commented Feb 28, 2018 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.