MATSIM
WGS84toCH1903LV03Plus.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  double lonNorm = (coord.getX() * 3600 - 26782.5) / 10000;
42  double latNorm = (coord.getY() * 3600 - 169028.66) / 10000;
43 
44  double CH1903X =
45  1200147.07 +
46  308807.95 * latNorm +
47  3745.25 * Math.pow(lonNorm, 2) +
48  76.63 * Math.pow(latNorm, 2) -
49  194.56 * Math.pow(lonNorm, 2) * latNorm +
50  119.79 * Math.pow(latNorm, 3);
51 
52  double CH1903Y =
53  2600072.37 +
54  211455.93 * lonNorm -
55  10938.51 * lonNorm * latNorm -
56  0.36 * lonNorm * Math.pow(latNorm, 2) -
57  44.54 * Math.pow(lonNorm, 3);
58 
59  /* Important Note: in the Swiss Grid, y describes easting and x describes
60  * northing, contrary to the usual naming conventions! */
61  double elevation;
62  try{
63  elevation = coord.getZ();
64  return new Coord((double) Math.round(CH1903Y), (double) Math.round(CH1903X), elevation);
65  } catch (Exception e){
66  return new Coord((double) Math.round(CH1903Y), (double) Math.round(CH1903X));
67  }
68  }
69 
70 }