source: josm/trunk/src/org/openstreetmap/josm/data/projection/SwissGrid.java@ 5067

Last change on this file since 5067 was 5066, checked in by bastiK, 12 years ago

Proj parameter refactoring (see #7495)

  • Property svn:eol-style set to native
File size: 3.1 KB
Line 
1//License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.projection;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionListener;
7import java.util.Collection;
8import java.util.Collections;
9
10import javax.swing.Box;
11import javax.swing.JPanel;
12
13import org.openstreetmap.josm.data.Bounds;
14import org.openstreetmap.josm.data.coor.LatLon;
15import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum;
16import org.openstreetmap.josm.data.projection.proj.ProjParameters;
17import org.openstreetmap.josm.data.projection.proj.SwissObliqueMercator;
18import org.openstreetmap.josm.gui.widgets.HtmlPanel;
19import org.openstreetmap.josm.tools.GBC;
20
21/**
22 * SwissGrid CH1903 / L03, see http://de.wikipedia.org/wiki/Swiss_Grid.
23 *
24 * Actually, what we have here, is CH1903+ (EPSG:2056), but without
25 * the additional false easting of 2000km and false northing 1000 km.
26 *
27 * To get to CH1903, a shift file is required. So currently, there are errors
28 * up to 1.6m (depending on the location).
29 *
30 * This projection does not have any parameters, it only implements
31 * ProjectionSubPrefs to show a warning that the grid file correction is not done.
32 */
33public class SwissGrid extends AbstractProjection implements ProjectionSubPrefs {
34
35 public SwissGrid() {
36 ellps = Ellipsoid.Bessel1841;
37 datum = new ThreeParameterDatum("SwissGrid Datum", null, ellps, 674.374, 15.056, 405.346);
38 x_0 = 600000;
39 y_0 = 200000;
40 lon_0 = 7.0 + 26.0/60 + 22.50/3600;
41 proj = new SwissObliqueMercator();
42 try {
43 proj.initialize(new ProjParameters() {{
44 ellps = SwissGrid.this.ellps;
45 lat_0 = 46.0 + 57.0/60 + 8.66/3600;
46 }});
47 } catch (ProjectionConfigurationException e) {
48 throw new RuntimeException(e);
49 }
50 }
51
52 @Override
53 public String toString() {
54 return tr("Swiss Grid (Switzerland)");
55 }
56
57 @Override
58 public Integer getEpsgCode() {
59 return 21781;
60 }
61
62 @Override
63 public int hashCode() {
64 return getClass().getName().hashCode(); // we have no variables
65 }
66
67 @Override
68 public String getCacheDirectoryName() {
69 return "swissgrid";
70 }
71
72 @Override
73 public Bounds getWorldBoundsLatLon() {
74 return new Bounds(new LatLon(45.7, 5.7), new LatLon(47.9, 10.6));
75 }
76
77 @Override
78 public void setupPreferencePanel(JPanel p, ActionListener listener) {
79 p.add(new HtmlPanel(tr("<i>CH1903 / LV03 (without local corrections)</i>")), GBC.eol().fill(GBC.HORIZONTAL));
80 p.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH));
81 }
82
83 @Override
84 public void setPreferences(Collection<String> args) {
85 }
86
87 @Override
88 public Collection<String> getPreferences(JPanel p) {
89 return Collections.singletonList("CH1903");
90 }
91
92 @Override
93 public String[] allCodes() {
94 return new String[] { "EPSG:21781" };
95 }
96
97 @Override
98 public Collection<String> getPreferencesFromCode(String code) {
99 if ("EPSG:21781".equals(code))
100 return Collections.singletonList("CH1903");
101 return null;
102 }
103}
Note: See TracBrowser for help on using the repository browser.