Neo4j Spatial in GeoServer
Neo4j Spatial includes built-in support for a GeoTools data store. This means it is, in principle, directly usable inside GeoServer. This document will discuss how to get it up and running in GeoServer. If you are interested in a desktop GIS, take a look at Neo4j Spatial in uDig.
Installing Neo4j-Spatial in GeoServer
Installing GeoServer
First of all you need to download and install geoserver from http://geoserver.org/display/GEOS/Download. For detailed installation instructions, refer to the official GeoServer documentation at http://docs.geoserver.org/stable/en/user/installation/index.html Here we provide very basic instructions, with factors to consider regarding installing GeoServer with Neo4j Spatial:
-
Choose the right version for the version of Neo4j Spatial you are going to use:
-
Neo4j-Spatial trunk is currently coded to work with GeoTools 2.7, so this means we need to load it into GeoServer 2.1 or later. The version we tested against was geoserver-2.1-beta1
-
If you want to deploy on the stable release of GeoServer 2.0.2, then you can use an older Neo4j-Spatial, or modify the code to work with GeoTools 2.6 (the differences are small). The last version of Neo4j Spatial that works with the GeoServer 2.0 series, is from the end of September 2010.
-
If you already have a servlet container running, you can download the WAR version, otherwise download the BIN version (or the Windows installer if on Windows). Install and run using the included instructions in geoserver.
-
Once installed, open a web browser on http://localhost:8080/geoserver/web/ (or other location is you configured it differently) to test that geoserver is runnning correctly.
Adding Neo4j Spatial
Install Neo4j-Spatial by copying the following JAR files into the in the GeoServer directory webapps/geoserver/WEB-INF/lib:
-
json-simple-1.1.jar
-
geronimo-jta_1.1_spec-1.1.1.jar
-
neo4j-kernel-1.2-1.2.M03.jar
-
neo4j-index-1.2-1.2.M03.jar
-
neo4j-spatial.jar
Getting this last jar can be achieved by using maven to compile from source, or by simply browsing to the maven repository website at http://m2.neo4j.org/org/neo4j/neo4j-spatial/
At the time of writing the latest JAR was:
-
For GeoTools 2.7 and GeoServer 2.1.x
-
http://m2.neo4j.org/org/neo4j/neo4j-spatial/0.3-SNAPSHOT/neo4j-spatial-0.3-20101021.124131-1.jar
-
For GeoTools 2.6 and GeoServer 2.0.x
-
http://m2.neo4j.org/org/neo4j/neo4j-spatial/0.2-SNAPSHOT/neo4j-spatial-0.2-20100929.153937-103.jar And then re-start Geoserver.
Visualizing Neo4j Spatial data in GeoServer
These instructions lead you through getting started with adding some test layers from Neo4j Spatial to the running GeoServer
Login as 'admin' with password 'geoserver', unless you have changed those in the security/users.properties file during installation
Add a data source
Go to 'Stores' and click 'Add a new Store'
Name the data source and add the path to the Neo4j Database you have your layers in
-
One option for the database location is a database created using the unit tests in Neo4j Spatial. The rest of this wiki assumes that you ran the TestDynamicLayers unit test which loads an OSM dataset for the city of Malmö in Sweden, and then creates a number of Dynamic Layers (or views) on this data, which we can publish in GeoServer.
-
If you do use the unit test for the sample database, then the location of the database will be in the target/var/neo4j-db directory of the Neo4j Source code.
-
Type the URL as the full path to the neostore-id file in the database directory
Publish from data source
Now we will publish a layer from the data source
Click 'Neo4j' under 'Vector Data Sources' and then click 'Add new layer'
Choose the 'Neo4j Data Store'
Choose a layer and click 'Publish' GeoServer seems to have trouble detecting the CRS and bounds, so we have to enter this manually
-
Type CRS manually into the 'Declared SRS' field. For OSM data (as published by the TestDynamicLayers code) use EPSG:4326
-
Click 'Compute from data' to get the native bounding box
-
Copy and paste all these fields into the Lat/Lon bounding box (for some reason, 'Compute from native bounds' is not working)
-
Save the layer
-
Repeat this for as many layers as you want to publish
Previewing layers
Preview one of the published layers
Go to the layer preview page and select the layer and 'OpenLayers' or other option for preview.
Preview multiple layers
-
Add a layer group, by clicking on 'layer groups'
-
and then click 'add new layer group'.
-
Enter the name, and copy the bounds from one of the layers you plan to add. The 'Generate Bounds' function does not seem to work.
-
Enter the CRS as the same as the one used in one of the layers you plan to add.
-
Then click 'Add Layer' and select a layer to add to the group. Repeat this for as many layers as you plan to add.
-
Save the group and then go to the Layer Preview and you will see the group as an option to preview.
-
Select 'OpenLayers' to preview in a dynamic map that can be zoomed in.