source: josm/trunk/src/org/openstreetmap/josm/data/projection/UTM_France_DOM.java @ 5241

Revision 5236, 4.4 KB checked in by bastiK, 9 days ago (diff)
  • removed offset option from UTM which is probably rarely used. (custom projection can be used for this now, e.g. +proj=tmerc +lon_0=-3 +k_0=0.9996 +x_0=3500000 or +init=epsg:32630 +x_0=3500000)
  • fixed tests
  • Property svn:eol-style set to native
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 org.openstreetmap.josm.data.Bounds;
7import org.openstreetmap.josm.data.coor.LatLon;
8import org.openstreetmap.josm.data.projection.datum.Datum;
9import org.openstreetmap.josm.data.projection.datum.GRS80Datum;
10import org.openstreetmap.josm.data.projection.datum.SevenParameterDatum;
11import org.openstreetmap.josm.data.projection.datum.ThreeParameterDatum;
12import org.openstreetmap.josm.data.projection.proj.ProjParameters;
13
14/**
15 * This class implements all projections for French departements in the Caribbean Sea and
16 * Indian Ocean using the UTM transvers Mercator projection and specific geodesic settings.
17 *
18 */
19public class UTM_France_DOM extends AbstractProjection {
20
21    private final static Bounds FortMarigotBounds = new Bounds( new LatLon(17.6,-63.25), new LatLon(18.5,-62.5), false);
22    private final static Bounds SainteAnneBounds = new Bounds( new LatLon(15.8,-61.9), new LatLon(16.6,-60.9), false);
23    private final static Bounds MartiniqueBounds = new Bounds( new LatLon(14.25,-61.25), new LatLon(15.025,-60.725), false);
24    private final static Bounds ReunionBounds = new Bounds( new LatLon(-25.92,37.58), new LatLon(-10.6, 58.27), false);
25    private final static Bounds GuyaneBounds = new Bounds( new LatLon(2.16 , -54.0), new LatLon(9.06 , -49.62), false);
26    private final static Bounds[] utmBounds = { FortMarigotBounds, SainteAnneBounds, MartiniqueBounds, ReunionBounds, GuyaneBounds };
27
28    private final static Integer FortMarigotEPSG = 2969;
29    private final static Integer SainteAnneEPSG = 2970;
30    private final static Integer MartiniqueEPSG = 2973;
31    private final static Integer ReunionEPSG = 2975;
32    private final static Integer GuyaneEPSG = 2972;
33    public final static Integer[] utmEPSGs = { FortMarigotEPSG, SainteAnneEPSG, MartiniqueEPSG, ReunionEPSG, GuyaneEPSG };
34
35    private final static Datum FortMarigotDatum = new ThreeParameterDatum("FortMarigot Datum", null, Ellipsoid.hayford, 136.596, 248.148, -429.789);
36    private final static Datum SainteAnneDatum = new SevenParameterDatum("SainteAnne Datum", null, Ellipsoid.hayford, -472.29, -5.63, -304.12, 0.4362, -0.8374, 0.2563, 1.8984);
37    private final static Datum MartiniqueDatum = new SevenParameterDatum("Martinique Datum", null, Ellipsoid.hayford, 126.926, 547.939, 130.409, -2.78670, 5.16124, -0.85844, 13.82265);
38    private final static Datum ReunionDatum = GRS80Datum.INSTANCE;
39    private final static Datum GuyaneDatum = GRS80Datum.INSTANCE;
40    private final static Datum[] utmDatums = { FortMarigotDatum, SainteAnneDatum, MartiniqueDatum, ReunionDatum, GuyaneDatum };
41
42    private final static int[] utmZones = { 20, 20, 20, 40, 22 };
43
44    /**
45     * UTM zone (from 1 to 60)
46     */
47    private static int zone;
48    /**
49     * whether north or south hemisphere
50     */
51    private boolean isNorth;
52
53    public static final int DEFAULT_GEODESIC = 0;
54
55    public int currentGeodesic;
56
57
58    public UTM_France_DOM() {
59        this(DEFAULT_GEODESIC);
60    }
61
62    public UTM_France_DOM(int currentGeodesic) {
63        if (currentGeodesic < 0 || currentGeodesic >= 5)
64            throw new IllegalArgumentException();
65        this.currentGeodesic = currentGeodesic;
66        datum = utmDatums[currentGeodesic];
67        ellps = datum.getEllipsoid();
68        proj = new org.openstreetmap.josm.data.projection.proj.TransverseMercator();
69        try {
70            proj.initialize(new ProjParameters() {{ ellps = UTM_France_DOM.this.ellps; }});
71        } catch (ProjectionConfigurationException e) {
72            throw new RuntimeException(e);
73        }
74        isNorth = currentGeodesic != 3;
75        zone = utmZones[currentGeodesic];
76        x_0 = 500000;
77        y_0 = isNorth ? 0.0 : 10000000.0;
78        lon_0 = 6 * zone - 183;
79        k_0 = 0.9996;
80    }
81
82    public int getCurrentGeodesic() {
83        return currentGeodesic;
84    }
85
86    @Override
87    public String toString() {
88        return tr("UTM France (DOM)");
89    }
90
91    @Override
92    public String getCacheDirectoryName() {
93        return this.toString();
94    }
95
96    @Override
97    public Bounds getWorldBoundsLatLon() {
98        return utmBounds[currentGeodesic];
99    }
100
101    @Override
102    public Integer getEpsgCode() {
103        return utmEPSGs[currentGeodesic];
104    }
105
106    @Override
107    public int hashCode() {
108        return getClass().getName().hashCode()+currentGeodesic; // our only real variable
109    }
110
111}
Note: See TracBrowser for help on using the repository browser.