Академический Документы
Профессиональный Документы
Культура Документы
Installation
This tutorial will guide you through the initial steps to get up and
running with Cartaro. Because Cartaro is based on several open
source components, we need to make sure all requirements are met.
This guide is based on Ubuntu Precise (12.04 LTS). You might need to
adapt commands depending on your Linux distribution.
If you find the installation too complicated for a first sight at Cartaro
then you should try Cartaro on the OSGeo Live DVD or use the Docker
container for Cartaro.
Prerequisites
PostGIS 1.5 or later are supported by Cartaro's PostGIS module.
Apache and PHP requirements are set by Drupal and Tomcat
requirements are set by GeoServer.
sudo su postgres
createuser --pwprompt --no-superuser --no-createdb --no-createrole DBUSER
createdb --encoding=UTF-8 --owner=DBUSER DBNAME
psql -d "DBNAME" -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
psql -d "DBNAME" -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql
psql -d "DBNAME" -f /usr/share/postgresql/9.1/contrib/postgis-
1.5/spatial_ref_sys.sql
psql -d "DBNAME" -c 'grant all on geometry_columns to "DBUSER";'
psql -d "DBNAME" -c 'grant all on spatial_ref_sys to "DBUSER";'
exit
Next you need to download and install GeoServer. Versions 2.2.x and
2.3.x has been tested with Cartaro:
wget
http://sourceforge.net/projects/geoserver/files/GeoServer/2.3.x/geoserver-
2.3.x-war.zip
sudo unzip geoserver-2.3.x-war.zip geoserver.war -d /var/lib/tomcat7/webapps/
JAVA_OPTS="${JAVA_OPTS} -DENABLE_JSONP=true"
Cartaro Installation
Download and extract the distribution to a location of your choice
within your web server (e.g. /var/www/) and proceed with the installation
in the same way you'd install a plain Drupal as described in the
installation guide or just follow the steps outlined below.
Point your browser to the extracted Cartaro download within your
webserver to launch the graphical installer.
After Drupal verified its permission you are asked for the database
configuration.
If
you opted to install demo data your Cartaro will have some capital
cities predefined (content type Capital with title and coordinates).
Documentation
Getting Started
Once Cartaro is installed you will find yourself in a basically empty
Drupal instance. Of course if you've chosen to install sample data
these will now be present, too. The first steps are probably setting up
users, roles, content types and custom theme to suit your case.
Content types are describing the fields and the structure of a specific
kind of content (e.g. the content type Capital contains the fields name
and location to generate content elements for the respective capitals
displayed on the map). To create a new content type, just follow the
steps below.
Choose a name and description for your content type and proceed
clicking Save and add fields.
Add a
new
field for
your
content
type by entering a descriptive name. We want to create a geospatial
field with the name Geometry. Select Geospatial data as field type and
OpenLayers Map as widget. Click Save to proceed to the field's
settings.
Choose your field settings in the new window: Select the geometry
type that describes the kind of geospatial information you want to
store. Choose Polygon to follow our example. Now click Save field
settings to go on.
The next screen asks for more settings of the newly created field. You
can now choose the map configuration and editor to use and select
the permitted amount of objects to draw on the map. The defaults
should be fine but check that OpenLayers Editor is set as OpenLayers
Behavior because that provides a nice editor for spatial data. Proceed
again with Save settings to finish the field creation.
Drupal directs you back to the list of attributes (manage fields screen)
but no other fields are necessary for the example. You have now
defined a content type with spatial data.
Under the tab Manage fields you could create further non-geospatial
fields. We don’t need to create a new one for our example.
Configuring GeoServer
GeoServer is used to provide layers via Web Feature Service (WFS) and
Web Map Service (WMS) with the geospatial field from your newly
created content type.
OpenLayers is used to display your new layer on a map. You will now
associate your GeoServer layer with your OpenLayers map.
Choose Content from the menu bar to see all existing content
elements within your Cartaro installation.
Select Add content to add more content and choose your new content
type in the appearing window (not shown). In the configuration page of
your new content element (called node in Drupal language) make the
following settings:
1. Type a name
2. You can draw the geometry for your content element. Choose the
draw symbol on the upper right corner of the map. Note that tool
tips are shown when you hover the toolbar icons. Click on the
map to create a new geometry. Finish the drawing with double
click.
3. Save your geometry.
Only one geometry per content element can be drawn in our example
configuration. Create additional content elements to add more
polygons.
You should now see your new content element.
To view your new content element on the front map, click on the
house icon in the upper left corner.
Things to try
Use the Layer Assistant to include external layers (see Structure
→ Open Layers → Layers → Add using assistant).
Change the default map behaviours and build your own map.
Try different geometry types and build more complex content
types.
Documentation
Using Drupal users and roles in GeoServer
The core idea of Cartaro is the closest possible integration of geodata
with other content in a single software stack. This aspect also
extends to the common management of users, roles and their
permissions, meaning you should be able to apply the same security
mechanisms and permissions for spatial and non-spatial content.
Within Cartaro the permissions for non-spatial content are handled by
Drupal. GeoServer, on the other hand, is responsible to deliver
optionally protected geospatial data to the web either through web
services (OWS) or through a number of downloadable file formats.
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:/applicationContext.xml
classpath*:/applicationSecurityContext.xml
classpath*:/applicationSecurityContextOverride.xml</param-value>
</context-param>
Finally make sure GeoServer does actually use the new service by
selecting it in GeoServer's global security settings.
The name of the new User-Group Service should be the same that the
Workspace name that you choose when installing Cartaro. The
database credentials should be the same as used for the
Authentication Provider. Password Encryption can be set as plain text
since Drupal hashes passwords itself and Password policy can be set
as default. More info about password management inside GeoServer
can be found in GeoServer documentation.
Activate the authentication provider by moving it into the list of active
providers (Security → Authentication → Authentication Providers).
Simply use the same user name and password as for logging into
Cartaro when accessing GeoServer's web services from a third-party
application. This applies in case you want to access GeoServer from a
desktop GIS for feature editing over WFS for example.
Note that you need to prepend your Drupal user name with Cartaro's
workspace if, and only if, your GeoServer is shared by multiple Cartaro
instances. For example if the GeoServer workspace used by Cartaro is
called forestry and your Drupal user is pat, your desktop GIS would
need to use forestry_pat as user name. Your password is unaltered.
Prefixing user names and roles in GeoServer provides that the Cartaro
instances are distinguishable in GeoServer in such case.
Documentation
Store Geospatial Data
A field type called Geospatial Data is available in Cartaro and can be
used to define custom content types. Those fields can hold map
features of common types and contain an unlimited number of
features, each. You would define your content structure as usual but
also add Geospatial Data fields.
You can choose to either provide or view your data as WKT or on a
map. WKT is a simple text base format to specify spatial data. An
example of using a map for editing with point, line and area features
follows.
Documentation
Provide Geo Web Services
The tight integration of Cartaro with GeoServer allows you to publish
your geospatial data in a multitude of data formats and web services.
As soon as content types with geospatial data fields have been
created, you will be able to add layers to your GeoServer through
Cartaro. Creating your own GeoServer styles (SLD format) allows for
visual customization of GeoServer layers.
Creating new Geoserver layers from Cartaro
Based on the geodata in Drupal, we can create now GeoServer layers
that will be provided via WMS or WFS.
In the layer specifics section there is the actual layer definition that
will be created from GeoServer as a view performed over the Drupal
database. This view can be modified to fit your needs. The rules
defined at the end of the view definition allows WFS-T operations over
the layer.
Documentation
Visualize Geospatial Data
Custom maps can be configured using the OpenLayers module to
visualize geospatial data. This article will describe how to display your
spatial features on a map and how to build custom maps. You can
either display single features on separate pages or display collection
of spatial features on a central map as shown below.
Single Feature
The spatial features from a node can be displayed in numerous ways.
By default they will be visualized on a map. To change the display
settings go to Structures → Content types and click on manage display
of the content type you want to edit. Select the desired format and
optionally change the display settings by clicking on the button on the
right.
Feature Collection
Before you can display a collection of spatial features, you need to
create a GeoServer layer that contains those features. Go to
Structures → GeoServer → Layers and click on Edit of the respective
layer. Depending on your needs, enable one of the check boxes in the
OpenLayers form section.
The GeoServer layer is now available to the OpenLayers map
configuration. Go to Structures → OpenLayers → Maps and edit or
create a map. You can enable your layer from the list in the overlay
layers section that appears after clicking the Layers & Styles tab.
Styling can be provided using SLD files as shown in this example to
render railways and bridges differently. More information can be found
in the documentation of the OpenLayers module or the symbolization
howto.
Information Popups
Additional data can be provided for features using popups so that the
data is displayed as soon as a feature is clicked. Even though Cartaro
presents sensible information by default you might want to customize
the displayed data. To do it, open Structure → GeoServer and edit the
layer in question. Modify the SQL query so that a column name provides
the popup's title and a column description its main content. Also enable
and configure the Pop Up for Features behaviour in the OpenLayers
map settings.
Documentation
Displaying maps within other content
Once you have configured a map in Cartaro you surely want to display
it in appropriately. You could use the Frontmap module if your site is
very map-centric but integrating maps within other content is often
preferable.
Tick OpenLayers Filters in the list of filters and drag the items in the
processing order section around so that OpenLayers Filters comes
last. This allows Drupal to enhance your content (adding links for
example) and insert maps lastly so that other filters don't interfere
with map rendering.
Embedding maps
It's finally time to add content with maps or add maps to existing
content. Navigate to Content, then Add content or edit.
Once MapFish Print runs on the server, the OpenLayers Print module
can be activated and configured by going to Structure → OpenLayers
→ Print (see screenshot above). Afterwards enable the OpenLayers
Print behavior for desired maps and a print button should appear in the
lower right corner of the map.
Documentation
How to protect your data
In an GIS environment it is often needed to protect the data provided
by the map server, restricting some clients to certain regions or
certain kinds of vector/raster data. As a consequence, clients must
authenticate themselves to have access to protected resources.
Drupal has fine-grained built-in protection for content types. The same
protection must apply to the geodata within Cartaro, but with Cartaro,
data can be accessed not only through the Drupal GUI. With its
integration with GeoServer, Cartaro can expose OGC webservices that
are accessed through direct HTTP requests according to the OGC
standards.
On layer creation, the default permissions are taken from the content
GeoServer also supports access control at the service level. There are
two main categories of services in GeoServer: OWS services, such as
WMS and WFS, and RESTful services. Service access rules can be
defined using the Geoserver GUI.