[GRASS5] HOW to for scripting GRASS to do shortest route analysis on windows 2000 + display results in Mapserver

Radim Blazek blazek at itc.it
Thu Jan 22 11:17:04 EST 2004


On Thursday 22 January 2004 17:29, Stephen Clark wrote:
> Hello,
>
> Is  there anyone that has tried to script GRASS to do shortest route
> analysis on windows 2000 and then display the results on Mapserver version
> 4.0.

Yes, i have made such system, it works, but as it is so awful that 
I must write GRASS Server, which responds queries send by client
via TCP/IP. Client is PHP module, using C library. Here is a part of 
PHP example code which gets shortest path and draws it on the map:

$gserver = new grass_server();
$sp = new grass_points();
$ret = grass_shortest_path_coor($gserver, "road", $x1, $y1, $x2, $y2, &$costs, &$sp);

$spLine = ms_newLineObj();
for ( $i = 0; $i < $spPoints->n; $i++ ) {
    $spLine->addXY( $spPoints->x[$i], $spPoints->y[$i]);
}
$spShape = ms_newShapeObj (MS_SHAPE_LINE);
$spShape->add($spLine);
$spLayer = $map->getLayerByName('sp');
$spShape->draw($map, $spLayer, $img);

GRASS Server already works, but it is not yet on the web, because it is 
not finished. Anyway, on windows, some small changes will be necessary, 
because sockets are bit different on unix and windows, I think.
Client needs nothing from GRASS package, so it should be possible to use 
it without Cygwin, for example GRASS Server on Linux + Mapserver
on Windows.

Radim




More information about the grass-dev mailing list