| 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.GRS80Datum; |
|---|
| 9 | import org.openstreetmap.josm.data.projection.proj.LambertConformalConic; |
|---|
| 10 | import org.openstreetmap.josm.data.projection.proj.ProjParameters; |
|---|
| 11 | |
|---|
| 12 | /** |
|---|
| 13 | * Lambert Conic Conform 9 Zones projection as specified by the IGN |
|---|
| 14 | * in this document http://professionnels.ign.fr/DISPLAY/000/526/700/5267002/transformation.pdf |
|---|
| 15 | * @author Pieren |
|---|
| 16 | * |
|---|
| 17 | */ |
|---|
| 18 | public class LambertCC9Zones extends AbstractProjection { |
|---|
| 19 | |
|---|
| 20 | /** |
|---|
| 21 | * France is divided in 9 Lambert projection zones, CC42 to CC50. |
|---|
| 22 | */ |
|---|
| 23 | public static final double cMaxLatZonesRadian = Math.toRadians(51.1); |
|---|
| 24 | |
|---|
| 25 | public static final double cMinLatZonesDegree = 41.0; |
|---|
| 26 | |
|---|
| 27 | public static final double cMaxOverlappingZones = 1.5; |
|---|
| 28 | |
|---|
| 29 | public static final int DEFAULT_ZONE = 0; |
|---|
| 30 | |
|---|
| 31 | private final int layoutZone; |
|---|
| 32 | |
|---|
| 33 | public LambertCC9Zones() { |
|---|
| 34 | this(DEFAULT_ZONE); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | public LambertCC9Zones(final int layoutZone) { |
|---|
| 38 | ellps = Ellipsoid.GRS80; |
|---|
| 39 | datum = GRS80Datum.INSTANCE; |
|---|
| 40 | this.layoutZone = layoutZone; |
|---|
| 41 | x_0 = 1700000; |
|---|
| 42 | y_0 = (layoutZone+1) * 1000000 + 200000; |
|---|
| 43 | lon_0 = 3; |
|---|
| 44 | if (proj == null) { |
|---|
| 45 | proj = new LambertConformalConic(); |
|---|
| 46 | } |
|---|
| 47 | try { |
|---|
| 48 | proj.initialize(new ProjParameters() {{ |
|---|
| 49 | ellps = LambertCC9Zones.this.ellps; |
|---|
| 50 | lat_0 = 42.0 + layoutZone; |
|---|
| 51 | lat_1 = 41.25 + layoutZone; |
|---|
| 52 | lat_2 = 42.75 + layoutZone; |
|---|
| 53 | }}); |
|---|
| 54 | } catch (ProjectionConfigurationException e) { |
|---|
| 55 | throw new RuntimeException(e); |
|---|
| 56 | } |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | @Override |
|---|
| 60 | public String toString() { |
|---|
| 61 | return tr("Lambert CC9 Zone (France)"); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | public static int north2ZoneNumber(double north) { |
|---|
| 65 | int nz = (int)(north /1000000) - 1; |
|---|
| 66 | if (nz < 0) return 0; |
|---|
| 67 | else if (nz > 8) return 8; |
|---|
| 68 | else return nz; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | @Override |
|---|
| 72 | public Integer getEpsgCode() { |
|---|
| 73 | return 3942+layoutZone; //CC42 is EPSG:3942 (up to EPSG:3950 for CC50) |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | @Override |
|---|
| 77 | public int hashCode() { |
|---|
| 78 | return getClass().getName().hashCode()+layoutZone; // our only real variable |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | @Override |
|---|
| 82 | public String getCacheDirectoryName() { |
|---|
| 83 | return "lambert"; |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | @Override |
|---|
| 87 | public Bounds getWorldBoundsLatLon() |
|---|
| 88 | { |
|---|
| 89 | double medLatZone = cMinLatZonesDegree + (layoutZone+1); |
|---|
| 90 | return new Bounds( |
|---|
| 91 | new LatLon(Math.max(medLatZone - 1.0 - cMaxOverlappingZones, cMinLatZonesDegree), -5.5), |
|---|
| 92 | new LatLon(Math.min(medLatZone + 1.0 + cMaxOverlappingZones, Math.toDegrees(cMaxLatZonesRadian)), 10.2), |
|---|
| 93 | false); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | public int getLayoutZone() { |
|---|
| 97 | return layoutZone; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | } |
|---|