Symbol points

From Maria GDK Wiki
Jump to navigation Jump to search

The SymbolPoint-service allows the user to define custom symbolproducts/libraries for use in Maria GDK. Products can be installed and upgraded similar to map products and it is easy to add new products as needed. A symbol point library can consist of both PNG and SVG-images.

Configuring symbol point libraries

The symcfg.json defines a product, symbols and styling-templates. The file should contain productid, a descriptive product name and the relative path to where the symbol files are located. Symbols can be sorted in multiple groups within a product. Each group defines its own id, name, symbolpath as well as symbol postfix (svg or png). A group should contain styleoptions, mappings and optional subgroups.

Tags

Products, groups and symbols can be tagged. The client can use tags for purposes such as filtering.

    "tags": [ "groupptag", "tpdev", "pngsyms" ],

Styleoptions

The SymbolPoint-service provides the means to override colour/fill patterns/strokes etc. on an existing SVG-image. This requires knowledge of CSS and how the SVG is layered. When creating the SVG, place objects in separate layers to enable them to be identified for restyling. The name of these layers can then be used in the "styleoptions"-section of the symcfg.json.

The styleoptions-section in the symcfg.json should contain templates for manipulating CSS-styling as well as styleitems. For restyling to be possible, each template must correspond to an existing layer in the svg. F.ex. ".background *{fill: $BK_C !important;}" assumes that a layer named "background" exists. If it does, all objects defined in that layer (with a valid "fill"-property) will be modified. Otherwise, nothing happens.

Greate care should be taken to ensure that all templates and styleitems defined on group level are applicable to all symbols contained in the group.

Mappings

The mappings-section defines available symbols. Each symbol definition must provide an id, symbolPath, symbolName and optional tags and stylingoptions.

Sample symcfg.json

Configurationfile for a simple product ("simplepoi") with a single symbol group ("styled") containing two symbols ("SHP" and "CI").

{
    "id": "simplepoi",
    "name": "Basic test symbol library",
    "symbolPath": "simplepoi/symbols",
    "tags": [ "simplepoitag", "tpdev", "internal" ],
    "groups":   [
            {
            "id": "styled",
            "name": "default",
            "symbolGrouppath": "",
            "symbolPostfix": ".svg",
                        
            "styleoptions":
            {
                "template":
                [".background *{fill: $BK_C !important;}",
                ".foreground *{fill: $FG_C !important;}",               
                ".background *{stroke-dasharray: $OL_DA !important;}",
                ".foreground *{stroke-dasharray: $OL_DA !important;}",                              
                ".background *{stroke: $OL_C !important;}",
                ".foreground *{stroke: $OL_C !important;}", 
                ".text *{fill: $TE_C !important;}"],
                "items": 
                [
                    {
                        "name":"Background color",
                        "type":"css_color",
                        "id":"BK_C"
                    },
                    {
                        "name":"Foreground color",
                        "type":"css_color",
                        "id":"FG_C"
                    },
                    {
                        "name":"Outline linestyle",
                        "type":"css_dasharray",
                        "id":"OL_DA"
                    },
                    {
                        "name":"Outline color",
                        "type":"css_color",
                        "id":"OL_C"
                    },
                    {
                        "name":"Text color",
                        "type":"css_color",
                        "id":"TE_C"
                    }
                ]
            },
            "mappings": 
            [
                {
                    "id": "SHP",
                    "symbolPath": "testStyling",
                    "symbolName": "Shapes for test",
                    "tags": ["tpdev"],
                },
                {
                    "id": "CI",
                    "symbolPath": "circle2",
                    "symbolName": "Circle template",
                    "tags": ["tpdev"],
                    "styleoptions":
                    {
                        "template":[".text *{opacity: $TE_OP !important;}",
                        ".background *{stroke-dasharray: $BK_DASH !important;}"],
                        "items": 
                        [
                            {
                                "name":"Background color2",
                                "type":"css_color",
                                "id":"BK_C"
                            },
                            {
                                "name":"Text opacity",
                                "type":"css_opacity",
                                "id":"TE_OP"
                            }       
                        ]
                    }                           
                }
            ]                   
        }       
    ]
}

ISymbolPoint Interface

namespace TPG.SymbolPoint.Contracts
{
    /// <summary>
    /// Access information on available products and point symbol data
    /// </summary>
    public interface ISymbolPoint
    {
        /// <summary>
        /// Get all installed products matching query. If query is null or empty, all
        /// installed product will be installed
        /// </summary>
        /// <param name="query">Query used to filter product information</param>
        /// <returns></returns>
        ProductsInfoResponse GetProductsInfo(ProductQuery query);

        /// <summary>
        /// Get detailed symbol configuarion for a single product, including mappings
        /// and symbol organization
        /// </summary>
        /// <param name="productId"></param>
        /// <returns></returns>
        SymbolProductConfig GetProductSymbolConfig(string productId);

        /// <summary>
        /// Get information for all symbols matching query 
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        SymbolsInfoResponse GetSymbolsInfo(SymbolQuery query);

        /// <summary>
        /// Get multiple symbols according to specification.
        /// </summary>
        /// <param name="symbolsInfo"></param>
        /// <returns>Symbol data, note that for each requested symbol, one entry in SymbolsData.Symbols will be
        /// returned, even if symbol was not found. Appropeiate status is set for invalid symbols</returns>
        SymbolsData GetSymbols(SymbolsRenderSpec symbolsInfo);

        /// <summary>
        /// Add product paths for symbol point libraries.
        /// </summary>
        /// <param name="productPath">Product path string.</param>
        /// <returns>Added path count.</returns>
        int AddProductPaths(ProductPathsInfo productPath);

    }
}