Modify

Opened 15 years ago

Closed 15 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 15 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by jttt, 15 years ago

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 by stoecker, 15 years ago

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

comment:3 by jttt, 15 years ago

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

comment:4 by stoecker, 15 years ago

Yes.

comment:5 by pieren, 15 years ago

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

by pieren, 15 years ago

Attachment: NTV2Grid.patch added

comment:6 by pieren, 15 years ago

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

in reply to:  6 comment:7 by pieren, 15 years ago

Replying to pieren:

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

Ooops, wrong ticket.

comment:8 by jttt, 15 years ago

Owner: changed from team to pieren
Status: newneedinfo

Can this ticket be closed?

comment:9 by pieren, 15 years ago

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. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.