X
Geocode your GIS data with WFS geocoding in GpsGate Server
2011-05-22 17:39 by Jonas Development, Labs

Many companies have existing GIS data in systems that are separate from GpsGate Server. The data could be geographic data such as roads, cities and district boundaries of their region, or it could be business related data such as electric power lines and stations. This blog explains how to enable geocoding of your own GIS data in GpsGate Server. This can be used with reporting to see if a vehicle has been at a location in your GIS data.

Introduction

Many companies have existing GIS data in systems that are separate from GpsGate Server. The data could be geographic data such as roads, cities and district boundaries of their region, or it could be business related data such as the electric power lines and stations served by a utility company, or it could be a transport business’ customer locations.


You can get more value out of your existing GIS data by making it accessible as a geocoding data source in GpsGate Server. Geocoding is the process of translating an address into coordinates and the opposite, which is called reverse geocoding, is the translation of coordinates into address/location data. For a utility company, this could mean that the weekly report shows when and for how long a utility service vehicle was at a specific transmission line for repairs. This blog explains how to enable geocoding of your own GIS data in your GpsGate Server installation.


This blog post consists of three parts:


Part 1 – Make your existing GIS data accessible by setting up a WFS
Here I explain how to install and configure GeoServer to publish your GIS data through a WFS. Although GeoServer is used as the example of this blog, note that since WFS is a standard there are many more vendors that allow publishing data through a WFS service, for example ESRI ArcGIS Server.


Part 2 – Installing and configuring the WFS plugin
In Part 2 I go through the necessary steps to let GpsGate Server read your GIS data. This involves creating a geocoder, adding a WFS geocoder provider and mapping your data fields (columns) to the GpsGate format. I also show how to make one of your VehicleTracker applications use the geocoder.


Part 3 – Testing the WFS geocoder
Finally I explain how you can test the WFS plugin by entering known coordinates and an address to see the result.

Part 1 – Make your existing GIS data accessible by setting up a WFS

To enable geocoding of your own geographic data in GpsGate Server you can make it accessible through a WFS service. WFS is short for Web Feature Service and is a standard from the Open Geospatial Consortium that allows accessing geodata over the web.


WFS will make your data a source for geocoding in GpsGate Server, similar to using Google or CloudMade. Since WFS is a widely spread standard, there are several free and commercial solutions for making geodata accessible as a WFS. In this blog post I will use the free GeoServer version 2.1.0 as an example WFS server.


GeoServer supports a wide range of geodata formats, see this list for all supported data formats.


As a side bonus of using GeoServer with GpsGate Server, you can also use it to show shapefiles as maps in VehicleTracker.


In this blog I use the already published sample data in GeoServer. However, you need to publish your own data as described in the following steps.

  1. Download GeoServer and run the installer. Follow the installation steps. When asked to install GeoServer to run manually or as a service, choose “Install as a service” to make the WFS service always online.
  2. When installation is finished, open the GeoServer Web Admin Page from the Windows Start menu.
  3. Log in with the user that you specified in the installation.
  4. Your GIS data should belong to a GeoServer ”workspace”. Click ”Workspaces” → Add new workspace.
  5. Enter a name of your workspace. This should typically be a short form of a company name, e.g. ”myco”. Also enter a unique Namespace URI, where it is IMPORTANT that the last part of the URI must match the workspace name. To clarify, if you enter the workspace name “myco” then the Namespace URI must end with “/myco”, for example http://www.myco.com/myco
  6. Click “Submit”. Your workspace is done.
  7. Click ”Stores” → Add new Store.
  8. In this example we have a directory of spatial files (shapefiles), so we will use it as a data store. Click ”Directory of spatial files (shapefiles)”.
  9. Select the workspace that you created in step 1.
  10. Enter a Data Source Name for your data, e.g. ”mydata”.
  11. Under ”Connection Parameters”, in the textbox for ”Directory of shapefiles” , enter the file URI to your directory of shapefiles, e.g. file://C:\Geodata\Shape. GeoServer will detect any shapefiles in the directory. Click Save.
  12. You will see a list of ”layers”. These are grouped data such as ”cities” or ”power lines” that you can publish. Click Publish for a layer that you want to make accessible for geocoding. Note that it will be possible to geocode with multiple layers. If a position overlaps both a city and a road in two different layers, that data could be mapped to both a StreetName and a CityName. The StreetName and CityName could then show up as the address in a report for the vehicle that was on that position. You can go back to adding more layers later by clicking “Layers” in the GeoServer Web Admin Page.
  13. When publishing a layer, it is required to set the spatial reference system of your data. Queries to GeoServer from GpsGate Server will be in WGS84 since this is used by the GPS system. GeoServer can handle on the fly re-projection of your data so if you have data in a fairly well known spatial reference system you can set up a conversion here, from your reference system to WGS 84. In the textbox for Native SRS, enter the name of the spatial reference system of your GIS data. In the textbox for Declared SRS (this is how the data will look externally when GpsGate Server is querying the WFS), enter EPSG:4326 (EPSG:4326 is another name for WGS84). You can then select to “reproject native to declared” in the drop down list. Or if you know that you have data in WGS84 already, select “force declared”.
  14. For Native Bounding Box, click “Compute from data”.
  15. For Lat/Lon Bounding Box, click “Compute from native bounds”.
  16. Click Save.
  17. Your layer should now be visible in the list of published Layers. Add all the layers that you want accessible as described in step 12-16 above.

