Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS no longer works #25

Closed
a-pirard opened this issue Oct 24, 2016 · 18 comments
Closed

AS no longer works #25

a-pirard opened this issue Oct 24, 2016 · 18 comments
Assignees
Labels

Comments

@a-pirard
Copy link

Since an unknown time, Area Selector no longer works. It draws 4 ways at the border of the window.
Neither with BE SPW PICC, nor with BE AGIV I was told, and not even as I can see with AT basemat.at which is your testbed I think.
I don't think the problem occurred with an AS update but rather with a JOSM one.
I ran josm-snapshot-10693.jar and AS did run, but very badly again.
It does not draws its ways onto the building walls but around them.
However, that shows better some interested friends what they will have when it will run superbly again.
TIA for fixing this !!!

@r00tat
Copy link
Contributor

r00tat commented Oct 25, 2016

Sounds like the layers are not rendered correctly. I'll try to look into it this weekend!

@r00tat r00tat added the bug label Oct 25, 2016
@r00tat r00tat self-assigned this Oct 25, 2016
@r00tat
Copy link
Contributor

r00tat commented Oct 25, 2016

#24 might also be related

@a-pirard
Copy link
Author

Would it help you if I dichotomically tried other JOSM versions and found the last working one and hence the version introducing incompatibility? It would be a workaround, too.

@a-pirard
Copy link
Author

I replied by e-mail but it didn't go through. So, here's a copy&paste.

Hi Paul,

I made those tests and I determined that JOSM started drawing on the window border beginning with josm-snapshot-10819.jar.
But before that, ending with 10799, the way it draws is something oval around and far from the walls.
So, I didn't find the workaround I was looking for.
The complete list of my tests is below.
I hope it will help you somehow.

Cheers

André.

10693 oval
10753 oval
10786 oval
10797 oval
10799 oval
10819 border
10929 border
11163 border

@a-pirard
Copy link
Author

On 2016-10-25 17:52, a-pirard wrote:

Would it help you if I dichotomically tried other JOSM versions and
found the last working one and hence the version introducing
incompatibility? It would be a workaoval, too.

Hi Paul,

I made those tests and I determined that JOSM started drawing on the
window border beginning with josm-snapshot-10819.jar
https://josm.openstreetmap.de/download/josm-snapshot-10819.jar.
But before that, ending with 10799, the way it draws is something oval
around and far from the walls.
So, I didn't find the workaround I was looking for.
The complete list of my tests is below.
I hope it will help you somehow.

Cheers

André.

10693 oval
10753 oval
10786 oval
10797 oval
10799 oval
10819 border
10929 border
11163 border

@r00tat
Copy link
Contributor

r00tat commented Nov 6, 2016

I did some debugging and found that the layers are not painted to the image.

This is the line, which no longer works:
AreaSelectorAction Line 160

layer.paint(imgGraphics, mapView, mapView.getRealBounds());

I'll try to find out what has changed in JOSM core with the help of the revisions you mentioned.

@r00tat
Copy link
Contributor

r00tat commented Nov 6, 2016

looks like the AbstractTileSourceLayer does not draw any more via paint:

    @Override
    public void paint(Graphics2D g, MapView mv, Bounds bounds) {
        // old and unused.
    }

Drawing is now done via doPaint and drawInView in AbstractTileSourceLayer

        private void doPaint(MapViewGraphics graphics) {
            drawInViewArea(graphics.getDefaultGraphics(), graphics.getMapView(), graphics.getClipBounds().getProjectionBounds());
        }

The problem is, that drawInViewArea is private, so this method cannot be used to get the imagery.

@don-vip I saw you made the changes to AbstractTileSourceLayer. As painted is deprecated and drawInViewArea is deprecated, how can the imagery be accessed via plugin?

@a-pirard
Copy link
Author

a-pirard commented Nov 6, 2016

Thanks for working on this, Paul !!!

As we are deep in the subject, may I please mention #20 which I meant not as a question but as a suggestion. If I'm correct: Distance tolerance setting should be in cm.
Because different zooms produce different results, I think that you are working on the zoomed image, not on the server's image.
Hence, the tolerance dots numbers must be zoomed too (multiplied by the level) and you must say to which zoom the setting applies.
Or the setting should be in cm that need no explanation and that you must convert to the correct dot numbers at each zoom level.
Duplicating this comment to #20.

@don-vip
Copy link
Contributor

don-vip commented Nov 7, 2016

@michaelzangl it seems I have broken AreaSelector plugin with core compatibility changes, do you see how to fix it?

@r00tat
Copy link
Contributor

r00tat commented Nov 7, 2016

@don-vip @michaelzangl the easiest solution would be to call drawInViewArea in paint. I don't know if that has any side effects.

@r00tat
Copy link
Contributor

r00tat commented Nov 7, 2016

I tested reimplementing paint and it looks like this will work fine.

