SymbolPoint service and client setup

From Maria GDK Wiki
Jump to navigation Jump to search

This page covers running SymbolPoint under GDK5 MariaServiceHoster and connecting MariaApplication or third-party apps to the new HTTP service or an existing GDK4 service.

Run SymbolPoint under MariaServiceHoster

For general host configuration and deployment, see configuration, hosting and routing, and deployment. SymbolPoint is disabled by default. To enable it and load products, merge this into appSettings.ServiceSettings.Local.json beside the host executable:

{
  "HostedServices": {
    "SymbolPoint": {
      "Settings": {
        "Disabled": false,
        "DataSources": [
          { "Path": "C:\\MariaData\\symbolpoint", "RecursionDepth": 1 }
        ]
      }
    }
  }
}

Set Path to a directory the host can read. A depth of 1 is appropriate when each product folder, containing its own symcfg.json, is directly under that directory. Include the MilSymSVG product for military point symbols. Restart MariaServiceHoster and check the startup log for the loaded product names.

With the default routing, clients use the host's HTTP listener on port 5110 at /symbolpoint; the child listens on loopback port 5121. Check http://127.0.0.1:5110/symbolpoint/ready: HTTP 200 means at least one product loaded. When Swagger is enabled, browse to /symbolpoint/swagger/index.html on the same host.

How MariaApplication selects a SymbolPoint source

MariaApplication selects one source at startup:

  1. Local files: A nonempty symbolPointConfig.dataSources list in the effective GeneralConfiguration.json selects the integrated renderer, regardless of the service endpoint.
  2. GDK5 HTTP: With no local sources, a SymbolPointService endpoint with a nonblank address and neither a nonblank bindingRef nor an explicit binding selects the GDK5 HTTP client.
  3. Legacy WCF: Otherwise, MariaApplication uses the named SymbolPointService endpoint as a WCF endpoint. The shared configuration defaults to WCF.

This is startup selection, not failover. If the selected service is unreachable, MariaApplication does not switch sources or transports.

Connect MariaApplication to GDK5 HTTP

If local sources are configured, set symbolPointConfig.dataSources to [] in GeneralConfiguration.local.json to clear the inherited list. Add or update the following entry in ClientServiceConfiguration.local.json:

{
  "endpoints": [
    {
      "name": "SymbolPointService",
      "address": "http://127.0.0.1:5110/symbolpoint",
      "bindingRef": null
    }
  ]
}

For a remote deployment, use its published scheme, host, and port. Use the service base URL ending in /symbolpoint, not a /web or /api/v1 endpoint. The endpoints array merges by name: "bindingRef": null clears the inherited WCF reference, while omitting it keeps the shared value. If your base endpoint supplies an explicit binding, remove it from that endpoint to use HTTP.

Place each .local.json beside its active base file. MariaApplication looks in %LocalAppData%\TeleplanGlobe\MariaGDK first, then in the application folder. When running from source, local override files in the MariaApplication project directory are ignored by Git and copied to the application output on build. Restart MariaApplication after changing the effective configuration.

If you previously configured symbolPointConfig.httpServiceUri, remove it and use the named endpoint above instead.

GDK5 also accepts APP-6C/2525C codes with an unambiguous single-point mapping. These render using Delta artwork, not the original GDK4 Charlie artwork. Use the legacy service if you need that artwork.

Connect MariaApplication to legacy GDK4 WCF

Leave symbolPointConfig.dataSources absent or empty in the effective configuration. Remove the HTTP SymbolPointService override if the shared WCF endpoint already points to your GDK4 service. Otherwise, replace the override with a WCF address and binding reference:

{
  "endpoints": [
    {
      "name": "SymbolPointService",
      "address": "http://127.0.0.1:9008/symbolpoint",
      "bindingRef": "[binding]"
    }
  ]
}

Replace the example address with the actual GDK4 SOAP endpoint. [binding] uses the top-level binding (normally BasicHttp); use a binding that matches your legacy deployment. Restart MariaApplication. For legacy server options, see legacy SymbolPoint settings.

Connect third-party applications

Third-party applications can call the GDK5 service over HTTP without installing the GDK client libraries. Use the published /symbolpoint base URL:

  • Get a PNG: GET /symbolpoint/web/app6c/SFSPXM----*****?maxSize=64&crop=true. The response body is image/png; the Symbol-Info header contains JSON metadata, including the anchor and bounds. For Delta SIDCs, use /web/app6d/{sidc}.
  • Render a batch: Send POST /symbolpoint/api/v1/symbols/render with Content-Type: application/json and the body below. The response includes a state and metadata for each returned symbol; ImageData is a base64-encoded PNG. Check the symbol state, not just the HTTP status. See /symbolpoint/swagger/index.html for the full API.
{
  "Symbols": [
    {
      "ProductId": "app6c",
      "SymbolLayerIds": ["SFSPXM----*****"],
      "MaxSymbolSize": 64
    }
  ]
}

For an existing GDK4 deployment, use its /symbolpoint/web/... routes for PNGs or its SOAP/WCF endpoint for managed operations. The GDK5 /api/v1 requests do not work against GDK4.

Connect from .NET with SymbolPointHttpClient

Reference the GDK5 TPG.GDK.CommonCore.SymbolPoint.Client library in a .NET 8 or later application. The client does not require WCF, Windows-specific GDK libraries, or MariaApplication configuration files. Pass the published SymbolPoint base URL, ending in /symbolpoint, directly to the client. The example uses the default MariaServiceHoster port and renders one of the APP-6C symbols described above; the server must have the MilSymSVG product loaded.

using System;
using System.IO;
using TPG.GDK.CommonCore.SymbolPoint.Client;
using TPG.Proto3.SymbolPoint;

using var client = new SymbolPointHttpClient(
    new Uri("http://127.0.0.1:5110/symbolpoint"));

var request = new SymbolsRenderSpec
{
    Symbols =
    {
        new SymbolRenderSpec
        {
            ProductId = "app6c",
            SymbolLayerIds = { "SFSPXM----*****" },
            MaxSymbolSize = 64
        }
    }
};

var result = await client.GetSymbolsAsync(request);
if (result is null || result.Symbols.Count == 0)
    throw new InvalidOperationException("No SymbolPoint response was returned.");

var symbol = result.Symbols[0];
if (symbol.State != SymbolData.Types.SymbolState.Ok)
    throw new InvalidOperationException($"SymbolPoint render state: {symbol.State}");

await File.WriteAllBytesAsync("symbol.png", symbol.ImageData.ToByteArray());

The client checks service readiness on its first request. Reuse the client across requests and dispose it when done. For batches, check each result's State: Partial is not a complete render, and Failed has no image. Product roots are configured on the server, not through the client.

Windows applications already using the GDK ISymbolPointServiceClient abstraction can instead call new SymbolPointServiceFactory().NewHttp(endpointUri) from the TPG.GDK.Windows.SymbolPoint.ServiceClient namespace to keep that interface. Both client options target the GDK5 HTTP API and do not fall back to WCF.