You have now published some GIS data layers that are accessible through the GeoServer WFS.
To test that your layers have been published correctly, click “Layer Preview” in GeoServer Web Admin Page. For your layer in the list, click “OpenLayers” to get a clickable map of your data.


You are now all set up and ready to install the WFS plugin in GpsGate Server!

Part 2 – Installing and configuring the WFS plugin

In Part 1 you published layers of your GIS data through WFS. Now let’s use it in GpsGate Server! You will do the installation of the WFS plugin in the GpsGate Server Site Administration application.


In SiteAdmin, go to Plugins and

  1. Click “Change URL”, enter “labsupdate.gpsgate.com” and press Enter
  2. Click “Get More Plugins”
  3. Install the plugin “Geocoder”
  4. Install the plugin “WFS”


Now that you have installed the WFS plugin, you will create a new geocoder and add a WFS geocoder provider to it. This step is very similar to the earlier blog post “Geocoder Integration with GpsGate Server”.

  1. Go to Maps → Geocoders
  2. Available Geocoders
  3. At the bottom of the list of Available Geocoders, enter the name “WFS” and click New.
  4. Click Details for the geocoder named WFS.
  5. At the bottom of the list of geocoder providers select WFS in the drop down list and click Insert.
  6. The list of geocoder providers will by default contain a “Cache”. A Cache provider will reduce the number of request to your WFS service, which is good for performance in a live system, but for this example you can remove it by clicking Remove.
  7. Click Save.
  8. On the WFS geocoder among the available geocoders, click Edit.
  9. Click Edit on the WFS geocoder provider. This will bring up a settings form.
  10. WFS Geocoder Provider Settings
  11. Under Base Settings, enter the URL to your GeoServer installation WFS capabilities document. A capabilities document generated by GeoServer and is XML that explains how a client (in this case the WFS plugin) can use the WFS. Typically, if GeoServer is installed on the same machine as GpsGate Server, this is http://localhost:8080/geoserver/wfs?version=1.1.0&request=GetCapabilities
  12. Click “Get WFS Layers” to get a list of the layers that you published in GeoServer in Part 1 of this blog. To be able to use your data with GpsGate Server, the data should be mapped to the GpsGate “Location” format, so configuring the WFS plugin involves mapping your own data columns to the GpsGate Location object. As you see in the screenshots In this example I have published sample data that comes with the GeoServer installation.
  13. For each layer of your data that you want to map to GpsGate Server, select the layer in the “Layer” drop down list. Select a property to map a field (column) to in the “Location Property” drop down list. Select the field name that should be mapped from the “Field Name” drop down list. Click Add Data Mapping. In this example I have mapped the Location properties from two different layers named “topp:tasmania_roads” and “topp:tasmania_cities”. This shows that multiple layers can be mapped to the same location. When you reverse geocode a coordinate pair that overlaps both a city and a road from two different layers, data will be mapped to both StreetName and CityName in this example. The StreetName and CityName then show up as the address in a report for the vehicle that was on that position.
  14. When you have created mappings for all properties that you want, click Save.


Click Save again which will bring you to the list of available geocoders. Done! We can now test that the WFS geocoder is working. I show how to do this in Part 3 – Testing your WFS geocoder.

Part 3 – Testing your WFS geocoder

Our WFS geocoder is now configured and we want to test that it is working. We will specify which application that should use the geocoder and then test it to do both geocoding and reverse geocoding.


We will create a new Vehicle Tracker application to test our WFS geocoder with.

  1. Go to Applications -> Create New. Select the Application Type “VehicleTracker”, enter the name WFSGeocoderTestApp and click Next. Enter a new test administrator user, or use an existing one, that can log in to the application. Click Next.
  2. In the application page, scroll down to “Geocoding” and select the geocoder “WFS” that you created in Part 2.
  3. Select WFS geocoder for application
  4. Click Finish.
  5. Go back to Maps -> Geocoders and click “Test Geocoders”
  6. Select the application “WFSGeocoderTestApp” that you created in step 1 from the drop down list.
  7. We can begin testing geocoding an address to a coordinate pair. In this example I enter “Hobart” in the textbox for “Geocode query string”, but you can enter a value that you know is found in your data.
  8. Test Geocode
  9. Click “Geocode”
  10. The result shows up in the Test Result area.
  11. We can now use the coordinates of the found location to test reverse geocoding. Copy and paste the value of Longitude and Latitude to the corresponding text boxes “Test Coordinate Longitude ” and “Test Coordinate Latitude”
  12. Test Reverse Geocode
  13. Click “Reverse Geocode”
  14. You can see the result in the Test Result area.

Concluding Remarks

Now that we are done configuring the WFS plugin you can use it with a real VehicleTracker application to among other things create reports.


You can preferrably add more geocoder providers to the list of providers in your geocoder. It is good practice to add a “Cache” geocoder provider first in the list for improving geocoder performance. You can also add another geocoder provider to the end of the list, such as Google, so that a coordinate that is not found in your GIS data will still get an address.


Jonas

Discuss this blog post on the forum please.

Blog categories

GpsGate Video gallery

Collection of video tutorials.

Active Forum topics

Subscribe to our Newsletter

Subscribe to the GpsGate Newsletter and get all the latest product updates, useful guides and tutorials and even receive hot offers.
E-mail
© 2012 GpsGate AB, All rights reserved. Privacy Policy
Wrong Username or Password