Nantes Université

Skip to content
Extraits de code Groupes Projets
README.md 7,94 ko
Newer Older
Damiano Albani's avatar
Damiano Albani a validé
# **Assignment report**

## **Task A: system setup & administration**

### _Work done_

1. Installed and configured Tomcat
 * Used ``tomcat7`` and ``tomcat7-admin`` packages.
 * Added ``manager`` user with the ``admin-gui`` and ``manager-gui`` roles.
 * Configured Tomcat to only serve requests through AJP connector on ``127.0.0.1:8009``.  
   (See Apache section below for explanation.)
2. Installed and configured GeoServer
 * Used the latest stable release (version ``2.7.0``).
Damiano Albani's avatar
Damiano Albani a validé
 * Chose to stick to Java 7, because of Java 8 not being “officially” recommended for production with GeoServer AFAIK.
 * Modified the password of the ``admin`` user.
 * Imported a Shapefile into a new assignment-specific workspace, in order to provide a WFS layers with data over NL.
3. Installed and configured Apache
 * Used ``apache2`` package.
 * Set up a AJP reverse proxy, to behave as a frontend to Tomcat.  
   Explanation of this choice:  
   • Setting Tomcat to serve on port 80 requires additional configuration.  
   • In my experience, Apache is more versatile and powerful in terms of configurations (access control, URL rewriting, SSL/TLS configuration, etc).  
   • Apache can be used to load balance between several GeoServer instances.  
   • It can be handy for serving outage pages in cases where you need to upgrade the webapp and wait for a restart.
4. Configured and activated the firewall
  * Allowing only HTTP (port 80) and SSH (port 22) incoming connections.
5. Carried out common tasks
  * Kept all packages on the server up to date (security best practice).
  * Configured and activated a swap file, due to the limited amount of RAM
    available.
Damiano Albani's avatar
Damiano Albani a validé

## **Task B: application development**

### Application usage

#### Java server backend  

* Running the application with Maven's Tomcat plugin: `mvn tomcat7:run`    
  Then point your web browser to ``http://localhost:8080``
* Building the application WAR file: `mvn package`
* Testing the application:
  * Unit tests:
    `mvn test`
  * Integration tests:
    `mvn integration-test`  
    (will also run unit tests in the process)

#### JavaScript client frontend

On startup, the user is presented with a full-screen map view. At that point, it
is possible to zoom, pan and move around the map.
Via a control in the top left corner, the creation / edition of user
features can be made.

Damiano Albani's avatar
Damiano Albani a validé
A “feature” is made of several properties : an ID, a label and a geometry.
While the ID is automatically generated by the server, the user is responsible
of setting the value of the label (form field) and the geometry (WYSIWYG editor).
All features can be deleted at once with a dedicated button, while individual
features must be deleted in the edit popup window.

In this application, background layers are tile-based MapQuest and OSM sources.
On the other hand, foreground layers are (hand-selected) WFS resources.

Damiano Albani's avatar
Damiano Albani a validé
The application provides an “intersection mode”, which can be switched ON/OFF
via a checkbox at the top-right corner.
When this mode is ON, data from foreground / WFS layers is restricted to areas
which intersects with user features.
This is achieved through an OGC ``Intersects`` filter within the WFS
``GetFeature`` request.
This data filtering could have been done at the client side, using OpenLayers
capabilities. However, it would have incurred lots of data transfer and put a
strain on the web browser memory usage.

##### Known issues

Having user features which geographically overlap breaks WFS requests made
Damiano Albani's avatar
Damiano Albani a validé
while “intersection mode” is active.  
This is due to how the WFS ``GetFeature`` query + ``Intersects`` filter is constructed
(``MultiPolygon`` made of the combination of all ``Polygon`` features).
### _Software libraries selected_

#### JavaScript client frontend

Damiano Albani's avatar
Damiano Albani a validé
1. _OpenLayers 3_  
   Apart from having a lot of experience with OpenLayers (__2__), I've chosen
   OpenLayers over, say Leaflet, because of the need to have a full-featured
   library, handling in particular GML and WKT formats, the WFS protocol
   and providing an API to manipulate features and geometries.
