Skip to content

Instantly share code, notes, and snippets.

@oliverheilig
Last active January 13, 2023 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oliverheilig/d900c3ee3d51a8ba670b445f9968f336 to your computer and use it in GitHub Desktop.
Save oliverheilig/d900c3ee3d51a8ba670b445f9968f336 to your computer and use it in GitHub Desktop.
xServer-2 Data Integration Strategies

whitepaper

PTV xMapServer-2 supports the Google-style map tile standard. This allows to use xMapServer with virtually every exeisting mapping client for both cloud and on-premise. These clients also have APIs to overlay the map with your own data, so you can keep you data where it belongs: in your database.

This article explains the different strategies for combining your data with xServer functions. They depend primarily on the quantity of the data and the complexity of the use case.

Making your Data spatial-aware

First you have to make your business data "spatial aware". You can do this just by adding two additional fields: latitude and longitude. If you need coordinates for your address data, you can use PTV xLocate to perform a geocoding, which calulates the lat/lon values for an address. Read here for guidelines how to use xLocate in various programming languages.

After you've stored these fields in your data table, it should be prepared for most geographic use cases. The database doesn't necessarily need do be a fully-fledged Oracle-DB, it can also be a plain old csv-file. This can be loaded into the application or browser and displayed on a map. Here's a sample for 10k locations loaded as .csv from here and displayed on via Leaflet.

<iframe width="950" height="540" src="https://ptv-logistics.github.io/xserverjs/premium-samples/poi-locator/map-only/index.html" frameborder="0" allowfullscreen></iframe>

Search and Analze your Data

Geocoding your data not only enables to display it on a map, you can also search for all locations which are reachable within a certain time (by car, pedestrian, etc.). You can find the source code here.

<iframe width="950" height="540" src="https://ptv-logistics.github.io/xserverjs/premium-samples/poi-locator/" frameborder="0" allowfullscreen></iframe>

Working with Regions

Most modern map clients also support the display of region data (postal code regions or districts) as GeoJSON. This data can be obtained by our partner dds, either combined with socio-economic data, or just as borders which can be linked to your own business data (for example by postal-code). This sample displays the regions and municipalities of Luxembourg. The source code can be found here.

<iframe width="950" height="540" src="https://ptv-logistics.github.io/xserverjs/premium-samples/admin-regions/" frameborder="0" allowfullscreen></iframe>

Large and Complex Data

One limitation of client-side rendering is that both the bandwidth and client-performance is usually limited. This requires a more complex setup, where the client only displays pre-rendered images from an application service.

This sample uses this approach. The client can be Leaflet or PTV xServer.NET, while the rendering is performed in ASP.NET utilizing SharpMap. The source code can be found here.

Just as for client-side data, the data can be linked to application data and combined with xServer for analytic queries.

xMapServer for Visualizations

xMapServer2 also plays well with the ultra modern WebGL-based clients:

References

  • xServer-dashboard - PTV xServer documentation
  • xServer.js - JavaScript Samples for PTV xServer
  • xServer.NET - Source code for PTV xServer.NET
  • SharpMap.Widgets - Build responsive map applications for web and desktop
  • SharpMap.Ptv - SharpMap Addons for PTV Services and Data
  • SpatialTutorial - A tutorial that shows some practices to visualize, analyze and manipulate spatial data with PTV xServer, ASP.NET and JavaScript
Copyright (c) 2017, PTV Group
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment