Symbol points: Difference between revisions

From Maria GDK Wiki
Jump to navigation Jump to search
()
No edit summary
 
Line 162: Line 162:
     }
     }
}</source>
}</source>
=== Configure SymbolPointServiceClient in GDK5 ===
This section documents how to create and configure a SymbolPoint Service Client using the SymbolPointServiceFactory class.
The SymbolPointServiceFactory is responsible for creating instances of ISymbolPointServiceClient using different configurations such as bindings, endpoints, or custom settings.
* Using SymbolPointConfig creates a new internal in-process client that works directly with symbol libraries and renderers without relying on external services.
* Other factory methods (New(string), New(BindingType, string)) are intended for legacy service clients that wants to run against GDK4 WCF services.
==== Key Methods ====
1. Create an internal in-process client based on custom symbol point configuration.
If settings.DataSources contains paths, an integrated client is created using local symbol libraries.
Otherwise, defaults to a remote service at http://localhost:9008/symbolpoint.
<source lang="csharp">public ISymbolPointServiceClient New(SymbolPointConfig? settings)</source>
Use Case: Modern approach for internal rendering and symbol management.
2. Create a client using a named service configuration from the configuration file used by the binding- and endpointaddress factories injected into the factory.
<source lang="csharp">public ISymbolPointServiceClient New(string serviceName)</source>
Use Case: Legacy service integration.
3. Create a client using a specific binding type and endpoint address.
<source lang="csharp">public ISymbolPointServiceClient New(BindingType bindingType, string endpointAddress)</source>
Use Case: Legacy service integration.
==== Configuring the Internal In-Process Client ====
The SymbolPointConfig class defines settings for the internal in-process client:
<source lang="csharp">
public class SymbolPointConfig : ConfigBase<SymbolPointConfig>
{
    [JsonPropertyName("discoveryEnabled")]
    public bool DiscoveryEnabled { get; set; } = false;
    [JsonPropertyName("dataSources")]
    public IList<ProductPaths> DataSources { get; set; } = new List<ProductPaths>();
}
public class ProductPaths
{
    [JsonPropertyName("path")]
    public string Path { get; set; } = string.Empty;
    [JsonPropertyName("recursionDepth")]
    public int RecursionDepth { get; set; }
}
</source>
''' Key Properties '''
* DiscoveryEnabled: Enables automatic discovery of symbol libraries.
* DataSources: A list of file system paths where SymbolPoint configurations are located.
* Path: The directory containing symbol products, (see [[#Styleoptions|SymCfg.json]]).
* RecursionDepth: How many folder levels to search for data.
==== Usage Examples ====
''' Internal In-Process Client '''
<source lang="csharp">
var settings = new SymbolPointConfig
{
    DiscoveryEnabled = true,
    DataSources = new List<ProductPaths>
    {
        new ProductPaths { Path = "C:\\Symbols", RecursionDepth = 2 }
    }
};
var factory = new SymbolPointServiceFactory();
var client = factory.New(settings);
</source>
==== Legacy Service Client ====
<source lang="csharp">
var factory = new SymbolPointServiceFactory();
var client = factory.New("SymbolPointService");
</source>

Latest revision as of 11:39, 20 November 2025

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);

    }
}

Configure SymbolPointServiceClient in GDK5

This section documents how to create and configure a SymbolPoint Service Client using the SymbolPointServiceFactory class.

The SymbolPointServiceFactory is responsible for creating instances of ISymbolPointServiceClient using different configurations such as bindings, endpoints, or custom settings.

  • Using SymbolPointConfig creates a new internal in-process client that works directly with symbol libraries and renderers without relying on external services.
  • Other factory methods (New(string), New(BindingType, string)) are intended for legacy service clients that wants to run against GDK4 WCF services.

Key Methods

1. Create an internal in-process client based on custom symbol point configuration. If settings.DataSources contains paths, an integrated client is created using local symbol libraries. Otherwise, defaults to a remote service at http://localhost:9008/symbolpoint.

public ISymbolPointServiceClient New(SymbolPointConfig? settings)

Use Case: Modern approach for internal rendering and symbol management.

2. Create a client using a named service configuration from the configuration file used by the binding- and endpointaddress factories injected into the factory.

public ISymbolPointServiceClient New(string serviceName)

Use Case: Legacy service integration.

3. Create a client using a specific binding type and endpoint address.

public ISymbolPointServiceClient New(BindingType bindingType, string endpointAddress)

Use Case: Legacy service integration.

Configuring the Internal In-Process Client

The SymbolPointConfig class defines settings for the internal in-process client:

public class SymbolPointConfig : ConfigBase<SymbolPointConfig>
{
    [JsonPropertyName("discoveryEnabled")]
    public bool DiscoveryEnabled { get; set; } = false;

    [JsonPropertyName("dataSources")]
    public IList<ProductPaths> DataSources { get; set; } = new List<ProductPaths>();
}

public class ProductPaths
{
    [JsonPropertyName("path")]
    public string Path { get; set; } = string.Empty;

    [JsonPropertyName("recursionDepth")]
    public int RecursionDepth { get; set; }
}

Key Properties

  • DiscoveryEnabled: Enables automatic discovery of symbol libraries.
  • DataSources: A list of file system paths where SymbolPoint configurations are located.
  • Path: The directory containing symbol products, (see SymCfg.json).
  • RecursionDepth: How many folder levels to search for data.

Usage Examples

Internal In-Process Client

var settings = new SymbolPointConfig
{
    DiscoveryEnabled = true,
    DataSources = new List<ProductPaths>
    {
        new ProductPaths { Path = "C:\\Symbols", RecursionDepth = 2 }
    }
};

var factory = new SymbolPointServiceFactory();
var client = factory.New(settings);

Legacy Service Client

var factory = new SymbolPointServiceFactory();
var client = factory.New("SymbolPointService");