MATSIM
CH1903LV03PlustoWGS84.java
Go to the documentation of this file.
1 /*
2  * *********************************************************************** *
3  * project: org.matsim.* *
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2015 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** *
20  */
21 
22 package org.matsim.core.utils.geometry.transformations;
23 
24 import org.matsim.api.core.v01.Coord;
26 
37 
38  @Override
39  public Coord transform(Coord coord) {
40 
41  /* Important Note: in the Swiss Grid, y describes easting and x describes
42  * northing, contrary to the usual naming conventions! */
43  double yNorm = (coord.getX() - 2600000.0) / 1000000.0;
44  double xNorm = (coord.getY() - 1200000.0) / 1000000.0;
45 
46  double longitude10000Sec =
47  2.6779094 +
48  4.728982 * yNorm +
49  0.791484 * yNorm * xNorm +
50  0.1306 * yNorm * Math.pow(xNorm, 2) -
51  0.0436 * Math.pow(yNorm, 3);
52 
53  double latitude10000Sec =
54  16.9023892 +
55  3.238272 * xNorm -
56  0.270978 * Math.pow(yNorm, 2) -
57  0.002528 * Math.pow(xNorm, 2) -
58  0.0447 * Math.pow(yNorm, 2) * xNorm -
59  0.0140 * Math.pow(xNorm, 3);
60 
61  if (coord.hasZ()) {
62  return new Coord(longitude10000Sec * 100.0 / 36.0, latitude10000Sec * 100.0 / 36.0, coord.getZ());
63  }
64  return new Coord(longitude10000Sec * 100.0 / 36.0, latitude10000Sec * 100.0 / 36.0);
65  }
66 
67 }