Everything Java Apache Geospatial Open Source. Hello Shinning Stars!!! Vincent Massol, Raphael Luta, Santiago Gala, Carsten Z.

Tuesday, December 06, 2005

The issues http://issues.apache.org/jira/browse/JS2-395 and http://issues.apache.org/jira/browse/JS2-350 will be interesting to watch because they enable database managment of PSML files and Graffito provides a graphical CMS to PSML content.

Thursday, December 01, 2005

I've been studying the data access methods used by MapServer and in theory any ODBC connection can be used to obtain data from a relational database. That's probably what we want. Afterwords all we need is a nifty car icon to indicate the direction that the car is travelling (the direction part may be tricky). MapServer uses SYMBOLS to label geo features using an icon image.

MapServer supports four categories of data access. The first is the basic file method. It can access files of type shape, arcinfo, mapinfo, us census tiger, csv, etc. These are read only methods of accessing data. Other sources could update these files and MapServer would get the updates. This wouldn't be a good idea because there could be a io conflict.

ODBC can be used to access relational databases (SQL Server, Oracle, MySQL, and company)

The third category of data access is not applicable to our work. MapServer can access data provided by a Spatial database engine like ArcSDE, Oracle Spatial, or PostGIS. These solutions provide spatial indexing and special geographic types. I think this is out of our scope. It would take longer to set up, it is more complex to install. I would suggest exploring this option if you expect to address larger clients.

The last thing that I want to tell you about is MapScript. MapServer exposes their application programing interface so that hackers and integraters can do custom things with MapServer in the language of their choice (Java,PHP,Perl,Ruby). We are not using it but It can be used to create maps and plot data, as well as query data. I will deliver you an example that I found on the net.

And lastly, I looked at your database and the GPSActive table looks like it could be plotted on the Map using the ODBC solution. There were duplicates in the table but they had the same latitude and longitude. MapServer will plot all data from the table. If we want to get fancy and label each car with their own icon we will have to read the database using PHP and plot using MapScript. Give me some more thoughts on what you need.
Here is a simple script that I found using ms4w from maptools.org. It helped me get a grasp on MapScript PHP for MapServer.

<?php

/*
Application: QuickMap
Purpose: Use this file to test mapfiles
Authors: Bill Bronsema (bbronsema@dmsolutions.ca)
Philip Donaghy (philip.donaghy@gmail.com)
Copyright: 2005, DM Solutions Group Inc.
Instructions: - modify the MAPFILE path and the name of the phpmapscript
MODULE (lines 16 & 17)
- in a web browser goto http://127.0.0.1/quickmap.php
- an image of your data should be displayed in your browser, or
a MapServer error
*/

// define variables
define( "MAPFILE", "map/MorganCo.map" );
define( "MODULE", "php_mapscript_44.dll" );

// load the mapscript module
if (!extension_loaded("MapScript")) dl(MODULE);

// open map
//$oMap = ms_newMapObj( MAPFILE, dirname( MAPFILE ) );
$oMap = ms_newMapObj( MAPFILE );

// set projection
//$oMap->setProjection("init=epsg:42304");

// set size
$oMap->setsize(1200, 700);

// set image format
$oMap->selectoutputformat("png");

// draw map
$oImage = $oMap->draw();

// set header
header("Content-type: image/png");

// output map
$url = $oImage->saveImage("");

?>