MDX Data Store for GeoServer

What this is all about...

This is a demo to show the capabilities of the GeoTools MDX data store coupled with the GeoServer map server. An exec summary is available here
The goal of this software is to build a lightweight, minimal but useful bridge between OLAP and GIS, in other words, to build a software that:
  1. Can add a minimal set of geographic functions to Mondrian without the need to have a dedicated Mondrian build (just add a JAR to the lib directory of Mondrian)
  2. Lets GeoServer produce maps out of OLAP data sources using MDX queries
  3. Enables an OLAP data warehouse to have geograpphic features without the need of a dedicated spatial component (just use a TEXT column in your table)
In addition to this "readme", there are two other panes in this application:
The "Catalog" pane shows the catalog of MDX queries that are "geo-enabled" (via columns storing WKT geometry). Click on one of the row to select the layer associated with it and proceed to the "map" pane.
The "Map" pane shows the map. You should first select the style in which to style the map then click "Show maps" to have the maps disdplayed (optionally, you may add a background layer to the maps).
More technically, the architecture of this demo is composed of:
  • A PostgreSQL/PostGIS database. Since the data are stored as WKT geometries in a text column, there is no need of PostGIS once data have been converted into WKT format.
  • A Pentaho Mondrian OLAP engine
  • A demo web application hosed on the Jetty servlet container
The MDX Data store is a GeoTools component that read an MDX query from a Mondrian store and converts the geometry dimension into GeoTools features and its measures and dimensions into feature attributes.
The prepared MDX queries are stored in the OLAP itself, as a separate cube that is read by the data store: each query in the catalog cube becomes a feature layer in GeoServer.
Warning: the display of maps may be slow (after all, the store is still in alpha version), especially if you select the "states" query.
Warning: this application has been tested on FireFox 3.6, Google Chrome 8.0, Internet Explorer 8 but the SVG map works only on Chrome.

Examples of geo-enabled MDX queries

In addition to let GeoServer serve maps straight out of OLAP data warehouses, a set of geographic Mondrian user-defined function has been developed to perform geographic queries on Mondrian.
For the time being only 6 functions have been defined:
  1. MemberToGeometry (returns a String out of a Member, in order to use both a Member or a String to specify a geometry)
  2. Contains (returns true if the first argument contains the second)
  3. IsWithinDistance (returns true if the first argument is within a given distance from the second argument)
  4. Merge (returns a geometry made up of the geometies contained in the first argument (a Set))
  5. Area (returns the computed area of the geometry given as first argument)
  6. Length (returns the lenght/perimeter of the geometry given as first argument)
These functions can be used to in the MDX queries used for defining the datasets used by GeoServer to draw maps or just to restrict the data returned by non-GeoServer MDX queries. Some example of the latter case follows:
Computes the areas of subregions and use it as a measure.
WITH MEMBER [Measures].[Area] AS
'Area(MemberToGeometry([Geometry].CurrentMember))',
FORMAT_STRING = "##0.##"
SELECT {[Measures].[Area], [Measures].[Land]} ON COLUMNS,
{Filter({[Geometry].Children}, [Measures].[Land] > 0)} ON ROWS
FROM [States]
Returns states containing the point (-120, 43). You can see the resulting map by choosing the "selstates" query.
WITH MEMBER [Measures].[Within] AS
'Aggregate(
Filter({[Geometry].[WKTState].Members},
Contains(MemberToGeometry([Geometry].[WKTState].CurrentMember), "POINT(-120 43)")
),
[Measures].[Land])'
SELECT {[Measures].[Within]} ON COLUMNS,
{[Geometry].[All]} ON ROWS
FROM [States]
Returns the Geometry as a measure (it as been defined as a property in the Mondrian schema).
with member [Measures].[Geometry] as '[Geography].CurrentMember.Properties("Geometry")' select {[Measures].[Geometry]} ON COLUMNS, NON EMPTY {[Geography].Children} ON ROWS from [States]

Queries catalog

This is the content of the geograpny-enabled MDX queries into the OLAP.
Choose one of the queries in the catalog then pass to the next pane.
The meaning of columns is the following:
  • Name of query (it will become the name of layer in GeoServer)
  • MDX query text
  • Type of geometry
  • Name of member containing the geometry as WKT

Maps display

Choose what to put in the map, then press the button
Choose style: Display background layer
This is a "live" map that the user can navigate (pan, zoom) using the mouse.
This is a static bitmap map (actually, a PNG). It has no behaviour, but the nice thing is that it can be embedded on any page without special coding: it is just an image, set the src with a specific URI and you're good to go.
This is an SVG map, it is static, but can be nicely styled with CSS and some behaviour can be added by handling the DOM events via JavaScript.
If you click on a polygon once the polygon turns yellow, if you click on it twice, it gets back to the default color. This beahviour is not generated by GeoServer, but by the JavaScript code that is implemented in this page.
Warning: SVG is supported only on Chrome.
This is a (rather small) KML map showing the results of the States MDX query. This map can be easily overlaid on Google maps imagery using the "import" feature of Google maps website producing this output.
To see the map with a bigger extent, go to the goole.map website by clicking on the link on the right (mind, the states are paginated, hence to browse them all you have to click on the page numbers at the bottom of the left pane).
Warning: this map has been loaded on Google servers off-line, hence it does not change when a different layer or style is chosen.