Expression in Style Editor for Text Alignment in Map 3D

Expression in Style Editor for Text Alignment in Map 3D

chetanpatelK2URY
Explorer Explorer
205 Views
4 Replies
Message 1 of 5

Expression in Style Editor for Text Alignment in Map 3D

chetanpatelK2URY
Explorer
Explorer

I am trying to create a simple .dwg from OS map data, which will have the topographic lines and cartographic text (cartographic symbols is a battle for another day) but can't find a guide anywhere. I've added the data, “cartographic_text_subregion_point”, to Map 3D from my PostgreSQL connection.

 

Using Style Editor, I've changed the standard symbol to MTEXT to show the OS map text (e.g. the road name) using the "textstring" property of the feature. If I try showing the text using Feature Label, I can't set the insertion offset and text alignment using the feature properties in the map data (and the label disappears if I accepted having the text in the centre of the point - although the solution I found online seems cumbersome).

 

chetanpatelK2URY_1-1755780441861.png

Using expressions, I can set the font size ("height) , rotation ("rotation") , and insertion offsets ("geo_x" and "geo_y").

chetanpatelK2URY_0-1755780304468.png

However, I can't figure out the expressions for the vertical and horizontal alignments for the text. The feature property "anchor" determines this but my OS map data uses compass orientations e.g. N, NW, C (centre), S, etc. while Map 3D uses Left, Right, Top, Halfline, etc. I've tried the following expressions which end up being valid, but don't end up working.

 

Attempt 1: The OR function doesn't work in the IF function (although the expression is valid) and all text ends up (horizontally) aligned in the centre.

 

(If('anchor=''C''OR''N''OR''S''','Center',' ')) (If('anchor=''NW''OR''W''OR''SW''','Left',' '))

 (If('anchor=''NE''OR''E''OR''SE''','Right',' '))

 

If I try using an OR function between each IF function I get an error. Not sure how I should be using the OR function here. 

chetanpatelK2URY_2-1755781594782.png

 

Attempt 2: Instead of using an OR function in the IF function, I have expressions for each. This doesn't work because only the first IF function is applied, and all other text is center aligned, even if I don't use 'Center' in the expression.    

(If('anchor=''C''','Center',' ')) (If('anchor=''N''','Center',' ')) (If('anchor=''S''','Center',' ')) (If('anchor=''NW''','Left',' ')) (If('anchor=''W''','Left',' ')) (If('anchor=''SW''','Left',' ')) (If('anchor=''NE''','Right',' ')) (If('anchor=''E''','Right',' ')) (If('anchor=''SE''','Right',' '))

chetanpatelK2URY_3-1755782112154.png

chetanpatelK2URY_4-1755782630269.png

 

Any help will be greatly appreciated.

 

0 Likes
Accepted solutions (2)
206 Views
4 Replies
Replies (4)
Message 2 of 5

O_Eckmann
Mentor
Mentor
Accepted solution

Hi @chetanpatelK2URY ,

 

You could use Lookup like this

 Lookup (  ANCHOR , 'Center', 'W', 'Left', 'SW', 'Left', 'NW', 'Left', 'C', 'Center', 'N', 'Center', 'S', 'Center', 'E', 'Right', 'NE', 'Right', 'SE', 'Right') 

Olivier Eckmann

EESignature

0 Likes
Message 3 of 5

ChicagoLooper
Mentor
Mentor

Hi @chetanpatelK2URY 

I fell your pain. Creating text labels with an expression can get wonky. Map3D doesn't provide user friendly controls. Keep an open mind to get map done. Why? Because Map3D doesn't like your workflow. Don't get me wrong, Map3D likes you, but not your workflow. You wrote:

 

<< I've changed the standard symbol to MTEXT to show the OS map text (e.g. the road name) using the "textstring" property of the feature. >>

 

Using a textstring is to label your lines is what the cool kids use. Unfortunately, M3D isn't sophisticated enough understand what cool kids do. He's too geeky. You'll need to dial back fancy ESRI-esque textstrings and substitute far simpler operation. Yes, simple means you'll might, or might not, have to perform additional steps, but in the end, you'll have mtext which will be manageable on a ByLayer basis. And they'll be properly rotated too.

 

<<If you are labeling topo lines, then you want the label to fall directly on the contour. Not offset! Label only the major contours and keep the minors unlabeled. The reader can figure out elevation of the minors. If you are labeling streets, it's best to use the centerline to represent a street and not two lines the marks the left and right edge of the roadway. Making a street label fall in the middle of the road, in between the two curbs, will get nasty because street widths vary and M3D doesn't want to (doesn't like to) determine the middle of a 4-lane or 2-lane road. Don't expect M3D to determine placement of labels based on road width. Just use a single line, e.g. the street centerline. M3D will place the label on the line and rotate it runs in the same direction as the line.>> 

 

Here's an old >>VIDEO<< (a-blast-from-the-past) that's demonstrates how to use a Feature Data Object (FDO) connection to bring in the linework and create labels. The video also shows how to convert the FDO labels into mtext. Since the FDO labels run in the same direction as the line, the mtext, after conversion, will too. No custom textstring is needed.

 

101_DEMO.png

 

     

Chicagolooper

EESignature

0 Likes
Message 4 of 5

chetanpatelK2URY
Explorer
Explorer
Accepted solution

THANK YOU so much @O_Eckmann,

 

This worked. I changed ANCHOR to "anchor" to match the feature property (i.e. case sensitive). I also removed the default value to nothing (although I don't know if that makes a difference, unless OS have any features that haven't defined the "anchor" position).

 

For the horizontal alignment, the code I've used is:

Lookup (   anchor , ' ', 'W', 'Left', 'SW', 'Left', 'NW', 'Left', 'C', 'Center', 'N', 'Center', 'S', 'Center', 'E', 'Right', 'NE', 'Right', 'SE', 'Right')

 

For the vertical alignment, the code I've used is:

 

Lookup (   anchor , ' ', 'NW', 'Top', 'N', 'Top', 'NE', 'Top', 'W', 'Halfline', 'C', 'Halfline', 'E', 'Halfline', 'SW', 'Bottom', 'S', 'Bottom', 'SE', 'Bottom')

 

chetanpatelK2URY_0-1755858564942.png

 

0 Likes
Message 5 of 5

chetanpatelK2URY
Explorer
Explorer

Hi @ChicagoLooper,

 

Thanks for your reply. There are OS map data where the e.g. road names are line data positioned centre of the road, however, this wouldn't include other cartographic text e.g. building names. I haven't fully tested using different OS map data, so it might be something to consider/test in the future.

0 Likes