Damiano Albani's avatar
Damiano Albani a validé
2. _OpenLayers 3 Layer Switcher plugin_  
   Third-party plugin to overcome the lack of built-in layer selector in OpenLayers 3.  
   I've slightly modified it to be more compatible with Bootstrap (conflicting
   CSS style names) and to always keep the panel open.
Damiano Albani's avatar
Damiano Albani a validé
3. _Bootstrap 3_  
   Provides useful UI widgets (e.g. popup) with an elegant look and feel.
Damiano Albani's avatar
Damiano Albani a validé
4. _jQuery 2_  
   Used as a general purpose library for common tasks (DOM nodes manipulation,
   event handling, etc).
The application is built using Maven and make uses of Maven Tomcat plugin in
particular, to ease the development process.

1. Application foundation
  * _Spring framework core API_  
    Dependency injection, tests, servlet, etc.
  * _LogBack_  
    Modern and powerful logging framework compatible with SLF4J API.
2. Data persistence  
  I made my selection with the goal to have a pluggable and extensible solution
  that makes possible to (almost) transparently switch between DB implementations
  simply by modifying configuration files.
  * _Spring Data JPA_  
Damiano Albani's avatar
Damiano Albani a validé
    Provides an easy yet powerful way to implement a data access layer, build
    on top of repositories with automatic default methods.
  * _EclipseLink_  
    Full-featured reference implementation of the JPA specification that is
    compatible with lots of databases (including HSQLDB).
  * _HSQLDB_  
    Embedded database that can be run either with a filesystem backend or
    fully in memory (this mode being used in this application).
3. Data validation  
  The application code contains a ``javax.validation``-based solution that
  validates input data before saving entities.  
  In this case, the ``geometry`` field of the ``Feature`` entity is validated
  through a WKT parser.
  * _javax.validation_
  * _GeoTools_ (WKT parser)
4. REST
  * _Jersey_  
    Reference implementation of the JAX-RS specification, that easily plugs
    into _Spring_ dependency injection features via a dedicated module.
4. Tests
  * _TestNG_  
    Unit test framework compatible with both _Spring_ and _Jersey_.
Damiano Albani's avatar
Damiano Albani a validé
## **Original assignment description**
Damiano Albani's avatar
Damiano Albani a validé

Damiano Albani's avatar
Damiano Albani a validé
```
WebViewer displaying a map (of the Netherlands).
Viewer has standard functionalities as zooming, panning, layer selection.
Viewer has possibility to draw a own geometry on the map.
Viewer has ability to send a user drawn geometry to the server.
Server does a check if the user drawn geometry has intersections with (server side defined) wfs layers and returns result of these checks.

What has to be build:

Server Component
 - build with Java (7 or 8)
 - usage of build management tool (preferable maven, but gradle or ant is also ok)
 - War file (to be deployed in Apache Tomcat) or Standalone application (Spring Boot (jetty, tomcat))
 - Make use of libraries (geotools, spring framework, jersey, dropwizard)
 - Rest interface for
	 - receiving geometry and sending back if geometry intersects defined wfs layers
	 - defining wfs layers
	 - getting list of defined wfs layers
	 - checking if wfs layer is available
 - add wfs layer
 - view available wfs layer
 - delete wfs layer
 - update  wfs layer
 - check intersections between geometry and defined wfs layers
 - server component persists wfs layers in file database (hsql, h2)

Client component
 - build with HTML, Javascript
 - Zoom
 - Pan
 - Layer selection 
	background (these are only options, feel free to add your own layers)
			http://geodata.rivm.nl/geoserver/ows?
				
	forground (options, feel free to add your own layers)
			http://geoservices.rijkswaterstaat.nl/nwb_wegen
			http://ahn.geodan.nl/ahn/viewer3/cgi-bin/tilecache/tilecache.py/1.0.0/
	http://www.spatineo.com/ is a good place to find free services
 - Drawing an editing of geometry in viewer
 - Sending Geometry to server component 
 	

What do we expect:
 - working example
 - unit tests
 - source code 
 - motivation for decisions (why usage of geotools or H2 database)
 
What do we provide:
  - accessible linux server
  - login credentials for server
  - email adress for questions
Damiano Albani's avatar
Damiano Albani a validé
```