Modify

Opened 2 years ago

Closed 20 months ago

Last modified 19 months ago

#18468 closed enhancement (fixed)

[Patch] Text Rotation in MapCSS

Reported by: BrackoNe Owned by: simon04
Priority: normal Milestone: 20.05
Component: Core mappaint Version: tested
Keywords: text; rotation; style Cc:

Description (last modified by Don-vip)

Hi!

I would like most kindly to ask if it is possible to add a support to rotate the text within the map style in JOSM.

I would propose to use text-rotation:"0.05"; which is as same as icon-rotation:"0.05";

I'm creating content-aware traffic signs which are available at the following location:
https://github.com/BrackoNe/rs_traffic_signs

For the traffic sign which represents ascent or descent (RS:I-3 and RS:I-4), text rotation is necessary:
https://en.wikipedia.org/wiki/File:Mauritius_Road_Signs_-_Warning_Sign_-_Dangerous_Descent.svg

Thank you in advance,
Nemanja

Attachments (5)

44.6730752-20.6034399.png (182.5 KB) - added by BrackoNe 2 years ago.
Samples of Content Aware traffic signs in MapStyle.
18468.patch (7.8 KB) - added by simon04 23 months ago.
2020-01-15_22-05.png (1.6 KB) - added by simon04 23 months ago.
18468-v2.patch (10.2 KB) - added by simon04 23 months ago.
MapCSSRendererTest-fails.zip (518.2 KB) - added by simon04 23 months ago.

Download all attachments as: .zip

Change History (25)

Changed 2 years ago by BrackoNe

Attachment: 44.6730752-20.6034399.png added

Samples of Content Aware traffic signs in MapStyle.

Changed 23 months ago by simon04

Attachment: 18468.patch added

comment:1 Changed 23 months ago by simon04

Summary: Text Rotation in MapCSS[Patch] Text Rotation in MapCSS

Draft patch: attachment:18468.patch

The rotation centre is might need to be adapted…ç

Changed 23 months ago by simon04

Attachment: 2020-01-15_22-05.png added

comment:2 Changed 23 months ago by Don-vip

Did you check that MapCSSRendererTest did not require any change? I would find it surprising.

comment:3 Changed 23 months ago by BrackoNe

I'm afraid that I'm not aware of it. I was using a wiki page where you can see all MapCSS objects and I have used it in process of creating this paint style. Can you be more specific, please?

comment:4 Changed 23 months ago by BrackoNe

This is one traffic sign:

node|z-15["traffic_sign:background"="yellow"]["side"="left"]["distance_ahead"]::background3_sign_layer_bckground{
  text:"distance_ahead";
  text-color: black;
  text-anchor-vertical: center;
  text-anchor-horizontal: center;
  font-size:"2";
  font-weight:"bold";
  text-offset-x:"-11";
  text-offset-y:"-8";
  icon-offset-x:"-10";
  icon-offset-y:"1";
  icon-width:"15";
  icon-image:"RS/yellow_single.png";
}

If I need to use icon rotation, I would use: icon-rotation: command, as it is stated here: https://josm.openstreetmap.de/wiki/Help/Styles/MapCSSImplementation, in section Icon and symbol styles

I have tried text-rotation, but it is not possible, I'm not sure how to use MapCSSRendererTest and is it possible to combine with this "classic" MapCSS file?

Thanks in advance,
Nemanja

Last edited 23 months ago by simon04 (previous) (diff)

comment:5 Changed 23 months ago by Klumbumbus

@BrackoNe: comment:2 was addressed to simon04. No action from your side required atm.

comment:6 Changed 23 months ago by BrackoNe

Oh, sorry for that.

Changed 23 months ago by simon04

Attachment: 18468-v2.patch added

Changed 23 months ago by simon04

comment:7 Changed 23 months ago by simon04

@team, can someone please review attachment:18468-v2.patch

The MapCSSRendererTest test fails on my system also without this patch applied. Here are the generated PNG files: attachment:MapCSSRendererTest-fails.zip

comment:8 Changed 22 months ago by BrackoNe

Any update on this? Thanks in advance.

comment:9 Changed 22 months ago by Don-vip

Milestone: 20.03

comment:10 in reply to:  7 Changed 21 months ago by simon04

Replying to simon04:

The MapCSSRendererTest test fails on my system also without this patch applied. Here are the generated PNG files: attachment:MapCSSRendererTest-fails.zip

What's the font used in source:trunk/test/data/renderer/node-text2/reference.png
When debugging MapCSSRendererTest[node-text2], font in org.openstreetmap.josm.gui.mappaint.styleelement.TextLabel#create is java.awt.Font[family=Droid Sans,name=Droid Sans,style=plain,size=10], but the test fails.

comment:11 Changed 21 months ago by simon04

Vincent, would you please help me with the unit test and let me know the required font. Simply, by setting a breakpoint in org.openstreetmap.josm.gui.mappaint.styleelement.TextLabel#create for the font variable. Thanks!

comment:12 Changed 21 months ago by Don-vip

In 16094/josm:

see #18468 - make MapCSSRendererTest run on Windows when JAVA_HOME points to an AdoptOpenJDK installation

comment:13 Changed 21 months ago by Don-vip

The font on my system is java.awt.Font[family=Dialog,name=Droid Sans,style=plain,size=10] and it fails too.

I retrieve the reference data on JOSM server from Jenkins, I guess we should add logs so that the exact font can be retrieved in the test output.

comment:14 Changed 21 months ago by simon04

In 16100/josm:

see #18468 - MapCSSRendererTest: generate style debugging output

comment:15 Changed 21 months ago by simon04

https://josm.openstreetmap.de/jenkins/job/JOSM/lastCompletedBuild/jdk=JDK8/testReport/org.openstreetmap.josm.gui.mappaint/MapCSSRendererTest/testRender_node_text2_/

...[truncated 5558 chars]...
rategy={DeriveLabelFromNameTagsCompositionStrategy} font=java.awt.Font[family=Dialog,name=Droid Sans,style=plain,size=10] color=#ffd700 box=java.awt.Rectangle[x=-25,y=-25,width=50,height=50] hAlign=CENTER vAlign=ABOVE xOffset=0 yOffset=0}

Still not much clearer …

comment:16 Changed 21 months ago by Don-vip

Description: modified (diff)

comment:17 Changed 20 months ago by simon04

Milestone: 20.0320.04
Owner: changed from team to simon04
Status: newassigned

comment:18 Changed 20 months ago by simon04

Resolution: fixed
Status: assignedclosed

In 16253/josm:

fix #18468 - MapCSS: add support for text-rotation

comment:20 Changed 19 months ago by Klumbumbus

Milestone: 20.0420.05

Milestone renamed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain simon04.
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.