Ticket #1441: Lambert.patch

File Lambert.patch, 3.3 KB (added by pieren, 16 years ago)

Patch for Lambert.java

  • Lambert.java

     
    6565
    6666        public static int layoutZone = -1;
    6767
     68        private static int currentZone = 0;
     69
     70        private static boolean dontDisplayErrors = false;
     71
    6872        /**
    6973         * @param p  WGS84 lat/lon (ellipsoid GRS80) (in degree)
    7074         * @return eastnorth projection in Lambert Zone (ellipsoid Clark)
     
    7680                double lg = geo.lon();
    7781
    7882                // check if longitude and latitude are inside the french Lambert zones
    79                 int currentZone = 0;
     83                currentZone = 0;
    8084                boolean outOfLambertZones = false;
    8185                if (lt >= zoneLimits[3] && lt <= cMaxLatZone1 && lg >= cMinLonZones && lg <= cMaxLonZones) {
    8286                        // zone I
     
    99103                                        currentZone = 3;
    100104                } else {
    101105                        outOfLambertZones = true; // possible when MAX_LAT is used
     106                        if (p.lat() != 0 && Math.abs(p.lat()) != Projection.MAX_LAT
     107                                        && p.lon() != 0 && Math.abs(p.lon()) != Projection.MAX_LON
     108                                && dontDisplayErrors == false) {
     109                                JOptionPane.showMessageDialog(Main.parent,
     110                                                tr("The projection \"" + this.toString() + "\" is designed for\n"
     111                                        + "latitudes between 46.1° and 57° only.\n"
     112                                        + "Use another projection system if you are not using\n"
     113                                        + "a french WMS server.\n"
     114                                        + "Do not upload any data after this message."));
     115                                dontDisplayErrors = true;
     116                        }
    102117                }
    103118                if (!outOfLambertZones) {
    104                         if (layoutZone == -1)
     119                        if (layoutZone == -1) {
    105120                                layoutZone = currentZone;
    106                         else if (layoutZone != currentZone) {
     121                                dontDisplayErrors = false;
     122                        } else if (layoutZone != currentZone) {
    107123                                if ((currentZone < layoutZone && Math.abs(zoneLimits[currentZone] - lt) > cMaxOverlappingZones)
    108124                                                || (currentZone > layoutZone && Math.abs(zoneLimits[layoutZone] - lt) > cMaxOverlappingZones)) {
    109125                                        JOptionPane.showMessageDialog(Main.parent,
    110126                                                                        tr("IMPORTANT : data positionned far away from\n"
    111127                                                                                        + "the current Lambert zone limits.\n"
     128                                                                                + "Do not upload any data after this message.\n"
    112129                                                                                        + "Undo your last action, Save your work \n"
    113130                                                                                        + "and Start a new layer on the new zone."));
    114131                                        layoutZone = -1;
     132                                        dontDisplayErrors = true;
    115133                                } else {
    116                                         System.out.println("temporarily extends Lambert zone "
    117                                                         + layoutZone + " projection at lat,lon:" + lt + ","
    118                                                         + lg);
     134                                        System.out.println("temporarily extends Lambert zone " + layoutZone + " projection at lat,lon:"
     135                                                + lt + "," + lg);
    119136                                }
    120137                        }
    121138                }
     
    126143        }
    127144
    128145        public LatLon eastNorth2latlon(EastNorth p) {
    129                 LatLon geo = Geographic(p, Xs[layoutZone], Ys[layoutZone], c[layoutZone], n[layoutZone]);
     146                LatLon geo;
     147                if (layoutZone == -1)
     148                        // possible until the Lambert zone is determined by latlon2eastNorth() with a valid LatLon
     149                        geo = Geographic(p, Xs[currentZone], Ys[currentZone], c[currentZone], n[currentZone]);
     150                else
     151                        geo = Geographic(p, Xs[layoutZone], Ys[layoutZone], c[layoutZone], n[layoutZone]);
    130152                // translate ellipsoid Clark => GRS80 (WGS83)
    131153                LatLon wgs = Clark2GRS80(geo);
    132154                return new LatLon(Math.toDegrees(wgs.lat()), Math.toDegrees(wgs.lon()));
    133155        }
    134156
    135         @Override
    136         public String toString() {
    137                 return "Lambert";
     157        @Override public String toString() {
     158                return "Lambert Zone (France)";
    138159        }
    139160
    140161        public String getCacheDirectoryName() {