# Formula for transforming from EPSG:4326 to EPSG:3003 or EPSG:3004

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°

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);
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);

}

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)

• 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