I have a GPS-coordinate in WGS84 that I would like to transform to a map-projection coordinate in SWEREF99 TM using PROJ.4 in Java or Proj4js in JavaScript.
Its hard to find documentation for PROJ.4 and how to use it. If you have a good link, please post it as a comment.
The PROJ.4 parameters for SWEREF99 TM is +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
I have tried to use a PROJ.4 Java library for transforming Lat: 55° 00’ N, Long: 12° 45’ E
and tried with this code:
String[] proj4_w = new String[] {
"+proj=utm",
"+zone=33",
"+ellps=GRS80",
"+towgs84=0,0,0,0,0,0,0",
"+units=m",
"+no_defs"
};
Projection proj = ProjectionFactory.fromPROJ4Specification(proj4_w);
Point2D.Double testLatLng = new Point2D.Double(55.0000, 12.7500);
Point2D.Double testProjec = proj.transform(testLatLng, new Point2D.Double());
This give me the point Point2D.Double[5197915.86288144, 1822635.9083898761]
but I should be N: 6097106.672, E: 356083.438
What am I doing wrong? and what method and parameters should I use instead?
The correct values is taken from Lantmäteriet.
I am not sure if proj.transform(testLatLng, new Point2D.Double());
is the right method to use.
55 is latitude or longitude?
EDIT: it seems you should simply swap lat and long parameters.
EDIT2: i.e.
Point2D.Double testLatLng = new Point2D.Double(12.7500, 55.0000);