Digital Mapping Solutions

ResponseMX Blog

A platform for building spatially enabled rich internet applications.

Multiple ResponseMX applications with mapserver

In the past, if you used mapserver as the mapping engine, you could only use one ResponseMX server application inside Tomcat. This was due to the fact that mapserver uses native libraries, which can only be loaded once by any given process, rather than pure java libraries.

We have found a way to remove this restriction, which opens up a number of possibilities. For example, it allows different applications to be created for different user groups. We are already using this to allow us to host several different ResponseMX applications in our test environment.

The change requires a small code modification to the ResponseMX server. If you would like to run multiple ResponseMX servers on the same tomcat, please contact Dotted Eyes so we can supply you with a new version of ResponseMX server.

There is no configuration required, but you have to make the following changes to your software installation once you have the new server software.

Set up

Assuming you have two ResponseMX applications called rmxa and rmxb, you’ll need to do the following:

Copy the mapscript.jar file from the WEB-INF/lib folder of one of the ResponseMX applications to $TOMCAT_HOME/shared/lib

For example

cd /opt/app/apache-tomcat-5.5.17/webapps/rmxa/WEB-INF/lib
cp mapscript.jar /opt/app/apache-tomcat-5.5.17/shared/lib

Then for each ResponseMX application installation inside your tomcat, rename the mapscript.jar file so that it is not automatically loaded when ResponseMX starts.

For example

cd /opt/app/apache-tomcat-5.5.17/webapps/rmxa/WEB-INF/lib
mv mapscript.jar mapscript.jar-DO-NOT-LOAD
cd /opt/app/apache-tomcat-5.5.17/webapps/rmxb/WEB-INF/lib
mv mapscript.jar mapscript.jar-DO-NOT-LOAD

Restart tomcat and have fun with maps.

Troubleshooting

It is important that none of the applications try to load mapscript.jar from the WEB-INF/lib folder any more, so if the server won’t start or won’t produce maps, check each installed webapp for mapscript.jar first.

MapServer, ResponseMX — Jon Hawkesworth on June 11, 2008 at 12:42 pm

ResponseMX Database search enhancements

I’ve been busy this week enhancing ResponseMX’s database search functionality.

At the moment if you have spatial data in Oracle, SQLServer, MySQL or access databases you can configure ResponseMX to search your database records and locate points on your maps.

In ResponseMX 3 you’ll have more flexibility when configuring searches. You’ll be able to specify how records are matched. Currently if you enter ‘Abbey’ into the search form, you’ll only find records that start with the word ‘Abbey’. However, if you add <matchmethod>contains</matchmethod> inside the <search/> tag, the word Abbey could appear anywhere in field that is being searched, so if you were searching a list of addresses you’d find ‘Mary’s Abbey Road’ as well as any Abbey Roads, Abbey Streets or Abbey Avenues you might have in your database.

Also, you’ll be able to conditionally filter out certain records. This can be useful when generating pre-populated searches. Say for example you have the locations of pharmacists in your database but wanted to have two pre-populated searches, one showing those offering evening and weekend services and another showing those with daytime opening hours. In ResponseMX 3 you’ll be able to add something like the following to your search xml:

<filter>
<field>Out_Of_Hours</field>
<string>Y</string>
</filter>

This will change the search so that unless the Out_Of_Hours field contains a Y, the record will not be displayed in the search results.

By the way, both these changes will work the same if you are using database layers or are searching layers drawn from .TAB files and will work the same if you are using MapXtreme Java or MapServer.

Jon

MapXtreme Java, MapServer, ResponseMX — Jon Hawkesworth on February 29, 2008 at 3:53 pm

How to display polygons from non-spatial databases

Here’s a tip for mapserver users which allows you read and display vector data stored within a regular database in ResponseMX.

You will need ODBC access to your database. I’ve used mysql on windows for this example but other databases should work just the same.

The tip takes advantage of OGR ability to understand geometry in Well Known Text (WKT) format, via its Virtual Format mechanism.

So to be of use, you’ll need to be able to create WKT feature descriptions and store them in a text column in your non-spatial database.

To do this you need to do the following:

1. Create a database containing your vector data
2. Create a system DSN to give ODBC access to a data source
3. Create an .ovf file
4. Test the connection through ogrinfo to prove access to the data
5. Modify map file
6. Modify the ResponseMX geoset

Here’s the detailed steps:

1. Create a database containing your vector data

Create a database table


  DROP TABLE IF EXISTS `test`.`polygon_test`;
  CREATE TABLE  `test`.`polygon_test` (
  `Record_Id` int(10) unsigned NOT NULL auto_increment,
  `Polygon` text NOT NULL,
  `Info` varchar(45) NOT NULL,
  PRIMARY KEY  (`Record_Id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Now add some data to it. The Polygon column is going to hold the geometry which can be a very long string, so it needs to be a text type column.


insert into polygon_test values (DEFAULT, 'POLYGON (( 350600 420200, 350600 440200, 330100 440200, 330100 420200, 350600 420200 ))', 'A square');
insert into polygon_test values (DEFAULT, 'POLYGON (( 436909.520549625 346979.908498395, 428048.086151056 341231.951050675, 431401.061328893 329975.534382221, 443495.721791806 330694.029063187, 446249.951402172 340752.954596698, 446249.951402172 340752.954596698, 436909.520549625 346979.908498395 ))', 'A Pentagon');

2 Create a system DSN to give ODBC access to the data source

On Windows, Go to Control panel -> Administrative tools -> Data Sources (ODBC) then select the System DSN tab.

Click Add and select the correct driver for whatever database is being used, e.g. SQL Server, MySQL

From this point the set up will be specific to the database server, but typically you will have to configure the database server connection details, such as server name, database name, username and password, default database to connect to.

Test the connection once you have entered the necessary details.

Once you have a working ODBC connection to your database you’re ready for step 2.

3. Create an .ovf file

The ovf file provides mapserver with the connection details it needs to retrieve geometry and feature information from the database.

Example .ovf file:

<OGRVRTDataSource>
<OGRVRTLayer name=”boundaries”>
<SrcDataSource>ODBC:TestDbUser/secret@testdb</SrcDataSource>
<SrcLayer>geometryTable</SrcLayer>
<FID>Record_Id</FID>
<GeometryType>wkbPolygon</GeometryType>
<GeometryField encoding=”WKT” field=”POLYGON”/>
</OGRVRTLayer>
</OGRVRTDataSource>>

Things you will have to configure:

<OGRVRTLayer name=”boundaries”> – this needs to be the name of your data source, in this case ‘boundaries’

<SrcDataSource>ODBC:TestDbUser/secret@testdb</SrcDataSource>

This is the odbc connection string which is in the format

ODBC:username/password@database

or

ODBC:username/password@database,tableName

<SrcLayer>geometryTable</SrcLayer> – this is where you specify the table that holds your vector data.

<FID>Record_Id</FID> – this may or may not be required. It is used to specify the column that contains the unique key for the row (the Feature Identifier, hence FID). Mapserver will have a go at guessing but can be confused by some data structures, hence this tag.

For point data you would leave <GeometryType></GeometryType> set to wkbPoint and leave the encoding attribute of the <GeometryField/> tag set to “PointFromColumns”.
Then you will need to specify the columns where the x and y coordinates are drawn from in the database table as the x and y attributes of the <GeometryField/> tag.

However, in this example we’re storing polygons in our database, so you would set
<GeometryType></GeometryType> to wkbPolygon and set the GeometryField tag thus:
<GeometryField encoding=”WKT” field=”POLYGON”/>

This tells OGR to expect the geometry of our polygons to be stored in a column called POLYGON and encoded in WKT format.

You’ll need to store your .ovf file in the same folder as your mapserver’s .map file. To avoid confusion, give the file a name that matches the layer name you’re going to give the layer in your .MAP file. e.g. boundaries.ovf

Be aware that although the .ovf file format looks like xml, it isn’t actually fully-compliant xml, so don’t put an xml declaration at the top of the file and if you have problems when you test the connection, make sure you don’t have blank lines or hidden characters in the file.

4. Test the connection through ogrinfo to prove access to the data

Having configured your .ovf file, test it using the following ogrinfo command:

ogrinfo -al boundaries.ovf

ogrinfo will warn you that the layer is read only with the following message:

ERROR 4: Update access not supported for VRT datasources.

This is ok - unfortunately virtual format layers can’t be updated (yet). If your configuration is correct you will be rewarded with a list of the features in your database.

5. Modify map file

Now you’ll need to modify your mapserver’s .map file to include your new layer. Note that you’ll need to provide styling for the layer as there won’t be any styling information in your database.


LAYER
NAME "boundaries"
STATUS ON
CONNECTIONTYPE OGR
CONNECTION "boundaries.ovf"
DATA "polygon_test"
TYPE POLYGON

6. Modify the ResponseMX geoset

Finally add the layer to the Response MX geoset xml file that corresponds to your mapserver .map file. Depending on your requirements this may be as simple as adding


Finally restart ResponseMX to pick up your changes

With luck your new layer is displaying your polygons.

If not here are a few things to check:

If you are using x and y values to retrieve point data, there seems to be a limit to the numeric length that OGR can handle for the FID column approx 12 digits long.

Check that your data is really in Well Known Text format. When setting up this test I managed to miss a couple of spaces which meant two coordinates were stuck together. The tell tale for this is ogrinfo -al shows ‘POLYGON (string)’ before the feature data but doesn’t then repeat all the feature data without the ‘(string)’. In other words ogrinfo can see your data, but can’t turn it into WKT.

There are several ways in which you can get WKT format wrong - see this post for another example: http://www.mail-archive.com/mapserver-users@lists.umn.edu/msg03679.html

Be careful when using the tag. I had this in my first few attempts and it stopped mapserver in its tracks. You shouldn’t need to specify a SRS in the .ovf file if the data is in the same spatial referencing system as your other layers.

Further info

Reference on mapserver site:

http://mapserver.gis.umn.edu/docs/reference/vector_data/VirtualSpatialData

Actual ovf file reference documentation:

http://www.gdal.org/ogr/drv_vrt.html

MapServer, ResponseMX — Jon Hawkesworth on February 6, 2008 at 12:53 pm

Ashfield Internet Goes Live

ashfield.png

Ashfield District Council have launched the first datasets on their Internet application Mole2 (Mapping Our Local Environment).
Datasets have so far been uploaded for planning history, local plans and councillors.

MapServer, ResponseMX — Charlie Gilbert on September 21, 2007 at 4:01 pm

ResponseMX with MapServer on Linux

It’s been over 6 months since we integrated MapServer with ResponseMX. In that time we’ve used the open source mapping engine for several custom ResponseMX applications, but until now we’ve only been able to offer ResponseMX with MapServer on a Windows operating system.

While the interfaces into MapServer (using MapScript Java) are consistent across both platforms the installations of MapServer are, as you would expect, radically different. All the binaries for MapServer on Windows come as a single package (MS4W). On Linux, however, MapServer is distributed as source code which must be compiled - along with all its dependent libraries.

Help is at hand, though. Frank Warmerdam provides an excellent set of libraries known as FWTools which bundles together most of the libraries required to compile MapServer. This package is a huge shortcut, saving several man-days of effort over configuring and compiling the libraries individually, from scratch.

While there are a number of pitfalls en route to successfully compiling MapServer, nearly all are well documented on the mapserver user forum. However, there was one issue we couldn’t find help for. The following error message occurred when the MapServer library loaded in the JVM:

java.lang.UnsatisfiedLinkError:<br />/usr/local/mapserver-4.8.4/src/mapscript/java/libmapscript.so:  /usr/local/FWTools-1.3.1/lib/libtiff.so.3: undefined symbol:  jpeg_resync_to_restart.

This error originates from the libtiff library, and occurs even if tiff support is turned off when compiling MapServer. It had us scratching our heads for some time. The problem is caused by a conflict between the jpeg library in FWTools and the jpeg library that comes with Java (read more). Fortunately this problem is specific to the latest versions of FWTools, v1.3.1 and v1.3.2. Installing and using an earlier version (v1.1.1) resolves the runtime error.

MapServer, ResponseMX — Stephen Battey on August 31, 2007 at 2:46 pm