Geocoder Integration with GpsGate Server using HTTP

This blog will demonstrate how to integrate a geocoding service over HTTP with GpsGate Server. A simple xml-based protocol is defined which allows 3rd party integration. We show how to configure GpsGate Server to communicate with the geocoding service, and how to use the appropriate tools to test the integration.


Introduction

GpsGate Server includes several types of geocoder providers out-of-the-box. For example, Point-of-Interest, Geofence, Google, and more. There is also an encoder available that can be configured to make web service requests to an URL using a simple xml-based protocol. It is, unsurprisingly, called “HTTP Geocoder”. With this geocoder, a 3rd party integration can be made by implementing a web service using, for example, PHP, JSP, or any other script-engine for dynamically-generated web pages. The following examples will use a fictitious web service, MyMap, implemented using PHP and located at http://your-server.com/Geocoder.php.

Protocols

Reverse Geocoding Protocol

When the MyMap geocoder provider does a reverse geocoding request, it will use the following URL format:


http://your-server.com/Geocoder.php?op=ReverseGeocode&longitude=103.851718&latitude=1.290655


The part in bold is configurable, as we’ll see in a moment.

The result of the request is expected to be xml with the following format:


The recognized elements within the Location element are: Address, AdministrativeAreaName, CityName, CountryName, PostalCodeNumber, StreetBox, StreetName, StreetNumber, SubAdministrativeAreaName, Longitude, Latitude, and Altitude.

Geocoding

A geocoding request is performed similarly. Here we send a query using the following URL format:

http://your-server.com/Geocoder.php?op=Geocode&Query=CITY+HALL

The result is expected to be a list of locations:

Installation of the Http Geocoder

To manage geocoders within GpsGate Server we need to install the Geocoder plugin. Within SiteAdmin > Plugins, find and install “Geocoder” from the update.gpsgate.com repository. This adds a new link under Maps: “Geocoders”. You also need to install the Dispatch plugin. We’ll use it for testing the integration. When you’ve installed the prerequisits, this is what you should have:


Plugins


Now, let’s go to “Maps > Geocoders” and create a new HTTP geocoder for our fictitious MyMap geocoding service:



I have set the URL to http://your-service.com/Geocoder.php. I also have a cache provider first in the provider chain. This is good practice, as it reduces the number of requests to the geocoder web service. Cached results are stored in the server database.

Next, select the geocoder for your application (SiteAdmin > Applications > Search and Manage):



Remember to save your modifications. The configuration of GpsGate Server is now complete.

Testing

Within VehicleTracker we can now test the MyMap geocoder. Drop the “Request Address” pin onto the map at a desired location:



The result is a success. Now lets test geocoding. This time we will use the dispatch plugin. Enable this plugin for your application within SiteAdmin:


Application Privileges


Now within your Vehicle Tracker application, enable dispatch for a user (Admin > Features):



Using the dispatch plugin, open up the “Create new Job” dialog and enter a search query. If all goes well you should see this:


Geocoding

Conclusion

This concludes the walk-through on how to integrate a 3rd party geocoding service. The configuration within GpsGate Server is quite simple and all the tools for testing are available. What remains is to create an integration service using a server-side scripting language of your choice (or any server technology for that matter). I’ll leave that part to you wink If you have any questions about this walk-through, don’t hesitate to visit the forums.

Daniel


  Discuss this blog post on the forum please



Download free GpsGate Server

Install it on your own server. The installation is free for 5 users.

Download Now