NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am trying write render for OSM on C#. I haven't trouble with drawing areas, house and roads, but i can't understand how drawing street names. Can you tell me algorithm for drawing label street. Or specify on opensource project where i can read them.

asked 24 May '13, 08:43

amirkin's gravatar image

amirkin
11112
accept rate: 0%


I don't no of a specific one but if it was a programming problem given to me I'd first work out the style I wanted to achive do I need it writen in a straight line or bending with the road if its a straight line do I need it spun around to lie in some relation to the road or just lying to the alignment of the paper with no regard to the road direction.

Once I'd worked out the co-ordenates that line goes and chosen a point lying along the line to act as a base point. I could then work out the angle of the line and corrisponding angle that my style would like to offset the text away from the road. Find cordinates for that offset line then referance the straight txt to that point in the normal method your graphics system dose it (note text base point might need a conversion if the offset point is say to the middle of the text and the graphics system uses the start of the line. Now thats the easy option sort of described how to do genericly to do curves I'd get the system to calculate multiple offset lines around the point I want the text to go then form a curve onto those end points and then try either a built in option to place text on a curve or without that luxuary I'd try playing at putting each letter and symbol at a point given along the dirved line note I'd think of spaceing futher along the line when the curve is tight or the relitive dictance between each letter looks mathimaticaly to small (ie too close).

I've not done it for real yet but hopefully these ideas might help you sus out your problem remeber its mainly geomatry and commonsence in graphics ploting.

Goodluck!

permanent link

answered 20 Apr '15, 21:54

Govanus's gravatar image

Govanus
1543711
accept rate: 3%

Drawing labels is indeed difficult but you can take a look at one of the many rendering softwares available for OSM to get an idea. According to this list there is no open source rendering software for OSM written in C# yet.

permanent link

answered 24 May '13, 09:01

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

edited 24 May '13, 09:18

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×219
×142
×86

question asked: 24 May '13, 08:43

question was seen: 5,364 times

last updated: 20 Apr '15, 21:54

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum