The OpenLS (Route) service allows you to determine a route based on specification, start point, and end point. The supported interfaces of the service are SOAP/WSDL-based WSIRoute and the OGC OpenLS (OLS) 1.1 Route Service.
This service provides an interface to compute a shortest path between a given set of stops. The web service can optionally reorder the given set of stops to find a best path. The route result consists of estimated time to travel, total distance covered, the bounding box, geometry, turn-by-turn instructions, and the language used for the instructions.
Refer GeoMedia WebMap Administrator Guide here for more details on supported operations.
Refer GeoMedia WebMap Administrator Guide here.
After the OpenLS (Route) service is created and configured, browse the URL http://localhost/DemoRouteService/Route.asmx. If the web service is accessible, a list of simple operations are displayed.
<SupportedLanguages> <Language>en-US</Language> <Language>zh-CN</Language> </SupportedLanguages>
Since the supported interfaces of the service are SOAP/WSDL-based, the operations supported by OpenLS (Route) web service can be tested using the SOAP UI. Download SOAP UI.
Create a new SOAP project and provide initial WSDL as http://localhost/DemoRouteService/Route.asmx?wsdl (Note: DemoRouteService is an OpenLS(Route) instance configured with demo data) The supported interfaces/operations are listed under WSIRoute and individual interface’s request can be modified to get desired result.
For example if the “GetAllDatasetInfo” operation request is fired it will provide the details of the dataset configured in the Route Service. See snapshot.
Similarly, the “DetermineRoute” operation request (refer attached xml) is also modified to get the basic routing output using start point and end point.
Thus by using the SOAP UI tool the interfaces/operations supported by the OpenLS Route web service can be tested with different input requests. The output response thus provides necessary idea that would be needed to develop a fully customized Routing solution.
Advanced web services of GeoMedia WebMap provides a web service for OpenLS Routing. Its implementation is not out of the box. Custom development is required around this web service and also at portal client like user interface, map visualization and interaction in order to achieve Routing workflow on Geospatial Portal.
In this integration basic start point to end point routing with quickest route is discussed. Computing route via a point between start and end points is also discussed here. Routing Instructions and Route Summary can be displayed in tabular format. The Route geometry information provided by the web service has to be parsed so that a route layer can be created using PSS and displayed on Map along with the start, end and via points.
Step 1: Add Route webservice as web reference in Portal SDK project
In the PortalSDK Application project, add a web reference to http://[server_name]/DemoRouteService/Route.asmx and name it (say) RoutingService.
Step 2: Create a generic handler (*.ashx) to add Route webservice server side code
Add a Generic Handler to the Application project, say Routing.ashx. Replace the contents of the ashx with the following code.
Source Code - GWM_Routing_Integration_with_Portal_SDK.cs
Add missing references (if any). The above handler code is taken from the WebMap documentation. But it has been modified to respond to ajax calls which sends input parameters (Start Point, End Point, ViaPoints). The above code after computing the routing, the output is serialized to JSON and sent as response to the ajax call.
Step 3: User Interface to perform and visualize Routing on Portal SDK Client Application
These are the design requirements:
Sample User Interface:
Step 4: Some useful Javascript snippets
User input point and placing pins
Fetching a point from user click on map, and place a pin at that point. Using this code snippet, start, end point and via points coordinates can be fetched and displayed on map using a pin.
The specific pin can be cleared using the following snippet:
$GP.map.pin.clear({ featureClassId: "startPointPin" //use featureClassId to remove a specific pin });
Execute Route button click event
Button click event to generate route using the input parameters (start and end points, viaPoints if selected). It fires an ajax to the Routing handler. Code
Write a custom function to parse route result JSON object to display route layer, route instructions etc…
Sample JSON structure for route result object. Parse this object to visualize routing output information on Geospatial Portal.
If objRoute is output route object, then
SRS Name: objRoute.Geometry.Item.geometryMembers[0].srsName
Route Layer geometry bounding box: objRoute.Summary.BBox
Total Route Distance: objRoute.Summary.Distance.Value
Total Route Duration: objRoute.Summary.Duration
Route instructions array: objRoute.RouteInstructions (contains route instructions geometry information (coordinates) for each instruction.)
Fetch Route Instruction and Geometry data
Consider an array routeInstructionsObj = objRoute.RouteInstructions to store route instructions information. It will be used to get geometry and instruction information.
In the route instruction array, actual start - end points and via points coordinates can be fetched by
if (routeInstructionsObj[i].Geometry.Item.hasOwnProperty("coordinates")) { // Stops coordinateObj = routeInstructionsObj[i].Geometry.Item.coordinates.Value.split(','); geojsonStops.features.push({ type: "Feature", geometry: { type: "Point", coordinates: coordinateObj } }); }
Loop through the instruction array routeInstructionsObj for Item.coordinates and store the coordinates in geojson variable geojsonStops. This will be used to draw points using PSS. Meanwhile, routeInstructionsObj[i].Geometry.Item.curveMembers contains the route coordinates for each instruction.
geojsonRoute.features.push({ type: "Feature", geometry: { type: "LineString", coordinates: coordinateArray } });
Loop through the instruction array routeInstructionsObj for Item.curveMembers[].segments and store the coordinates in geojson variable geojsonRoute. This will be used to draw route layer (linestring) using PSS.
Each Instruction has the following information. Parse this instructions accordingly into tabular format.
routeInstructionsObj[i].Instruction routeInstructionsObj[i].Duration routeInstructionsObj[i].Distance routeInstructionsObj[i].BBox
Draw route map using PSS
Draw PSS using the stop point coordinates and route layer (linestring) coordinates stored in geojson. Code
pssStyleObj is the style geojson object. It is used to style the route layer (line) and stop (points). Refer Portal SDK documentation for $GP.map.draw api for the sample geojson object structure. Code
Step 5: Code Build and Deployment setup
Build the PortalSDK solution, once the all the required source code (for ashx handler, UI design and javascript functions to process route result at client-side) is in place.
Create a WMS service for the same data source which was used to process route data earlier. This will be helpful for the user to place accurate start and end points on the map.
Details about the movie:
Note:View in fullscreen and 720p resolution for better visualization