[josm-dev] Need advice about a recent change in Mapview blocking the plugin cadastre-fr and its Lambert zone projections

Pieren pieren3 at gmail.com
Tue Nov 17 00:12:11 GMT 2009


Hi,

A recent change in Mapview.java (rev.2450) by "jttt" introduces a
problem with the Lambert projections and I don't know how it could be
fixed. That's why I'm calling here for some help/advice.

The change is the following in Mapview @Override public void paint(Graphics g) :
(before)
        Graphics2D tempG = offscreenBuffer.createGraphics();
        tempG.setColor(Main.pref.getColor("background", Color.BLACK));
        tempG.fillRect(0, 0, getWidth(), getHeight());
        for (Layer l: getVisibleLayersInZOrder()) {
            l.paint(tempG, this);
        }
        for (MapViewPaintable mvp : temporaryLayers) {
            mvp.paint(tempG, this);
        }

(and after)
        Graphics2D tempG = offscreenBuffer.createGraphics();
        tempG.setColor(Main.pref.getColor("background", Color.BLACK));
        tempG.fillRect(0, 0, getWidth(), getHeight());
        Bounds box = getLatLonBounds(g.getClipBounds());
        for (Layer l: getVisibleLayersInZOrder()) {
            l.paint(tempG, this, box);
        }
        for (MapViewPaintable mvp : temporaryLayers) {
            mvp.paint(tempG, this, box);
        }

The problem is this new call of getLatLonBounds() with random east,
north values the first time a new layer is added. With the Lambert
zone projections, I use the first calls to the projection methods to
automagically determin the Lambert zone (in Lambert CC 9 zones, the
zone is 1 for north values around 1.000.000, the zone is 2 for north
values around 2.000.000, etc). It just ignores values outside the
projection (for instance, for the first latlon<->eastnorth convertions
called with the world bounds).
Now, the first call of EastNorth2latlon is done with east, north
values which looks "correct" but are in the wrong Lambert zone:
in MapView.getLatLonBounds(), we pass a
Rectangle[x=0,y=0,width=900,height=873] which gives
EastNorth[e=1245767.0463764844, n=1285470.7852088492].
Then the projection is switching to the Lambert zone 1 when the first
layer is opened. And I cannot ask the plugin cadastre-fr to change
again the projection zone once there is something present in a layer.
So, I don't know how this issue could be fixed.

Pieren




More information about the josm-dev mailing list