I created a patch to fix this issue.
First, it will not raise an exception anymore if the nodes are outside
the Lambert zones.
Second, it will display once an error message if someone tries to use
this Lambert projection beyond the latitudes it was designed for.
Third, I renamed the projection as "Lambert Zone (France)" to show
that this projection has limited coverage and is not for the whole
planet (I hope the new name is more clear).

If would be nice if someone with a write access could apply the patch
to the source Lambert.java.

I attach the patch with the extension .txt in this email but the patch
is also attached in the related Trac ticket 1441 :
http://josm.openstreetmap.de/ticket/1441

Thank you in advance,
Pieren

On Thu, Aug 21, 2008 at 10:07 PM, Dirk Stöcker
<[EMAIL PROTECTED]> wrote:
>> Probably you introduced a new bug with this:
>
> http://josm.openstreetmap.de/ticket/1441
>
> Ciao
> --
> http://www.dstoecker.eu/ (PGP key available)
Index: Lambert.java
===================================================================
--- Lambert.java        (revision 815)
+++ Lambert.java        (working copy)
@@ -65,6 +65,10 @@
 
        public static int layoutZone = -1;
 
+       private static int currentZone = 0;
+
+       private static boolean dontDisplayErrors = false;
+
        /**
         * @param p  WGS84 lat/lon (ellipsoid GRS80) (in degree)
         * @return eastnorth projection in Lambert Zone (ellipsoid Clark)
@@ -76,7 +80,7 @@
                double lg = geo.lon();
 
                // check if longitude and latitude are inside the french 
Lambert zones
-               int currentZone = 0;
+               currentZone = 0;
                boolean outOfLambertZones = false;
                if (lt >= zoneLimits[3] && lt <= cMaxLatZone1 && lg >= 
cMinLonZones && lg <= cMaxLonZones) {
                        // zone I
@@ -99,23 +103,36 @@
                                        currentZone = 3;
                } else {
                        outOfLambertZones = true; // possible when MAX_LAT is 
used
+                       if (p.lat() != 0 && Math.abs(p.lat()) != 
Projection.MAX_LAT
+                                       && p.lon() != 0 && Math.abs(p.lon()) != 
Projection.MAX_LON
+                               && dontDisplayErrors == false) {
+                               JOptionPane.showMessageDialog(Main.parent, 
+                                               tr("The projection \"" + 
this.toString() + "\" is designed for\n" 
+                                       + "latitudes between 46.1° and 57° 
only.\n"
+                                       + "Use another projection system if you 
are not using\n"
+                                       + "a french WMS server.\n"
+                                       + "Do not upload any data after this 
message."));
+                               dontDisplayErrors = true;
+                       }
                }
                if (!outOfLambertZones) {
-                       if (layoutZone == -1)
+                       if (layoutZone == -1) {
                                layoutZone = currentZone;
-                       else if (layoutZone != currentZone) {
+                               dontDisplayErrors = false;
+                       } else if (layoutZone != currentZone) {
                                if ((currentZone < layoutZone && 
Math.abs(zoneLimits[currentZone] - lt) > cMaxOverlappingZones)
                                                || (currentZone > layoutZone && 
Math.abs(zoneLimits[layoutZone] - lt) > cMaxOverlappingZones)) {
                                        
JOptionPane.showMessageDialog(Main.parent,
                                                                        
tr("IMPORTANT : data positionned far away from\n"
                                                                                
        + "the current Lambert zone limits.\n"
+                                                                               
+ "Do not upload any data after this message.\n"
                                                                                
        + "Undo your last action, Save your work \n"
                                                                                
        + "and Start a new layer on the new zone."));
                                        layoutZone = -1;
+                                       dontDisplayErrors = true;
                                } else {
-                                       System.out.println("temporarily extends 
Lambert zone "
-                                                       + layoutZone + " 
projection at lat,lon:" + lt + ","
-                                                       + lg);
+                                       System.out.println("temporarily extends 
Lambert zone " + layoutZone + " projection at lat,lon:"
+                                               + lt + "," + lg);
                                }
                        }
                }
@@ -126,15 +143,19 @@
        }
 
        public LatLon eastNorth2latlon(EastNorth p) {
-               LatLon geo = Geographic(p, Xs[layoutZone], Ys[layoutZone], 
c[layoutZone], n[layoutZone]);
+               LatLon geo;
+               if (layoutZone == -1)
+                       // possible until the Lambert zone is determined by 
latlon2eastNorth() with a valid LatLon
+                       geo = Geographic(p, Xs[currentZone], Ys[currentZone], 
c[currentZone], n[currentZone]);
+               else
+                       geo = Geographic(p, Xs[layoutZone], Ys[layoutZone], 
c[layoutZone], n[layoutZone]);
                // translate ellipsoid Clark => GRS80 (WGS83)
                LatLon wgs = Clark2GRS80(geo);
                return new LatLon(Math.toDegrees(wgs.lat()), 
Math.toDegrees(wgs.lon()));
        }
 
-       @Override
-       public String toString() {
-               return "Lambert";
+       @Override public String toString() {
+               return "Lambert Zone (France)";
        }
 
        public String getCacheDirectoryName() {
_______________________________________________
josm-dev mailing list
[email protected]
http://lists.openstreetmap.org/listinfo/josm-dev

Reply via email to