Modify

Opened 8 years ago

Closed 8 years ago

#3987 closed defect (fixed)

Recent change in MapView creating problems in projections

Reported by: pieren Owned by: pieren
Priority: blocker Milestone:
Component: Core Version: latest
Keywords: Cc:

Description

A recent change in Mapview.java (rev.2450) by "jttt" introduces a
problem with the Lambert projections.

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. It's not exactly random as the values are based on the screen width and height !

The solution is not to ignore those values in the projection implementation when they are outside the box otherwise I cannot warn the user when he is really working outside the projection limits.

This problem is also independent of the subprojection things to do. It is currently blocking the cadastre-fr plugin working only with the concerned projections.

Attachments (1)

NTV2Grid.patch (38.2 KB) - added by pieren 8 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by jttt

The value is not random (and it's not a bug afaik), it's bbox arount default center, calculated by NavigatableComponent.calculateDefaultCenter(). Default center is calculated as:

        Bounds b = Main.proj.getWorldBoundsLatLon();
        double lat = (b.getMax().lat() + b.getMin().lat())/2;
        double lon = (b.getMax().lon() + b.getMin().lon())/2;

        return Main.proj.latlon2eastNorth(new LatLon(lat, lon));

Problem here is that first call of MapView.paint is before any data are loaded. As a workaround I can check whether there is any non empty OsmDataLayer and if not then use whole world bounds instead of value calculated by getLatLonBounds().

But that seems a bit hackish, I would preferer if all Projections returned polygon where the projection is valid and center point of that polygon.

comment:2 Changed 8 years ago by stoecker

When the world bounds are fixed to be proper for all the relevant projections, then this code should return valid coordinates.

comment:3 Changed 8 years ago by jttt

What does the value returned by getWorldBoundsLatLon() means? Is it bbox where projection is valid?

comment:4 Changed 8 years ago by stoecker

Yes.

comment:5 Changed 8 years ago by pieren

In ticket #3989, I added a better support of getWorldBoundsLatLon() in the patches to apply.

Changed 8 years ago by pieren

Attachment: NTV2Grid.patch added

comment:6 Changed 8 years ago by pieren

I've attached a patch file "NTV2Grid.patch". Sorry about that.

comment:7 in reply to:  6 Changed 8 years ago by pieren

Replying to pieren:

I've attached a patch file "NTV2Grid.patch". Sorry about that.

Ooops, wrong ticket.

comment:8 Changed 8 years ago by jttt

Owner: changed from team to pieren
Status: newneedinfo

Can this ticket be closed?

comment:9 Changed 8 years ago by pieren

Resolution: fixed
Status: needinfoclosed

Should be fixed with #3989

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain pieren.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.