Modify

Opened 11 hours ago

Last modified 4 hours ago

#24678 new enhancement

[PATCH] Possibility to specify custom MapPaintSettings for MapCSS rendering.

Reported by: zkir Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: MapCSS, MapPaintSettings, StyledMapRenderer, UrbanEye3D Cc:

Description

Problem

The UrbanEye3D plugin provides a 3D rendering of OSM data. To display the ground, it uses JOSM's RenderingHelper and StyledMapRenderer to render a 2D map image(s) with a custom MapCSS style.

The problem is, that the global JOSM preferences from OSM Data tab (e.g. "Draw oneway arrows", "DrawSegment numbers", mappaint.shownames ), are affecting rendering in 3D window also.
This is not a desired behaviour, and it looks quite surprising. Style for the groundplane in 3D window was designed to look "realistic", and all titles and arrows were excluded from it.
However, they reappear if the settings in question are activated. (see screenshots).

Proposed Solution

The proposed solution introduces a mechanism to create and use a "neutral" set of MapPaintSettings for the rendering process, ensuring it is independent of global user preferences.
The patch is composed of three main changes:

  1. In MapPaintSettings.java:
    • A new public constructor is added to allow for the creation of custom MapPaintSettings instances.
    • A new static factory method, createNeutralSettings(), is introduced. This method returns a settings object specifically configured to be non-intrusive for realistic rendering. It disables settings that add symbolic cartographic elements (e.g., showDirectionArrow=false, showOnewayArrow=false, showNamesDistance=0), while inheriting other defaults (like colors and node sizes) from the global INSTANCE.
  1. In StyledMapRenderer.java:
    • A new constructor is added that accepts a MapPaintSettings object.
    • The getSettings() method is updated to use these custom settings if they are provided. If no custom settings are passed, it falls back to the global MapPaintSettings.INSTANCE to maintain existing behavior.
  1. In RenderingHelper.java:
    • The class is updated to take advantage of the new mechanism. It now instantiates StyledMapRenderer with the neutral settings provided by MapPaintSettings.createNeutralSettings().

Performance and memory impact

  • No negative performance impact. No addtional operations or activites are added.
  • Additional instance of MapPaintSettings is created, but only if RenderingHelper is used. In normal scenario there is no additional memory consumption.

Attachments (3)

patch-24678.diff (20.6 KB ) - added by zkir 11 hours ago.
24678-pic.png (653.6 KB ) - added by zkir 11 hours ago.
patch-24678-v2.diff (9.8 KB ) - added by zkir 4 hours ago.
Patch, version 2, much shorter.

Download all attachments as: .zip

Change History (6)

by zkir, 11 hours ago

Attachment: patch-24678.diff added

by zkir, 11 hours ago

Attachment: 24678-pic.png added

comment:1 by stoecker, 10 hours ago

Whoa. Is there no better way than creating a function with a zillion arguments? setXXX() instead?

comment:2 by stoecker, 10 hours ago

BTW: That function will break all the time and thus is not a good interface for a plugin.

by zkir, 4 hours ago

Attachment: patch-24678-v2.diff added

Patch, version 2, much shorter.

comment:3 by zkir, 4 hours ago

OK, it was not the best idea.
How about this variant?

It is much shorter and more close to the point: non relevant settings are overridden.

If you approve creation of setters for only fields in question (7 out of 27, which is strange a bit for me), I will do that and move the fabric method directly to the RenderingHelper class.

If I am missing something obvious, please advise.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to zkir.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


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