Creating your first editable node

 

Congratulations! You are now ready to create your own editable node, meaning a simple application that lets you edit your own geographical data through a web browser. The basic process is quite simple:

  1. Upload your vector data to the PostGIS database: the shp2pgsql tool that comes with PostGIS will be your friend here!
  2. Configure your application in the applications directory
  3. Restart the server

1. Uploading vector data

We will now guide you step-by-step through this process. For tutorial purposes we provide you with a sample shape file, containing some parcel data in the region of Bruges (Belgium). You can download the file parcels.zip here.

  • Unzip the parcels.zip file in a newly created directory of your choice. You should have the files parcels.shp, parcels.shx and parcels.dbf.
  • Open a Windows command prompt in this directory and type the following command:
shp2pgsql -I -s 31300 parcels parcels > parcels.sql
  • The file parcels.sql has now been generated. It is an SQL script that contains both schema and data insertion statements for your spatial table
  • To execute the script type the following command:
psql -U postgres -d postgis -f parcels.sql
  • You should now be able to see the table parcels in your pgAdmin III console (Start->All Programs->PostgreSQL 8.3 -> pgAdmin III). Just drill down the postgis database tree as shown below in the screen shot:

 2. Configuration

All Geomajas applications are configured in the directory

 <TOMCAT_HOME>/webapps/majas-tutorial/applications

Each application has its own specific subdirectory within the applications directory. As you can see, the tutorial with the samples is also an application wich has, quite appropriately, been named tutorial:

We will call our new application db and put it next to the tutorial application. To speed up things a little bit, we provide you with a zipped configuration of the db application. Download db.zip and unzip it in the applications directory. You should now see the following directory layout:

3. Restarting the server

To activate the new application you should restart the tomcat server. Now navigate to http://localhost:8080/majas-tutorial/applications/db/html/db.html and have a look at your new application:

 The application has two layers as you can see in the layer tree widget at the right-hand side.

  • OpenStreetMap is a raster layer based on OpenStreetMap raster data. Its configuration file is located at db/maps/raster/osm.xml
  • Parcels is a vector layer based on the tabel parcels. Its configuration file is located at db/maps/belgium/parcels.xml.

This parcels layer is currently not visible as indicated by the small eye icon. To make it visible you must zoom in a little bit by scrolling the mouse wheel forward or using one of the zoom tools in the toolbar. The following screenshot has been taken at a slightly higher zoom level:

 The green park at the lower right is one of the parcels.You can now start editing it by activating the edit tool in a similar way as in the feature editing sample. The instructions can be found in the bottom panels.

Congratulations if you have made it so far! You have now created your first editable node. In an upcoming tutorial we will further investigate the configuration files and show you how to add your own data. If you want to try this yourself, check out our online documentation, especially the part that describes the map and layer configurations. Have fun with Geomajas !