SVG (Scalable Vector Graphics) Feature Representation
In addition to the generic FME feature attributes that FME Workbench adds to all features (see About Feature Type Attributes), this format also adds format-specific attributes (Format Attributes).
Any feature that is sent to the SVG writer has several attributes that the writer uses to determine that feature’s geometric representation in SVG. The start of this processing occurs when the writer examines the feature’s svg_type attribute. Once the writer determines this attribute’s value, it can process the other attribute information required to complete the geometric conversion process. If, for example, the feature has an svg_type of svg_arc, then the writer will retrieve the svg_primary_axis, svg_secondary_axis, svg_start_angle and svg_rotation attributes to determine what geometric attribute values will exist in the feature’s path element representation.
All format-specific attributes begin with svg_ and are predefined in this section’s tables. In addition to format attributes, the SVG writer can process user-defined attributes. The writer extracts these user attributes from the incoming features and inserts them the output element’s attribute list. The user-defined attributes are defined in the SVG element’s attribute list under the qualified name prefix fme. An extension to the SVG DTD is produced to accommodate these user-defined attributes. This extension is defined in the document’s internal document type declaration.
When producing an element’s attribute list, the writer will examine the contents of the attribute values to determine if there are any < or " characters. If these values are present, they are output using < and " respectively. Attribute values are embedded in an element’s attribute list using the quote (") delimiter.
The following table lists the format attributes that are common to all features sent to the SVG writer. Other than svg_color and svg_fill_color, all attributes in this table have a direct mapping to the attribute names that can be set on individual SVG elements. Selected SVG elements attribute names have been prepended with a svg_ string to produce the FME attribute names.
Attribute Name |
Contents |
---|---|
svg_color |
The color used to stroke an element. The string is formatted with three comma-separated values representing the ordered intensities red, green, and blue. The individual intensity values are character decimal character strings that can range in value from 0 to 1 with 1 being the highest. See note on color below. Range: string Value: 0.0..1.0, 0.0..1.0, 0.0..1.0 Default: None |
svg_fill_color |
The color used to fill an element. The string is formatted with three comma-separated values representing the ordered intensities red, green, and blue. The individual intensity values represent decimals that can range in value from 0 to 1 with 1 being the highest. This value is not applicable to svg_line or svg_arc features. See note on color below. Range: string Value: 0.0..1.0, 0.0..1.0, 0.0..1.0 Default: None |
svg_id |
An element’s unique identifier. Directly maps to an element’s id attribute. Refer to the XML 1.0 specification for applicable values. It is strongly recommended that users not create IDs that begin with “FME_”. Range: string Default: None |
svg_class |
Assigns a class name or set of class names to an element. Directly maps to an element’s class attribute. Refer to the SVG 1.1 specification for applicable values. Range: string Default: None |
svg_style |
Specifies style information for an element. Directly maps to an element’s style attribute. Refer to the SVG 1.1 specification for applicable values. Range: string Default: None |
svg_onfocusin |
Identifies the script method to call when an element recieves focus. Directly maps to an element’s onfocusin attribute. Range: string (must match an available script method ID) Default: None |
svg_onfocusout |
Identifies the script method to call when an element loses focus. Directly maps to an element’s onfocusout attribute. Range: string (must match an available script method ID) Default: None |
svg_onclick |
Identifies the script method to call when a pointing device button is clicked over an element. Directly maps to an element’s onclick attribute. Range: string (must match an available script method ID) Default: None |
svg_onmousedown |
Identifies the script method to call when a pointing device button is pressed over an element. Directly maps to an element’s onmousedown attribute. Range: string (must match an available script method ID) Default: None |
svg_onmouseup |
Identifies the script method to call when a pointing device button is release over an element. Directly maps to an element’s onmouseup attribute. Range: string (must match an available script method ID) Default: None |
svg_onmouseover |
Identifies the script method to call when a pointing device button is moved on to an element. Directly maps to an element’s onmouseover attribute. Range: string (must match an available script method ID) Default: None |
svg_onmousemove |
Identifies the script method to call when a pointing device button is moved while it is over an element. Directly maps to an element’s onmousemove attribute. Range: string (must match an available script method ID) Default: None |
svg_onmouseout |
Identifies the script method to call when a pointing device button is moved away from an element. Directly maps to an element’s onmouseout attribute. Range: string (must match an available script method ID) Default: None |
The attributes fme_color and svg_color can both be used to set the value on an element’s stroke attribute. fme_color and svg_color are translated to SVG’s RGB function syntax. For the case where more than one color attribute is specified on a feature, order of precedence is svg_color, and then fme_color.
The same processing occurs for the attribute fme_fill_color, svg_fill_color, except both values can be used to set the element’s ‘fill’ attribute.
In addition, if the values for the svg_color or svg_fill_color do not match the FME color specification, i.e., “r,g,b” where r,g,b are in [0..1], then the writer will plainly transfer the value specified into the SVG stroke and fill attributes respectively. This is useful if the user needs to by pass the FME “r,g,b” syntax, for example, to use the SVG’s predefined color names, “red”, “black”, etc..., or if the user wants to use gradient fill. A user-defined SVG template (see the writer’s Template File parameter) could define several gradients to be referenced by the FME feature’s svg_fill_color attribute.
Arc
svg_type: svg_arc
Arc features must have exactly one coordinate. Arc features are output as SVG path elements, and have the following additional attributes:
Attribute Name |
Contents |
---|---|
svg_primary_axis |
The length of the semi-major axis in ground units. Range: Any real number > 0 Default: 0 |
svg_secondary_axis |
The length of the semi-minor axis in ground units. Range: Any real number > 0 Default: 0 |
svg_start_angle |
The start angle defines the counterclockwise distance from the primary axis to the starting point of the arc. It is measured in degrees. Range: 0.0...360.0 Default: 0 |
svg_rotation |
The rotation of the major axis. The rotation is measured in degrees counterclockwise up from the horizon. Range: -360.0...360.0 Default: 0 |
Ellipse
svg_type: svg_ellipse
Ellipse features must have exactly one coordinate. Ellipse features are output as SVG ellipse elements and have the following additional attributes:
Attribute Name |
Contents |
---|---|
svg_primary_axis |
The length of the semi-major axis in ground units. Range: Any real number > 0 Default: 0 |
svg_secondary_axis |
The length of the semi-minor axis in ground units. Range: Any real number > 0 Default: 0 |
svg_rotation |
The rotation of the ellipse, as measured in degrees counterclockwise from the horizontal. Range: -360.0...360.0 Default: 0 |
Lines
svg_type: svg_line
Polyline features must have at least two coordinates. Line features are output as SVG path elements.
Points
svg_type: svg_point
Point features can have one or more coordinates. All point features are usually output as SVG path elements. Single, non-aggregate, point features may also be output by an SVG use element that references another element whose graphical content is to be drawn at the position of the single point:
Attribute Name |
Contents |
---|---|
svg_use |
This format attribute only applies to single point features. If it is present and non-empty in a single point feature then the point feature is written out with a SVG use rather than a SVG path element. The value of the svg_use attribute must be a valid href location because this value is directly copied into the use element’s xlink:href attribute. The single coordinate of the point is also transferred onto the use element’s x and y attributes. The element referenced by the the SVG use element may be predefined in an FME SVG writer template file, see the writer’s Template File parameter. Range: string Default: Empty String |
Polygons
svg_type: svg_polygon
Polygon features must have at least two coordinates. Polygon feature are output as SVG path elements, and are automatically closed if the first and last coordinate of a polygon segment do not match.
Rectangle
svg_type: svg_rectangle
The extends of this feature are calculated using its bounding box. Rectangle features are output as SVG rect elements.
Rounded Rectangle
svg_type: svg_rectangle
The extents of this feature are calculated using its bounding box. Rounded Rectangle features are output as SVG rect elements.
Attribute Name |
Contents |
---|---|
svg_rounding |
Contains the diameter, in ground units, of the circle used to produce the rounded corners. Range: Any real number > 0 Default: 0 |
Text
svg_type: svg_text
Text features must have exactly one coordinate. Text features are output as SVG text elements, and have the following additional attributes:
Attribute Name |
Contents |
---|---|
svg_text_string |
The text string may contain blanks and there is no limit on its length. This attribute must be present for all svg_text features. Range: string Default: Empty String |
svg_text_size |
The size of the text in ground units. Range: Any real number > 0 Default: 0 |
svg_rotation |
The rotation of the text, as measured in degrees counterclockwise from the horizontal. Range: -360.0...360.0 Default: 0 |