Opened 6 years ago

Last modified 6 years ago

#18468 closed enhancement

[Patch] Text Rotation in MapCSS — at Version 16

Reported by: BrackoNe Owned by: team
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

Change History (21)

by BrackoNe, 6 years ago

Attachment: 44.6730752-20.6034399.png added

Samples of Content Aware traffic signs in MapStyle.

by simon04, 6 years ago

Attachment: 18468.patch added

comment:1 by simon04, 6 years ago

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

Draft patch: attachment:18468.patch

The rotation centre is might need to be adapted…ç

by simon04, 6 years ago

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

comment:2 by Don-vip, 6 years ago

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

comment:3 by BrackoNe, 6 years ago

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 by BrackoNe, 6 years ago

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 6 years ago by simon04 (previous) (diff)

comment:5 by Klumbumbus, 6 years ago

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

comment:6 by BrackoNe, 6 years ago

Oh, sorry for that.

by simon04, 6 years ago

Attachment: 18468-v2.patch added

by simon04, 6 years ago

comment:7 by simon04, 6 years ago

@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 by BrackoNe, 6 years ago

Any update on this? Thanks in advance.

comment:9 by Don-vip, 6 years ago

Milestone: 20.03

in reply to:  7 comment:10 by simon04, 6 years ago

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 by simon04, 6 years ago

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 by Don-vip, 6 years ago

In 16094/josm:

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

comment:13 by Don-vip, 6 years ago

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 by simon04, 6 years ago

In 16100/josm:

see #18468 - MapCSSRendererTest: generate style debugging output

comment:15 by simon04, 6 years ago

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 by Don-vip, 6 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.