Integrating Custom Data

The rendering of geographical content is not a monolithic process without any possibility for intervention. It can be divided into several steps for interspersing own custom data between the geographical objects provided by PTV xMap. This feature is possible with Web serviceClosed A web service represents a communication technology applied in computer networks. It provides an interface described in a machine-processable format, for example WSDL. and RESTClosed REST (Representational State Transfer) represents a World Wide Web paradigm, consisting of constraints to the design of components which results in a better performance and maintainability. API, whereby the latter is demonstrated in this use case.

Benefits

Using the incorporated profilingClosed A profile is a collection of parameters used to configure the request. Full profiles consist of a number of specialized sub-profiles like the VehicleProfile which describes the properties of a vehicle. mechanism, it is possible

Such use cases can be implemented by using the simple REST API.

Prerequisites

Check if the following prerequisites are fulfilled before you start with the use case:

  • Installed and licensed PTV xMap Server
  • Installed PTV Map

Concepts

The whole geographical content of a map is divided into several groups, which make it possible to intersperse own geographical data into the map rendering:

  • The first, or better lowest layer group consists of background content like oceans, rivers, forests, etc. These more area-like objects, commonly covering the whole map content, are candidates for being replaced by aerial or satellite views.
  • Intermediate layer content is represented by transport relevant data like street segments, tunnels and bridges, which can be
    • underlayed by a routing polygon or
    • overlayed by e.g. own POI information.
  • Commonly, this POI should be placed below the textual labels. Therefore, these labels represent the third group of layers.

By means of dedicated profiles, each of the three layer groups mentioned above can be separated from each other and rendered in separate images. For merging all of these images plus the custom geographical content, these images have to support transparency for all sections of the image, which do not contain any information.

Programming Guide

For the following code samples, the REST API is used providing the URL pattern


            http://hostname:50000/services/rest/XMap/tile/{z}/{x}/{y}?storedProfile={profile}
        

for map tiles. Please note the order of the parameters and refer to the REST operation tile to learn more about the supported URL schema. This is the information you must supply to your toolkit to have it display tiles from PTV xMap. In the following samples, a Leaflet defined TileLayer is used to address the xMap tiles:


          new L.TileLayer(window.location.protocol + "//" + window.location.host + '/services/rest/XMap/tile/{z}/{x}/{y}?storedProfile=silkysand&layers=background',
              {
                  pane: 'tilePane',
                  minZoom: 3,
                  maxZoom: 18,
                  attribution: copyright,
                  noWrap: true
              }).addTo(map)
        

Mapping with interspersed customer data

To integrate customized content, multiple requests to PTV xMap have to be used, each provided with a different profile:


            <Request map with Background profile>
            <Draw own (e.g. routing) data>
            <Request map with Transport profile>
            <Draw my own (POI) data>
            <Request map with Label profile>
        

The following Leaflet sample shows how to achieve this goal. Besides three requests to the xMap layering, two layers are integrated between these xMap layers. These two client-side rendering layers are using customized data, which is hard-coded in the script:

Replace PTV background

In the following example, the Leaflet concept of base layers is used to show the replacing of the PTV background layer. Leaflet's base layers are a collection of layers, which can be shown alternatively. By means of the L.control.layers object, the base layers (and overlays) can be manipulated by the user concerning its visibility:


            var baseLayers = {
              'Background': new L.TileLayer(backgroundTileUrl, {pane: 'tilePane', minZoom: 3, maxZoom: 18, noWrap: true}).addTo(map),
              'OpenTopoMap': new L.TileLayer('http://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', { maxZoom: 16, attribution: 'OpenStreetMap, SRTM, OpenTopoMap'
              })
            };

            var overlays = {
              'Transport': new L.TileLayer(transportTileUrl, {pane: 'overlayPane', minZoom: 3, maxZoom: 18, noWrap: true}).addTo(map),
              'Labels': new L.TileLayer(labelsTileUrl, {pane: 'popupPane', minZoom: 3, maxZoom: 18, noWrap: true}).addTo(map),
            };

            L.control.layers(baseLayers, overlays, { collapsed: false }).addTo(map);
        

Related Topics

The following topics might be relevant for this use case.