Web Service Based on GeoTools in The Atlas of Fire Protection

The paper describes a simple way of a systems integration based on SOAP web services. The systems integration described in the paper is covered by a system named The atlas of a fire protection. The atlas is a set of dynamically created maps published in WWW browser. Technologies used for the solution are UMN MapServer, ArcIMS, PHP, GeoTools and Axis. GeoTools and Axis are used for building platform and programming language independent component for the atlas. The paper describes a software architecture used for the atlas and a role of a web service in the integration.


Introduction
It was a few years ago when my colleague ask me if there is a way how to integrate external component for the atlas that allows basic data classification.The atlas was completely build on PHP and PHP/MapScript.We could not find any PHP based component for this purpose.We have found a Java based component GeoTools Lite.There were a few ways how to integrate this component to the atlas.After some research we have found the way of web service based on SOAP (Simple Object Access Protocol) the most flexible and independent.Our decision was probably right and after a few years when the system was rebuilded to support ArcIMS and other tools, the only part based on GeoTools stayed without any change.A month ago one Turkish colleague ask me about documentation of GeoTools used for building web services.Unfortunately I did not have any at that time.I have decided to write this paper to fill this gap on the Internet.I hope that somebody will find this paper useful.

The atlas of a fire protection
The atlas development started in 2004 year with support of General Directorate of Fire Rescue Service of the Czech Republic.The atlas is a web based interactive application that enables a map creation based on user specified conditions.The atlas is based on a statistical database about incidents in a scope of fire brigade field of action.That's why there are two basic ways of thematic map creation: Choropleth maps.

Diagram maps.
The proces of choropleth map definition starts with specification of the following conditions:  The statistical method The atlas was based on UMN MapServer resp.on PHP/MapScript library.Authors of the atlas could not find any method for data classification available in used library.There were two ways how to solve this problem: implement algorithms, use external component.

Geinformatics FCE CTU 2009
The external component has been found in spring 2004.At that time was named GeoTools Lite 1.5.

GeoTools Lite
GeoTools Lite 1.5 library has been used for the atlas.GeoTools Lite 1.5 library is not nowadays developed.Developers can not download it from any official resource.There is available GeoTools Lite follower currently named GeoTools 2.

GeoTools 2
The GeoTools is a set of libraries written in Java language.The main features of GeoTools library are [1]: Why not GeoTools 2?
The reason why was not used the richer library GeoTools 2 instead of GeoTools Lite 1.5 is a quite simple.The module for the classification was not included in GeoTools 2 at the time of the implementation.

Way of integration
The atlas was based on PHP language and the library was based on Java language.There were three possible ways how to integrate the atlas with the GeoTools Lite: Use a source code of GeoTools Lite 1.5 and rewrite it in PHP, A native link of the Java library from PHP using JNI (Java Native Interface), Write a software component based on the GeoTools Lite 1.5 where the communication is based on an other way than JNI.
We believed that classification module will be included in the GeoTools 2 and that a future development of the module is expected at the time of the integration.That is why a rewriting of the code into PHP seemed as a wrong way.The technology named JNI and its usage in PHP was (and still is) experimental and we have not any experience with this technology at that time.We have started our research of SOA (Service Oriented Architecture) in 2003 and at the time of the atlas implementation it was a hot topic of our research (and it still is).That's why we have decided to use web services as a solution for building independent library based on GeoTools Lite available from PHP.

Web Services
Web services can be simply characterised with the following facts.

Software components.
Available via web (based on HTTP).

Simillar to RPC (Remote Procedure Call).
Based on Request / Response.Usualy based on XML (SOAP), but may be more flexible (REST) or simpler and hardcoded (WMS).

GeoWeb Services
GeoWeb services are services that we are dealing (delivering, manipulating, analysing) with geodata.There are several specifications for building GeoWeb services.Well known are for example: Web Map Service.Web Feature Service.

Web Coverage Service.
Catalogue Web Service.

Classification
The Carto Support Service (CSS) was written as SOAP based web service with four public methods: getEqualIntervalBreaks getNaturalBreaks getQuantileBreaks getCapabilities The first three of the methods are used for classification.All of them have the same arguments: string that contains numbers (float or integer) delimited with semicolon and integer that holds number of requested classes.The methods returns string that contains class breaks delimited with semicolon.The fourth method returns XML with the service capabilities description.The description is based on OGC WMS GetCapabilities response.We had to deal with problems with SOAP implementation in PHP in the area of encoding of arrays and lists, that's why the encoding was simply based on text delimited using semicolon.
The SOAP interface for the CSS is based on Axis Library (Apache Foundation).Axis Library and the CSS is hosted on a Tomcat servlet container (Apache Foundation).For web service deployment is used simple autodeploy mechanism that is offered by Axis technology: A source code of a service is copied into directory specified by Axis with jws suffix in a name of the file.
When a Tomcat servlet container is restarted Axis servlet checks content of the directory.
If there is a change of the source code or if there is a new file, the Axis servlet performs compilation of the source code and deployment.The source code

The architecture
The architecture is figured at fig. 3. When a user selects data for a visualisation and specifies a number of classes and a method for classification, the atlas requests via SOAP the selected method on CSS.The request contains data and a number of classes.The response contains classes breaks.The breaks are used with PHP/MapScript library to create requested map.

Other example
There is described an another example how to use GeoTools for building GeoWeb services in the following chapter.

Geinformatics FCE CTU 2009
interval of time from/to of events, incident type (e.g.fire-fighters injured during interventions), statistical method for generating class intervals (Jenks, Equal interval, etc.), number of classes, type of frequency (square km, population), colour scale for classes visualization.An example of a possible result of the choropleth map creation is figured at fig. 1.

Figure 1 :
Figure 1: Choropleth map, Screenshot from Peňáz 2009 Coverage implementation, Coordinate reference system, Symbology using OGC SLD specification, Attribute and spatial filters using OGC Filter Encoding specification, Graphs and networks, Java Topology Suite (JTS), Two renderers, Raster and vectors formats.GeoTools Lite 1.5 GeoTools Lite 1.5 is a library with basic features necessary for geodata manipulation.It consists of modules for: Geodata reading (raster and vector basic formats), Desktop rendering (including diagrams), Projections, Map algebra, Data classification.GeoTools Lite 1.5 data classification For data classification are available three methods: Equal Interval, Natural Breaks (Jenks), Geinformatics FCE CTU 2009 Quantile.