Example of how web services can be integrated: incident management application

This example shows you how to use the different components of Geoconcept Web, and to link one component in with another to construct a complete application.

We will take as an example an accident management application requiring search for the nearest rescue service. In this application, the service operators feature in a traditional kind of database (Oracle, SQL Server, …).

Geocoding of service providers

Add to the table of service providers two numeric columns with X and Y (or latitude and longitude) as column headers.

For a full scale and rapid geocoding operation (several thousand lines) use the Universal Geocoder application in desktop mode, or in batch mode.

For a less ambitious Geocoding operation, one can also use the geocoding web service described in the documentation. This web service takes an address as input, and returns the best address or addresses found, with their respective X and Y coordinates.

Indexing longitude and latitude fields

Making modifications to the application

Adding a Geocoding functionality to handle incidents

After typing in the address of an accident via a form, a geocoding step is added (étape_géocoder_) that calls the geocoding web service. It is also possible to display a map of the location at which the accident happened, with the Javascript component, using the GCIS component. Following geocoding, a position for the accident (X,Y) can be obtained. Thanks to the Javascript functionalities, it is possible to centre the map displayed on the X, Y position returned.

Search for candidate rescue services

In the first instance, a preliminary selection needs to be made of the nearest rescue providers occurring within the limits of a Bounding Box that has to be defined.

First, construct an approximate first query in the table of providers to search for providers in a square X kilometers around the site of the accident. Then calculate (approximate formula):

longitude0 : longitude sinistre
latitude0 : latitude sinistre
l : distance de recherche (en km)
R = 6371 (en km)
delta_latitude = (180 / PI) * l / R
delta_longitude = (180 / PI) * l / R / cos(latitude0)

which can be achieved with a simple SQL query:

SELECT * FROM prestataire
WHERE longitude > longitude0 - delta_longitude
AND longitude < longitude0 + delta_longitude
AND latitude > latitude0 - delta_latitude
AND latitude < latitude0 + delta_latitude

This example of a query defines a certain number of candidate providers among the nearest. If the number of candidates is too high (more than 100), one can restart the operation by dividing the distance in two. If the number of candidates is too low, one could also restart the operation by doubling the search area, until the correct number of candidates is found (a minimum of 10, for example). The next step will be to classify these potential candidates as a function of the method chosen, in order to highlight the nearest.

Calculating distance, time and sort operations on candidate entities

We use the “SearchAround” Web Service described in the documentation to classify candidates as a function of the chosen method.

The user only needs to present the result of classified providers to the user for them to then choose the most suitable provider (the nearest in distance or the nearest in terms of travel time).

Display of candidates on a map

We would use the API Javascript component to include the map in the existing web application and display the providers on a street map background.

Utilisation of API Javascript
gcweb-reference-img/lbs-integration/lbs-gestion-sinistre-1.png

Route calculation

The route calculation web service returns a route sheet in xml format between a start address (supplied by the user via the form filled in) and a service provider chosen by the user.

It is then possible to use this route sheet to track an itinerary between the start and arrival points.

Route calculation
gcweb-reference-img/lbs-integration/lbs-gestion-sinistre-2.png