This is my fix:

    @Override
    public void paint(Graphics2D g, MapView mv, Bounds bounds) {
        // old and unused.
        drawInViewArea(g, mv, mv.getProjectionBounds());
    }

@michaelzangl
Copy link

michaelzangl commented Nov 7, 2016

This won't help much. As soon as #13386 is implemented, it won't work any more ;-).

The changes were intended to make JOSM support multiple map views. All layers should use the attachToMapView(MapViewPaintable.MapViewEvent event) method. It receives the map view instance and is called as soon as the map view is created. paint is still called by the map view if no other implementation is present.

It should return a MapViewPaintable.LayerPainter. You can move methods like getLayeredImage, ... there. That way, you do not need any global Main.map.mapView references. Nice side effect: If you do not keep any references to it (listeners, ...) it gets garbage collected as soon as the map view is destroyed.

There is currently no way to access the paintes that are used by the current map view.

You would need to access the registeredLayers field. The best way would be to make the method paintLayer accessible. I'd suggest creating a new method. Bounds can be computed automatically.

public void paintLayers(Iterable<? extends Layer> layer, Graphics2D g);

Would this be enough for you?

Some more notes while looking at your code:
getLayeredImage: You can use getVisibleLayersInZOrder(), then only filter for background layers.

createArea(): You can use the JOSM preference system for this. We use '.' to separate child preferences, but this is just a convention. You can use Boolean/Integer/String/... preferences.

KEY_TOLERANCEDIST = "areaselector.tolerancedist";
TOLERANCEDIST = new DoubleProperty(KEY_TOLERANCEDIST, DEFAULT_TOLERANCEDIST);
...
distMeters = TOLERANCEDIST.get(); // no try/catch, no if/else.

@r00tat
Copy link
Contributor

r00tat commented Nov 7, 2016

Once there are multiple mapViews possible, there should be a way to access the active mapView from a plugin. I suppose there is an idea how to handle that, right?

I believe it would be better to provide a method to paint one layer, not all together in one method. A plugin might want to access only specific layers and therefore the existing paint function would is easy to use.

Regarding getLayeredImage:
Thanks, Done. (d57f588)

Regarding the preferences:
Thank's for your suggestion, I'll change it. It makes the code way more readable.

@r00tat
Copy link
Contributor

r00tat commented Nov 7, 2016

I just looked at paintLayerin MapView and providing access to that method would help.
Providing a method to paint multiple layers at once or not is more a matter of code style or personal taste.

@michaelzangl
Copy link

There you go:

https://josm.openstreetmap.de/changeset/11226/josm

It is best to feed it with the layers obtained using: mapView.getLayerManager().getVisibleLayersInZOrder()

Let me know if there are any issues with using the method.

@r00tat r00tat closed this as completed in ae81ffe Nov 10, 2016
@r00tat
Copy link
Contributor

r00tat commented Nov 10, 2016

Thanks @michaelzangl for implementing the new method in JOSM core!

@a-pirard
Copy link
Author

On 2016-11-10 19:31, Paul wrote:

Closed #25 #25 via
ae81ffe
ae81ffe.
Thanks @michaelzangl https://github.com/michaelzangl for
implementing the new method in JOSM core!
You JOSM people are great people, really. THANKS !!!!
I wish everybody doing serious work were using it.

Are we supposed to use (test) it right now?
I ran josm-snapshot-11227, updated the plugins and it contoured the
whole window again.

Additionally, when activating my layer, I get the following dialog:

The layer BE SPW PICC 0 does not support the new projection EPSG:3857.
Supported projections are:
Change the projection again or remove the layer.
(copy&paste not invented yet, middle-age copying used)

"OK" and the layer seems to display all right, though. It's definition:

wms:http://geoservices.wallonie.be/arcgis/rest/services/TOPOGRAPHIE/PICC_VDIFF/MapServer/export?&f=image&format=png8&dpi=90&transparent=True&SRS={proj}&bboxSR={wkid}&imageSR={wkid}&bbox={bbox}&size={width},{height}&layers=hide:0,12,26
THANKS !!!!

Cheers
Cordialement,

André.

@r00tat
Copy link
Contributor

r00tat commented Nov 10, 2016

I just released the new plugin version, it should be available in the plugin section in a few minutes.

The minimum JOSM version is now 11226.

The projection error message is something from an update from JOSM core, not by the plugin.

simon04 pushed a commit to JOSM/josm that referenced this issue Nov 17, 2016
This allows plugins like the areaselector to access the drawing code of the map view.

See JOSM/areaselector#25



git-svn-id: http://josm.openstreetmap.de/svn/trunk@11226 0c6e7542-c601-0410-84e7-c038aed88b3b
floscher pushed a commit to floscher/josm that referenced this issue Nov 19, 2018
This allows plugins like the areaselector to access the drawing code of the map view.

See JOSM/areaselector#25



git-svn-id: https://josm.openstreetmap.de/svn/trunk@11226 0c6e7542-c601-0410-84e7-c038aed88b3b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants