001 // License: GPL. For details, see LICENSE file. 002 package org.openstreetmap.josm.data.projection; 003 004 import static org.openstreetmap.josm.tools.I18n.tr; 005 006 import org.openstreetmap.josm.data.Bounds; 007 import org.openstreetmap.josm.data.coor.LatLon; 008 import org.openstreetmap.josm.data.projection.datum.NTV2Datum; 009 import org.openstreetmap.josm.data.projection.datum.NTV2GridShiftFileWrapper; 010 import org.openstreetmap.josm.data.projection.proj.ProjParameters; 011 import org.openstreetmap.josm.data.projection.proj.TransverseMercator; 012 013 public class GaussKrueger extends AbstractProjection { 014 015 public static final int DEFAULT_ZONE = 2; 016 private final int zone; 017 018 private static Bounds[] bounds = { 019 new Bounds(new LatLon(-5, 3.5), new LatLon(85, 8.5), false), 020 new Bounds(new LatLon(-5, 6.5), new LatLon(85, 11.5), false), 021 new Bounds(new LatLon(-5, 9.5), new LatLon(85, 14.5), false), 022 new Bounds(new LatLon(-5, 12.5), new LatLon(85, 17.5), false), 023 }; 024 025 public GaussKrueger() { 026 this(DEFAULT_ZONE); 027 } 028 029 public GaussKrueger(int zone) { 030 if (zone < 2 || zone > 5) 031 throw new IllegalArgumentException(); 032 this.zone = zone; 033 ellps = Ellipsoid.Bessel1841; 034 datum = new NTV2Datum("BETA2007", null, ellps, NTV2GridShiftFileWrapper.BETA2007); 035 ////less acurrate datum (errors up to 3m): 036 //datum = new SevenParameterDatum( 037 // tr("Deutsches Hauptdreiecksnetz"), null, ellps, 038 // 598.1, 73.7, 418.2, 0.202, 0.045, -2.455, 6.70); 039 proj = new TransverseMercator(); 040 try { 041 proj.initialize(new ProjParameters() {{ ellps = GaussKrueger.this.ellps; }}); 042 } catch (ProjectionConfigurationException e) { 043 throw new RuntimeException(e); 044 } 045 x_0 = 1000000 * zone + 500000; 046 lon_0 = 3 * zone; 047 } 048 049 @Override 050 public String toString() { 051 return tr("Gau\u00DF-Kr\u00FCger Zone {0}", zone); 052 } 053 054 @Override 055 public Integer getEpsgCode() { 056 return 31464 + zone; 057 } 058 059 @Override 060 public String getCacheDirectoryName() { 061 return "gausskrueger"+zone; 062 } 063 064 @Override 065 public Bounds getWorldBoundsLatLon() { 066 return bounds[zone-2]; 067 } 068 069 }