| 1 | // License: GPL. For details, see LICENSE file. |
|---|
| 2 | package org.openstreetmap.josm.data.projection; |
|---|
| 3 | |
|---|
| 4 | import static org.openstreetmap.josm.tools.I18n.tr; |
|---|
| 5 | |
|---|
| 6 | import org.openstreetmap.josm.data.Bounds; |
|---|
| 7 | import org.openstreetmap.josm.data.coor.LatLon; |
|---|
| 8 | import org.openstreetmap.josm.data.projection.datum.NTV2Datum; |
|---|
| 9 | import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; |
|---|
| 10 | import org.openstreetmap.josm.data.projection.proj.ProjParameters; |
|---|
| 11 | import org.openstreetmap.josm.data.projection.proj.TransverseMercator; |
|---|
| 12 | |
|---|
| 13 | public class GaussKrueger extends AbstractProjection { |
|---|
| 14 | |
|---|
| 15 | public static final int DEFAULT_ZONE = 2; |
|---|
| 16 | private final int zone; |
|---|
| 17 | |
|---|
| 18 | private static Bounds[] bounds = { |
|---|
| 19 | new Bounds(new LatLon(-5, 3.5), new LatLon(85, 8.5), false), |
|---|
| 20 | new Bounds(new LatLon(-5, 6.5), new LatLon(85, 11.5), false), |
|---|
| 21 | new Bounds(new LatLon(-5, 9.5), new LatLon(85, 14.5), false), |
|---|
| 22 | new Bounds(new LatLon(-5, 12.5), new LatLon(85, 17.5), false), |
|---|
| 23 | }; |
|---|
| 24 | |
|---|
| 25 | public GaussKrueger() { |
|---|
| 26 | this(DEFAULT_ZONE); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | public GaussKrueger(int zone) { |
|---|
| 30 | if (zone < 2 || zone > 5) |
|---|
| 31 | throw new IllegalArgumentException(); |
|---|
| 32 | this.zone = zone; |
|---|
| 33 | ellps = Ellipsoid.Bessel1841; |
|---|
| 34 | datum = new NTV2Datum("BETA2007", null, ellps, NTV2GridShiftFileWrapper.BETA2007); |
|---|
| 35 | ////less acurrate datum (errors up to 3m): |
|---|
| 36 | //datum = new SevenParameterDatum( |
|---|
| 37 | // tr("Deutsches Hauptdreiecksnetz"), null, ellps, |
|---|
| 38 | // 598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.70); |
|---|
| 39 | proj = new TransverseMercator(); |
|---|
| 40 | try { |
|---|
| 41 | proj.initialize(new ProjParameters() {{ ellps = GaussKrueger.this.ellps; }}); |
|---|
| 42 | } catch (ProjectionConfigurationException e) { |
|---|
| 43 | throw new RuntimeException(e); |
|---|
| 44 | } |
|---|
| 45 | x_0 = 1000000 * zone + 500000; |
|---|
| 46 | lon_0 = 3 * zone; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | @Override |
|---|
| 50 | public String toString() { |
|---|
| 51 | return tr("Gau\u00DF-Kr\u00FCger Zone {0}", zone); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | @Override |
|---|
| 55 | public Integer getEpsgCode() { |
|---|
| 56 | return 31464 + zone; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | @Override |
|---|
| 60 | public String getCacheDirectoryName() { |
|---|
| 61 | return "gausskrueger"+zone; |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | @Override |
|---|
| 65 | public Bounds getWorldBoundsLatLon() { |
|---|
| 66 | return bounds[zone-2]; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | } |
|---|