File: ogr_feature_style.html

package info (click to toggle)
gdal 2.4.2+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 106,252 kB
  • sloc: cpp: 1,034,818; ansic: 177,912; python: 23,610; perl: 7,420; sh: 6,283; java: 5,382; xml: 3,100; cs: 2,343; yacc: 1,198; makefile: 519; sql: 112
file content (1049 lines) | stat: -rw-r--r-- 39,618 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<HTML>
<HEAD>
   <TITLE>GDAL - Feature Style Specification</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">

<CENTER>
<H1>
GDAL - Feature Style Specification</H1></CENTER>

<CENTER>
  <H2>Version 0.016 - 2018-12-03</H2>
</CENTER>

<HR WIDTH=50%>
<H2>REVISION HISTORY</H2>
<UL>
<LI><B>Version 0.016 - 2018-12-03 - Andrew Sudorgin</B><BR>
    Restored and documented font property for point symbols
<LI><B>Version 0.015 - 2018-01-08 - Alan Thomas</B><BR>
    Update outdated material; minor changes to BRUSH 'id' and LABEL 't', 'bo', 'it', 'un', 'st'; clarify BRUSH 'fc', 'bc', SYMBOL 'o' and LABEL 's', 'w', 'p'
<LI><B>Version 0.014 - 2011-07-24 - Even Rouault</B><BR>
    Mention the escaping of double-quote characters in the text string of a LABEL (ticket #3675)
<LI><B>Version 0.013 - 2008-07-29 - Daniel Morissette</B><BR>
    Added 'o:' for font point symbol outline color (ticket #2509)
<LI><B>Version 0.012 - 2008-07-21 - Daniel Morissette</B><BR>
    Added 'o:' for text outline color and updated 'b:' to be specifically
    a filled label background box (ticket #2480)
<LI><B>Version 0.011 - 2008-02-28 - Tamas Szekeres</B><BR>
    Note about OGR SQL to transfer the style between the data sources
<LI><B>Version 0.010 - 2006-09-23- Andrey Kiselev</B><BR>
    Added label styles 'w', 'st', 'h', 'm:h', 'm:a', 'p:{10,11,12}'
<LI><B>Version 0.009 - 2005-03-11- Frank Warmerdam</B><BR>
    Remove reference to OGRWin, move into ogr distribution
<LI><B>Version 0.008 - 2001-03-21- Frank Warmerdam</B><BR>
    Fix minor typos (h:12pt instead of s:12pt in examples)
<LI><B>Version 0.008 - 2000-07-15 - Stephane Villeneuve</B><BR>
    Remove style table in Layer.  Add forecolor and backcolor to brush.
<LI><B>Version 0.007 - 2000-06-22 - Daniel Morissette</B><BR>
    Fixed typo and added offset param for PEN.
<LI><B>Version 0.006 - 2000-06-20 - Daniel Morissette</B><BR>
    Added the OGR-Win idea and made small changes here and there.
<LI><B>Version 0.005 - 2000-06-12 - Daniel Morissette</B><BR>
    Allow passing of comma-delimited list of names in PEN's "id" parameter.<BR>
    Defined system-independent pen style names.
<LI><B>Version 0.004 - 2000-06-09 - Stephane Villeneuve</B><BR>
    Added PEN cap and join parameters<BR>
    More clearly defined the API
<LI><B>Version 0.003 - 2000-02-15 - Daniel Morissette</B><BR>
    First kind-of-complete version.
<P>

</UL>

<HR WIDTH=50%>
<H2>
1. Overview</H2>
This document defines the way feature style information (i.e. colors, line
width, symbols, etc.) should be handled at the various levels in GDAL's
vector drivers (OGR).
<P>The following GDAL vector drivers have varying levels of support
for feature styles:
<a href="drv_cad.html">DWG (libopencad)</a>,
<a href="drv_dwg.html">DWG (Teigha)</a>,
<a href="drv_dxf.html">DXF</a>,
<a href="drv_libkml.html">KML (libkml)</a>,
<a href="drv_mitab.html">MapInfo</a>,
<a href="drv_dgn.html">MicroStation DGN v7</a> and
<a href="drv_dgnv8.html">DGN v8</a>,
<a href="drv_jml.html">OpenJUMP JML</a> and
<a href="frmt_pdf.html">PDF</a>.
<H3>
1.1 Style is a property of Feature object</H3>
Conceptually, the feature style should be seen as a property of a feature.
Even though some systems store style information in a special attribute,
in GDAL it is more consistent to see the style as a property, just the same
way the geometry of a feature is also a property.
<P>This does not prevent us from storing the style information in an attribute
when writing to some formats that have no provision for styles (e.g. E00).
But then at the time such a dataset is opened through GDAL, the name of
the attribute that contains style information should either be specified
in some metadata, or be specified by the user.
<P>Also, in the SFCOM interface, the style information will be stored in
an attribute just like the geometry is.
<H3>
1.2 Feature Styles can be stored at 2 levels</H3>
The style defines the way a feature should be drawn, but it is very common
to have several features that share the same style. In those cases, instead
of duplicating the style information on each feature, we will provide a
more efficient way to share style information.
<P>There are two levels at which style information can be found:
<UL>
<LI>
A <B>dataset</B> can have a table of pre-defined styles that can then be referred
to by the layers or by the individual features. The mechanism for that is defined
further down in this document.

<LI>
A <B>feature (OGRFeature object)</B> can have its own complete style definition.
Alternatively, a feature can be linked to a style in the dataset's table of styles.
This can save storage space when the same styles are reused often.

</UL>
It should be possible to have style information stored at one or more of
the various levels while working on a given dataset. The level(s) where
the style is actually stored will depend on the most efficient approach
for the format we are dealing with.

<H3>
1.3 Drawing Tools</H3>
We define a small set of drawing tools that are used to build style definitions:
<UL>
<LI>
<B>PEN</B>: For linear styles</LI>

<LI>
<B>BRUSH</B>: For filling areas</LI>

<LI>
<B>SYMBOL</B>: Point symbols</LI>

<LI>
<B>LABEL</B>: For annotations</LI>
</UL>
Each drawing tool can take a number of parameters, all optional. The style
syntax is built in a way that a system that cannot support all possible
parameters can safely skip and ignore the parameters it does not support.
This will also make it easy to extend the specification in the future without
breaking existing code or applications.
<P>A style can use a single tool, or use a combination of one or more tools.
By combining the use of several tools in a style, one can build virtually
any type of graphical representation. For instance, the SYMBOL tool can
be used to place spaced symbols along a line. Also, the LABEL tool can
be used to place text on a point, stretch it along a line, or even, by
combining the PEN tool with the LABEL tool, use the line as a leader to
the text label, and draw the text string on the last vertex of the line.
<P>Of course, few systems can support all that. But the intention here
is to have a style specification that is powerful and flexible enough to
allow all types of formats to exchange style information with the least
possible loss.
<H3>
1.4 Feature attributes can be used by style definitions</H3>
In some cases, it might be useful for a style definition to refer to an
attribute field on the feature for a given tool parameter's value instead
of having a hardcoded value inside the style itself.
<P>Example of this are text angle, text string, etc... these values change
for every single text label, but we can share the rest of the label style
at the layer level if we lookup the angle and text string in an attribute
on each feature.
<P>The syntax of the style string provides a way that any parameter value
can be either a constant value, or a lookup to an attribute field.
<H3>
1.5 Tool parameter units</H3>
Several parameter values can be expressed in different measurement units
depending on the file format you are dealing with. For instance, some systems
express line width, or text height in points, other in pixels, and others
use ground units. In order to accommodate all that, all parameters can be
specified in one of the following units systems:
<UL>
<LI>
<B>g</B>: Map Ground Units (whatever the map coordinate units are)</LI>

<LI>
<B>px</B>: Pixels</LI>

<LI>
<B>pt</B>: Points (1/72 inch)</LI>

<LI>
<B>mm</B>: Millimeters</LI>

<LI>
<B>cm</B>: Centimeters</LI>

<LI>
<B>in</B>: Inches</LI>
</UL>
Some tools will have to be provided at the GDAL client level to simplify
the conversion of any value from one units system to another. This would
imply that the GDAL client has to specify a map scale so that conversions
from ground units to paper/pixel units can be performed.
<P>
<HR WIDTH=50%>
<H2>
2. Feature Style String</H2>
As was mentioned earlier, styles definitions will usually be stored as
strings, either in a per-layer (or per-dataset) table, or directly in the
features.
<H3>
2.1 Examples</H3>
Here are some example style definition strings:
<UL>
<LI>A 5 pixels wide red line:
<BR><CODE>PEN(c:#FF0000,w:5px)</CODE>

<LI>A polygon filled in blue, with a black outline:
<BR><CODE>BRUSH(fc:#0000FF);PEN(c:#000000)</CODE>

<LI>A point symbol:
<BR><CODE>SYMBOL(c:#00FF00,id:"points.sym-45,ogr-sym-7")</CODE>

<LI>A text label, taking the text string from the "text_attribute" attribute field:
<BR><CODE>LABEL(f:"Times New Roman",s:12pt,t:{text_attribute})"</CODE>
</UL>

Here is what a style table that contains all the above styles could look
like:
<PRE>    road:      PEN(c:#FF0000,w:5px)
    lake:      BRUSH(fc:#0000FF);PEN(c:#000000)
    campsite:  SYMBOL(c:#00FF00,id:"points.sym-45,ogr-sym-7")
    label:     LABEL(f:"Times New Roman",s:12pt,t:{text_attribute})</PRE>

Then individual features can refer to styles from the table above
using the "@" character followed by the style name in their style property.
<P>For instance, a feature with its style set to "@road" would be drawn
as a red line.
<H3>
2.2 Style String Syntax</H3>
Each feature object has a style property (a string):
<TABLE BORDER WIDTH="100%" >
<TR>
<TD>
<PRE>
  &lt;style_property> = "&lt;style_def>" | "" | "@&lt;style_name>" | "{&lt;field_name>}"</PRE>
</TD>
</TR>
</TABLE>

<UL>
<LI>
<CODE>&lt;style_def></CODE> is defined later in this section.</LI>

<LI> An empty style string means that the feature's style is unspecified. It
does not indicate that the feature is invisible &ndash; an invisible feature may
be indicated using a fully transparent color, like PEN(c:#00000000).

<LI>
<CODE>@&lt;style_name></CODE> is a reference to a predefined style in the layer or
the dataset's style table. The layer's table is looked up first, and if
style_name is not found there then the dataset's table will be looked up.</LI>

<LI>
Finally, <CODE>{&lt;field_name>}</CODE> means that the style property should be read
from the specified attribute field.</LI>
</UL>
The &lt;style_def> is the real style definition. It is a combination of
1 or more style parts separated by semicolons. Each style_part uses a drawing
tool to define a portion of the complete graphical representation:
<TABLE BORDER WIDTH="100%" >
<TR>
<TD>
<PRE>
  &lt;style_def> =    &lt;style_part>[;&lt;style_part>[;...]]

  &lt;style_part> =   &lt;tool_name>([&lt;tool_param>[,&lt;tool_param>[,...]]])

  &lt;tool_name> =    name of a drawing tool, for now: PEN | BRUSH | SYMBOL | LABEL

  &lt;tool_param> =   &lt;param_name>:&lt;param_value>

  &lt;param_name> =   see list of parameters names for each drawing tool

  &lt;param_value> =  &lt;value> | &lt;value>&lt;units>

  &lt;value> =        "&lt;string_value>" | &lt;numeric_value> | {&lt;field_name>}

  &lt;units> =        g | px | pt | mm | cm | in</PRE>
</TD>
</TR>
</TABLE>

<P>By default, style parts are drawn in the order that they appear in the
style_def string unless each part is assigned a different level parameter
value (see the level parameter definition).
<P>All drawing tool parameters are optional. So it is legal to have a style_part
with an empty drawing tool parameter list (e.g. "PEN()"). For each parameter
that does not have any specified value, it is up to the client application
to use its own default value. This document provides advisory default values
for most parameters, but it is not mandatory for an application to use
those default values.
<P>When {&lt;field_name>} is used for a tool_param value, several options
are available with respect to the units. The units can be specified after
the field name as in PEN(c:#FF0000,w:{line_width}pt) or can be left unspecified
as in PEN(c:#FF0000,w:{line_width}). In the first case, the default units
will be points (pt), but if the attribute field line_width contains a value
followed by a units abbreviation (e.g. "5px") then the units specified
in the attribute fields have precedence (in this case pixels). Note that
the attribute field does not have to contain a units value and probably
won't in most cases; it is just an optional feature to be able to override
the default units from inside an attribute field's value.
<H3>
2.3 Pen Tool Parameters</H3>
<B>Applicable geometry types:</B>
<UL>
<LI>
Point: When applied to a point, a PEN tool can only define the color and
the size of the point to draw.</LI>

<LI>
Polyline: This is the most obvious case.</LI>

<LI>
Polygon: Defines the way the outline of a polygon should be drawn.</LI>
</UL>
Here is the current list of PEN tool parameters. While this is sufficient
to cover all the cases that we have encountered so far, new parameters
might be added in the future to handle new types of graphical representation.
Note again that all parameters are optional:
<TABLE BORDER WIDTH="100%" >
  <TR>
    <TH>param_name</TH>
    <TH>Description</TH>
  </TR>

  <TR>
    <TD ALIGN=CENTER>c</TD>
    <TD><B>Pen Color</B>, expressed in hexadecimal (#RRGGBB[AA])
<BR>
      [AA] the last 2 digits define the alpha channel value, with 0 being transparent and FF being opaque.  The default is FF (opaque)
      <BR>
      Suggested default: black (c:#000000)
<BR>
      Example: PEN(c:#FF0000), or PEN(C:#FF0000FF)</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>w</TD>
    <TD><B>Pen Width</B>, expressed as a numeric value with units (g, px, pt, mm, cm, in)
<BR>
      Suggested default: 1 pixel
<BR>
      Examples: PEN(c:#FF0000,w:5px), PEN(w:3pt), PEN(w:50g)</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>p</TD>
    <TD><B>Pattern</B> - To create dash lines. A list of pen-down/pen-up distances
<BR>
      Examples:
<BR>
      <IMG SRC="style_pen1.gif" HEIGHT=15 WIDTH=75>  = PEN(c:#FF0000,w:2px,p:"4px
5px") - short-dash line
<BR>
      <IMG SRC="style_pen2.gif" HEIGHT=15 WIDTH=75>  = PEN(c:#FF0000,w:2px,p:"10px
5px") - long-dash line
<BR>
      <IMG SRC="style_pen3.gif" HEIGHT=15 WIDTH=75>  = PEN(c:#FF0000,w:2px,p:"10px
5px 4px 5px") - long/short dash line</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>id</TD>
    <TD><B>Comma-delimited list of Pen Names or Ids</B> - For systems that
identify pens with a name or an id.  The names in the comma-delimited list
of ids are scanned until one is recognized by the target system.
      <P>
Pen Ids can be either system-specific ids (see further below) or be one
of the pre-defined OGR pen ids for well known line patterns.  The id
parameter should always include one of the OGR ids at the end of the
comma-delimited list of ids so that an application never has to rely on
understanding system-specific ids.
      <P>
Here is the current list of OGR pen ids (this could grow over time):<BR>
      <UL>
        <LI>ogr-pen-0: solid  (the default when no id is provided)
        <LI>ogr-pen-1: null pen (invisible)
        <LI>ogr-pen-2: dash
        <LI>ogr-pen-3: short-dash
        <LI>ogr-pen-4: long-dash
        <LI>ogr-pen-5: dot line
        <LI>ogr-pen-6: dash-dot line
        <LI>ogr-pen-7: dash-dot-dot line
        <LI>ogr-pen-8: alternate-line (sets every other pixel)
      </UL>
      <P>
System-specific ids are very
likely to be meaningful only to that specific system that created them.
The ids should start with the system's name, followed by a dash (-),
followed by whatever information is meaningful to that system (a number,
a name, a filename, etc.).<BR>
e.g. "mapinfo-5", or "mysoft-lines.sym-123", or "othersystems-funnyline"
      <P>
System-specific ids are allowed in order to prevent loss of information when
dealing with data from systems that store line patterns in external files
or that have their own pre-defined set of line styles (for instance, to do a MapInfo MIF
to TAB translation without any loss.)
      <P>Examples: <BR>
PEN(c:#00FF00,id:"ogr-pen-0") - simple solid line<BR>
PEN(c:#00FF00,id:"mapinfo-5,ogr-pen-7") - corresponds to MapInfo's Pen #5, and a system that can't understand MapInfo pens falls back on the default "ogr-pen-7" pen (dot-dot line).
    </TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>cap</TD>
    <TD><B>Pen Cap</B> - Set the shape of end points of lines.<BR>
"cap:b" - Butt: The ends of the line don't extend beyond the end points. This is the default. <BR>
"cap:r" - Round: Terminate lines with a circle whose diameter is equal to the line width. <BR>
"cap:p" - Projecting: Similar to Butt, but the ends of the line extend by half of line width beyond the end points. </TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>j</TD>
    <TD><B>Pen Join</B> - Set the shape of the join point (vertex) of lines.<BR>
"j:m" - Miter: Extend the outer edge of the lines until they touch. This is the default. <BR>
"j:r" - Rounded: Join lines with an arc whose center is at the join point and whose diameter is equal to the line width. <BR>
"j:b" - Bevel: Join the lines with butt end caps and fill the resulting triangular notch at the join position. </TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>dp</TD>
    <TD><B>Perpendicular Offset</B>, expressed as a numeric value with units (g, px, pt, mm, cm, in)<BR>
      Offset from the line center. If the offset is negative then the pen will be
      drawn left of the main segment and right otherwise.
    </TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>l</TD>
    <TD><B>Priority Level</B> - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
<BR>
      If priority level is unspecified, the default is 1.</TD>
  </TR>
</TABLE>

<H3>
2.4 Brush Tool Parameters</H3>
<B>Applicable geometry types:</B>
<UL>
<LI>
Point: Not applicable.</LI>

<LI>
Polyline: Not applicable.</LI>

<LI>
Polygon: Defines the way the surface of a polygon is filled.</LI>
</UL>
Here is the current list of BRUSH tool parameters. Note again that that
this list may be extended in the future, and all parameters are optional:
<TABLE BORDER WIDTH="100%" >
<TR>
<TH>param_name</TH>

<TH>Description</TH>
</TR>

<TR>
<TD ALIGN=CENTER>fc</TD>

    <TD>
      <P><B>Brush ForeColor</B>, expressed in hexadecimal (#RRGGBB[AA]). Used for painting the brush pattern itself.
<BR>
      [AA] the last 2 digits define the alpha channel value, with 0 being transparent and FF being opaque.  The default for [AA] is FF (opaque).<BR>
        Suggested default: 50% grey (c:#808080)
<BR>
      Example: BRUSH(fc:#FF0000)</P>
      </TD>
</TR>
<TR>
<TD ALIGN=CENTER>bc</TD>

    <TD>
      <P><B>Brush BackColor</B>, expressed in hexadecimal (#RRGGBB[AA]). Used for painting the area behind the brush pattern.
<BR>
      [AA] the last 2 digits define the alpha channel value, with 0 being transparent and FF being opaque.  The default for [AA] is FF (opaque)<BR>
        Suggested default: transparent (c:#FFFFFF00)
<BR>
      Example: BRUSH(fc:#FF0000,bc:#FFEEDD)</P>
      </TD>
</TR>

<TR>
<TD ALIGN=CENTER>id</TD>

<TD>
      <P><B>Brush Name or Brush Id</B> - Comma-delimited list of brush names or ids.  The names in the comma-delimited list
of ids are scanned until one is recognized by the target system.
</P>
      <P>
Brush  Ids can be either system-specific ids (see further below) or be one
of the pre-defined OGR brush  ids for well known brush patterns.  The id
parameter should always include one of the OGR ids at the end of the
comma-delimited list of ids so that an application never has to rely on
understanding system-specific ids.
      <P><IMG SRC="style_ogr_brush.png" STYLE="float: right">
Here is the current list of OGR brush ids (this could grow over time):<BR>
      <UL>
        <LI>ogr-brush-0: solid foreground color (the default when no id is provided)
        <LI>ogr-brush-1: null brush (transparent - no fill, irrespective of fc or bc values)
        <LI>ogr-brush-2: horizontal hatch
        <LI>ogr-brush-3: vertical hatch
        <LI>ogr-brush-4: top-left to bottom-right diagonal hatch
        <LI>ogr-brush-5: bottom-left to top-right diagonal hatch
        <LI>ogr-brush-6: cross hatch
        <LI>ogr-brush-7: diagonal cross hatch
      </UL>
      <P>
Like with Pen Ids, system-specific brush ids are very
likely to be meaningful only to that specific system that created them.
The ids should start with the system's name, followed by a dash (-),
followed by whatever information is meaningful to that system (a number,
a name, a filename, etc.).
      <P>The following conventions will be used for common system-specific brush ids:</P>
      <UL>
        <LI>&quot;bmp-filename.bmp&quot; for Windows BMP patterns

      </UL>
      <P>Other conventions may be added in the future (such as vector symbols, WMF, etc).
      </TD>
</TR>

<TR>
<TD ALIGN=CENTER>a</TD>

<TD><B>Angle</B> - Rotation angle (in degrees, counterclockwise) to apply
to the brush pattern.</TD>
</TR>

<TR>
<TD ALIGN=CENTER>s</TD>

<TD><B>Size or Scaling Factor</B> - Numeric value with or without units.
<BR>If units are specified, then this value is the absolute size to draw
the brush or symbol.
<BR>If no units are specified then it is taken as a scaling factor relative
to the symbol's default size.</TD>
</TR>

<TR>
<TD ALIGN=CENTER>dx, dy</TD>

<TD><B>Spacing</B>, expressed as a numeric value with units (g, px, pt, mm, cm, in)
<BR>If filling an area using point symbols, these values
will define the spacing to use between them. "dx" is the horizontal distance
between the center of two adjacent symbols and "dy" is the vertical distance.
<BR>The default is to use the symbol's bounding box width and height for dx
and dy respectively.</TD>
</TR>

<TR>
<TD ALIGN=CENTER>l</TD>

<TD><B>Priority Level</B> - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
<BR>If priority level is unspecified, the default is 1.</TD>
</TR>
</TABLE>

<H3>
2.5 Symbol Tool Parameters</H3>
<B>Applicable geometry types:</B>
<UL>
<LI>
Point: Place a symbol at the point's location</LI>

<LI>
Polyline: Place symbols along the polyline, either at each vertex, or equally
spaced.</LI>

<LI>
Polygon: Place the symbols on the outline of the polygon.</LI>
</UL>
Here is the current list of SYMBOL tool parameters. Note again that that
this list may be extended in the future, and all parameters are optional:
<TABLE BORDER WIDTH="100%" >
<TR>
<TH>param_name</TH>

<TH>Description</TH>
</TR>

<TR>
<TD ALIGN=CENTER>id</TD>

    <TD>
      <P><B>Symbol Name or Id</B> - Comma-delimited list of symbol names or ids.  The names in the comma-delimited list
of ids are scanned until one is recognized by the target system.
</P>
      <P>
Symbol  Ids can be either system-specific ids (see further below) or be one
of the pre-defined OGR symbol  ids for well known symbols.  The id
parameter should always include one of the OGR ids at the end of the
comma-delimited list of ids so that an application never has to rely on
understanding system-specific ids.
      <P><IMG SRC="style_ogr_sym.png" STYLE="float: right">
Here is the current list of OGR symbol ids (this could grow over time):<BR>
      <UL>
        <LI>ogr-sym-0: cross (+)
        <LI>ogr-sym-1: diagcross (X)
        <LI>ogr-sym-2: circle (not filled)
        <LI>ogr-sym-3: circle (filled)
        <LI>ogr-sym-4: square (not filled)
        <LI>ogr-sym-5: square (filled)
        <LI>ogr-sym-6: triangle (not filled)
        <LI>ogr-sym-7: triangle (filled)
        <LI>ogr-sym-8: star (not filled)
        <LI>ogr-sym-9: star (filled)
        <LI>ogr-sym-10: vertical bar (can be rotated using angle attribute to produce diag bar)
      </UL>
      <P>
Like with Pen Ids, system-specific symbol ids are very
likely to be meaningful only to that specific system that created them.
The ids should start with the system's name, followed by a dash (-),
followed by whatever information is meaningful to that system (a number,
a name, a filename, etc.).
      <P>The following conventions will be used for common system-specific symbol ids:</P>
      <UL>
        <LI>&quot;bmp-filename.bmp&quot; for Windows BMP symbols
        <LI>&quot;font-sym-%d&quot; for a font symbols,
            where %d is a glyph number inside a font,
            font family is defined by <B>f</B> style field.
      </UL>
      <P>Other conventions may be added in the future (such as vector symbols, WMF, etc).
      </TD>
</TR>

<TR>
<TD ALIGN=CENTER>a</TD>

<TD><B>Angle</B> - Rotation angle (in degrees, counterclockwise) to apply
to the symbol.</TD>
</TR>

<TR>
<TD ALIGN=CENTER>c</TD>

<TD>
      <P><B>Symbol Color</B>, expressed in hexadecimal (#RRGGBB[AA])
<BR>
      [AA] the last 2 digits define the alpha channel value, with 0 being transparent and FF being opaque.  The default for [AA] is FF (opaque)<BR>
        Suggested default symbol color: black (c:#000000)
<BR>
      Example: SYMBOL(c:#FF0000)</P>
      </TD>
</TR>

<TR>
<TD ALIGN=CENTER>o</TD>

<TD>
      <P><B>Symbol Outline Color</B>, expressed in hexadecimal (#RRGGBB[AA]).
        <BR>If this parameter is set, an additional halo or border of this color is drawn around the symbol.
      </TD>
</TR>

<TR>
<TD ALIGN=CENTER>s</TD>

<TD><B>Size or Scaling Factor</B> - Numeric value with or without units.
<BR>If units are specified, then this value is the absolute size to draw
the symbol.
<BR>If no units are specified then it is taken as a scaling factor relative
to the symbol's default size.</TD>
</TR>

<TR>
<TD ALIGN=CENTER>dx, dy</TD>

<TD><B>X and Y offset</B> of the symbol's insertion point, expressed as a
numeric value with units (g, px, pt, mm, cm, in)
<BR>Applies to point geometries, and to symbols placed at each vertex of
a polyline.</TD>
</TR>

<TR>
<TD ALIGN=CENTER>ds, dp, di</TD>

<TD><B>Spacing parameters</B> for symbols spaced along a line, expressed as a 
numeric value with units (g, px, pt, mm, cm, in).
<BR>"ds" is the step to use when placing symbols along the line.
<BR>By default, symbols applied to a feature with a line geometry are placed
at each vertex, but setting "ds" triggers the placement of symbols at an
equal distance along the line. "ds" has no effect for a feature with a
point geometry.
<BR>"dp" can be used together with "ds" to specify the perpendicular distance
between the symbols' center and the line along which they're placed.
<BR>Finally, "di" can be used to specify an initial offset from the beginning
of the line.
<BR>Example:
<BR>SYMBOL(id:123, s:5, di:5px, ds:50px)</TD>
</TR>

<TR>
<TD ALIGN=CENTER>l</TD>

<TD><B>Priority Level</B> - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
<BR>If priority level is unspecified, the default is 1.</TD>
</TR>

  <TR>
    <TD ALIGN=CENTER>f</TD>
    <TD><B>Font Name</B> -
      Comma-delimited list of fonts names.  Works like the CSS font-family
property: the list of font names is scanned until a known font name is encountered.
<BR>
      Example: SYMBOL(c:#00FF00,s:12pt,id:"font-sym-75,ogr-sym-9",f:"MapInfo_Cartographic")

    </TD>
  </TR>

</TABLE>

<H3>
2.6 Label Tool Parameters</H3>
<B>Applicable geometry types:</B>
<UL>
<LI>
Point: Place a text label at the point's location</LI>

<LI>
Polyline: Place text along the polyline.</LI>

<LI>
Polygon: Place a label at the centroid of the polygon. All parameters behave
exactly as if the geometry was a point located at the polygon's centroid.</LI>
</UL>
Here is the current list of LABEL tool parameters. Note again that that
this list may be extended in the future, and all parameters are optional:
<TABLE BORDER WIDTH="100%" >
  <TR>
    <TH>param_name</TH>
    <TH>Description</TH>
  </TR>

  <TR>
    <TD ALIGN=CENTER>f</TD>
    <TD><B>Font Name</B> -
      Comma-delimited list of fonts names.  Works like the CSS font-family
property: the list of font names is scanned until a known font name is encountered.
<BR>
      Example: LABEL(f:"Noto Sans, Helvetica", s:12pt, t:"Hello World!")

    </TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>s</TD>
    <TD><B>Font Size</B>, expressed as a numeric value with units (g, px, pt, mm, cm, in).
<BR><BR>In the CAD world, font size, or "text height", determines
the height of a capital letter &ndash; what typographers call "cap height".
But in the worlds of typesetting, graphics and cartography, font size
refers to the "em height" of the font, which is taller than the cap height.
This means that text assigned a height of 1 inch in a DXF file will look larger
(often about 45% larger) than 72-point text in a PDF file or
MapInfo map. At present, GDAL vector drivers treat the "s:" style string value as
whichever font size measurement (cap height or em height) is used natively by
that format, which may result in incorrect text sizing when using the ogr2ogr tool.
This parameter could be subject to clearer
specification in the future.</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>t</TD>
    <TD><B>Text String</B> - Can be a constant string, or a reference to an
attribute field's value. If a double-quote character or backslash (\) character
is present in the string, it is escaped with a backslash character before it.
<BR>
      Examples:
<BR>
      LABEL(f:"Arial, Helvetica", s:12pt, t:"Hello World!")
<BR>
      LABEL(f:"Arial, Helvetica", s:12pt, t:"Hello World with escaped \"quotes\" and \\backslash!")
<BR>
      LABEL(f:"Arial, Helvetica", s:12pt, t:{text_attribute})</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>a</TD>
    <TD><B>Angle</B> - Rotation angle (in degrees, counterclockwise).</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>c</TD>
    <TD><B>Text Foreground Color</B>, expressed in hexadecimal (#RRGGBB[AA])
<BR>
      Suggested default: black (c:#000000)</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>b</TD>
    <TD><B>Text Background Color</B> - Color of the filled box to draw behind the label,
expressed in hexadecimal (#RRGGBB[AA]). No box drawn if not set.</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>o</TD>
    <TD><B>Text Outline Color</B> - Color of the text outline (halo in MapInfo terminology),
expressed in hexadecimal (#RRGGBB[AA]). No outline if not set.</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>h</TD>
    <TD><B>Shadow Color</B> - Color of the text shadow, expressed in hexadecimal (#RRGGBB[AA]).
No shadow if not set.</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>w</TD>
    <TD><B>Stretch</B> - The stretch factor changes the width of all
      characters in the font by the given percentage. For example, a setting
      of 150 results in all characters in the font being stretched to 150%
      of their usual width. The default stretch factor is 100.</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>m</TD>
    <TD><B>Label Placement Mode</B> - How the text is drawn relative to the
feature's geometry.
<BR>
	"m:p" - The default. A simple label is attached to a point or to the first
vertex of a polyline.
<BR>
	"m:l" - Text is attached to the last vertex of a polyline. A PEN tool
can be combined with this LABEL tool to draw the polyline as a leader to
the label.
<BR>
	"m:s" - Stretch the text string along a polyline, with an equal spacing
between each character.
<BR>
	"m:m" - Place text as a single label at the middle of a polyline (based
on total line length).
<BR>
	"m:w" - One word per line segment in a polyline.
<BR>
	"m:h" - Every word of text attached to polyline is placed horizontally
in its segment, anchor point is a center of segment.
<BR>
	"m:a" - Every word of text attached to polyline is stretched to fit
the segment of polyline and placed along that segment. The anchor point is
a start of a segment.
<BR>
  </TR>

  <TR>
    <TD ALIGN=CENTER>p</TD>
    <TD><IMG SRC="style_textanchor.gif" STYLE="float: right">
      <B>Anchor Position</B> - A value from 1 to 12 defining the
		  label's position relative to the point to which it is
		  attached. There are four vertical alignment modes:
		  <i>baseline</i>, <i>center</i>, <i>top</i> and <i>bottom</i>;
		  and three horizontal modes: <i>left</i>, <i>center</i> and
		  <i>right</i>. The scheme is shown at right.
<BR><BR>Currently, the precise interpretation of these values (for example,
whether accents on uppercase letters sit above or below the alignment point with p:7)
differs from file format to file format. This parameter could be subject to clearer
specification in the future.
    </TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>dx, dy</TD>
    <TD><B>X and Y offset</B> of the label's insertion point, expressed as a
numeric value with units (g, px, pt, mm, cm, in).
<BR>
      Applies to text placed on a point, or at each vertex of a polyline.</TD>
  </TR>

  <TR>
    <TD ALIGN=CENTER>dp</TD>
    <TD><B>Perpendicular Offset</B> for labels placed along a line, expressed as
a numeric value with units (g, px, pt, mm, cm, in).
<BR>
      "dp" specifies the perpendicular distance between the label and the
line along which it is placed.  If the offset is negative then the label will be shifted
left of the main segment, and right otherwise.</TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>bo</TD>
    <TD><B>Bold</B> - Set to 1 for bold text. Set to 0 or omitted otherwise.</TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>it</TD>
    <TD><B>Italic</B> - Set to 1 for italic text. Set to 0 or omitted otherwise.</TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>un</TD>
    <TD><B>Underline</B> - Set to 1 for underlined text. Set to 0 or omitted
otherwise.</TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>st</TD>
    <TD><B>Strikethrough</B> - Set to 1 for struck-through text. Set to 0
or omitted otherwise.</TD>
  </TR>
  <TR>
    <TD ALIGN=CENTER>l</TD>
    <TD><B>Priority Level</B> - Numeric value defining the order in which style
parts should be drawn. Lower priority style parts are drawn first, and
higher priority ones are drawn on top.
<BR>
      If priority level is unspecified, the default is 1.</TD>
  </TR>
</TABLE>

<H3>
2.7 Styles Table Format</H3>
For file formats that support tables of styles, then the predefined styles
would be stored in that format.
<P>For file formats that do not support tables of styles, then the style table
could be stored in a text file with a .ofs (OGR Feature Styles)  extension
and the same basename as the dataset.
This would apply to formats like Esri Shapefile.
<P>Here is an example of a .ofs file:
<PRE>
    #OFS-Version: 1.0
    #StyleField: &quot;style&quot;

    DefaultStyle: PEN(c:#000000)
    road:      PEN(c:#FF0000,w:5px)
    lake:      BRUSH(fc:#0000FF);PEN(c:#000000)
    campsite:  SYMBOL(c:#00FF00,id:"points.sym-45,ogr-sym-7")
    label:     LABEL(f:"Times New Roman",s:12pt,t:{text_attribute})</PRE>

<P>
<P>The first line is a signature with a version number, which must be present.
<P>The second line (StyleField: &quot;style&quot;) is the name of the attribute
field in which the Feature Style String is stored for each object in the corresponding layer.  This is optional, if not set, then the objects in the layer will all share the same style defined in DefaultStyle.
<P>The third line (DefaultStyle:...) defines the style that applies by
default to all objects that have no explicit style.
<P>Then the list of style definitions follow.
<P>
<H3>2.8 Using OGR SQL to transfer the style between the data sources</H3>
<P>You can use the <B>OGR_STYLE</B> special field to extract the feature level style,
and ogr2ogr can be used to transfer the style string between data sources according
to the following example:</P>
<PRE>  ogr2ogr -f "ESRI Shapefile" -sql "select *, OGR_STYLE from rivers" rivers.shp rivers.tab</PRE>
<P>Without specifying the length of the style field, the output driver may truncate
the length to a default value. Therefore it may be necessary to specify the target
length manually, like:</P>
<PRE>  ogr2ogr -f "ESRI Shapefile" -sql "select *, CAST(OGR_STYLE AS character(255)) from rivers" rivers.shp rivers.tab</PRE>
<P>OGR is aware of using the OGR_STYLE field if it exists, and OGRFeature::GetStyleString
will return the value of this field if no style string has been specified programmatically.</P>
<P>&nbsp;
<P>
<HR WIDTH=50%>
<H2>
3. OGR Support Classes</H2>
<P>The <a href="classOGRFeature.html">OGRFeature class</a> has
member functions <code>GetStyleString</code>, <code>SetStyleString</code> and
<code>SetStyleStringDirectly</code> which may be used to interact with a
feature's style string as a C-style string. Additionally, there are
<code>GetStyleTable</code>, <code>SetStyleTable</code> and
<code>SetStyleTableDirectly</code> for managing style tables as instances of the
<a href="classOGRStyleTable.html">OGRStyleTable class</a>.

<P>The <a href="classOGRLayer.html">OGRLayer class</a> and
<a href="classGDALDataset.html">GDALDataset class</a> also
have <code>GetStyleTable</code>, <code>SetStyleTable</code> and
<code>SetStyleTableDirectly</code> member functions.

<P>To parse style strings, the
<a href="classOGRStyleMgr.html">OGRStyleMgr class</a> is used.
Each style tool in the string is accessed as an instance of the
<a href="classOGRStyleTool.html">OGRStyleTool class</a>. Lastly,
four helper classes exist, one for each tool 
(<a href="classOGRStylePen.html">OGRStylePen</a>,
<a href="classOGRStyleBrush.html">OGRStyleBrush</a>,
<a href="classOGRStyleSymbol.html">OGRStyleSymbol</a>,
<a href="classOGRStyleLabel.html">OGRStyleLabel</a>), 
with each available parameter represented by a getter and setter member function. To
understand these classes better, it may be useful to read the
<a href="https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogr_featurestyle.h">ogr_featurestyle.h</a> and
<a href="https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrfeaturestyle.cpp">ogrfeaturestyle.cpp</a>
code files.

<P>Here is some example C++ code:

<PRE>
   OGRStyleTable oStyleTable;

   OGRStyleMgr *poStyleMgr = new OGRStyleMgr(&amp;oStyleTable);

   // Create a new style in the style table by specifying the whole style string

   if (poStyleMgr->AddStyle("@Name","PEN(c:#123456;w:10px);BRUSH(c:#345678)"))
   {
     poStyleMgr->SetFeatureStyleString(poFeature,"@Name",TRUE)
     // or
     poStyleMgr->SetFeatureStyleString(poFeature,"PEN(c:#123456,w:10px);BRUSH(c:#345678)",FALSE)
   }

   oStyleTable->SaveStyleTable("ttt.tbl");


   // Create a new style in the style table by specifying each tool (part) as a string

   poStyleMgr->InitStyleString();
   poStyleMgr->AddPart("PEN(c:#123456,w:10px)");
   poStyleMgr->AddPart("BRUSH(c:345678)");
   poStyleMgr->AddStyle("@Name");
   poStyleMgr->SetFeatureStyleString(poFeature,"@Name",TRUE);

   oStyleTable->SaveStyleTable("ttt.tbl");


   // Create a new style in the style table using the style tool helper classes

   OGRStyleTool *poStylePen = new OGRStylePen;

   poStylePen->SetColor("#123456");
   poStylePen->SetUnit(OGRSTUPixel);
   poStylePen->SetWidth(10.0);
   poStyleMgr->AddPart(poStylePen);

   delete poStylePen;


   // Reading a style

   OGRStyleTool *poStyleTool;

   poStyleMgr->GetStyleString(poFeature);

   for (int iPart = 0; iPart &lt; poStyleMgr->GetPartCount(); iPart++)
   {
      poStyleTool = GetPart(iPart);
      switch (poStyleTool->GetType())
      {
         case OGRSTCPen:
            poStylePen = (OGRStylePen *)poStyleTool;
            pszColor = poStylePen->Color(bDefault);
            if (bDefault == FALSE)
              poStylePen->GetRGBFromString(pszColor, nRed, nGreen,
	                                   nBlue, nTrans);
            else
              // Color not defined

            dfWidth = poStylePen->Width(bDefault);
            if (bDefault == FALSE)
              // Use dfWidth
            else
              // dfWidth not defined

           :
           :
       }
    }

</PRE>

<P>&nbsp;
</P>
<P>
<HR WIDTH=50%>
</BODY></HTML>