Mapscript - problem with binary grid (ADF)

Marcin Zajączkowski mszpak at WP.PL
Fri Oct 29 10:47:03 PDT 2004


Hi,

can anyone please help me, i encountered two problems using mapscript
and am unable to figure out the source of the problems.
I have stopped using mapserver executable /cgi-bin/mapserv and started
using mapscript.

1) When using /cgi-bin/mapserv i am able to view grid maps saved in .adf
format, when i started using mapscript they are not drawn.

2) When i try executing a query using mapscript everytime i get no
results (no objects found). When executing the same query on both
/cgi-bin/mapserv and mapscript, /cgi-bin/mapserv find the proper results
and mapscript gets no results.

In both describled cases i use the same maps.

Below are the script used for generating proper images and
/cgi-bin/mapserv and mapscript compile options (in both cases i
downloaded them from the web not compiled them myself)

vars.php
<?php
$VARS["map"] = $_GET[map];

if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
         @dl("php3_mapscript.dll");
else
         dl("php_mapscript.so");

// Odczyt mapy
if( ! $g_Map )
{
         $g_Map = ms_newMapObj( $VARS["map"] );

         $g_Map->web->set("log", "c:/temp/log.log");
         $g_Map->set("debug", 1);
}
?>

viewMap.php
<?php
include('vars.php');

function MS_NINT($x){ return (($x) >= 0.0 ? ((int) (($x)+.5)) : ((int)
(($x)-.5))); }

function MS_CELLSIZE($min,$max,$d){ return (($max - $min)/$d); }
function MS_MAP2IMAGE_X($x,$minx,$cx){ return (MS_NINT(($x - $minx)/$cx));
}
function MS_MAP2IMAGE_Y($y,$maxy,$cy){ return (MS_NINT(($maxy - $y)/$cy));
}
function MS_IMAGE2MAP_X($x,$minx,$cx){ return ($minx + $cx*$x); }
function MS_IMAGE2MAP_Y($y,$maxy,$cy){ return ($maxy - $cy*$y); }

if( $_GET[layers] )
         $g_ShowLayer = explode(' ', $_GET[layers]);

if( is_array($g_ShowLayer) )
{
         reset($g_ShowLayer);
         while ( list($index, $layerName) = each($g_ShowLayer) )
         {
                 $layer = $g_Map->getLayerByName($layerName);
                 if ( $layer )        // jeśli była taka wartswa
ustawiamy jej widocznosc podczas rysowania
                 {
                         if( $layer->set( "status", MS_ON ) == -1 )
                                 die( "set('status', MS_ON): $layerName" );
                 }
                 else
                         die( "$layerName: Layer Not Found" );
         }
}

if($_GET[mapext])
{
         $mapext = explode(" ", $_GET[mapext]);
         $g_Map->extent->setextent($mapext[0], $mapext[1], $mapext[2],
$mapext[3]);
}

switch( $_GET[mode] )
{
         // MAP
         case "map":
            $img = $g_Map->draw();
            $url = $img->saveWebImage(MS_PNG, 0, 0, 0);
         break;

         // REFERENCE
         case "reference":
                 $img = $g_Map->drawReferenceMap();
                 $url = $img->saveWebImage(MS_PNG, 0, 0, 0);
         break;

         // SCALEBAR
         case "scalebar":
         switch($_GET[map_scalebar_units])
         {
                 case "kilometers":
               $g_Map->scalebar->set("units", MS_KILOMETERS);
               break;
            case "miles":
               $g_Map->scalebar->set("units", MS_MILES);
               break;
            default:
                    $g_Map->scalebar->set("units", MS_METERS);
                    break;
         }
         $img = $g_Map->drawScaleBar();
         $url = $img->saveWebImage(MS_PNG, 0, 0, 0);
         break;

         case "query":
         case "nquery":
                 $imgext = explode(" ", $_GET[imgext]);        // [minx,
miny, maxx, maxy]
                 $imgxy = explode(" ", $_GET[imgxy]);        // [clickx,
clicky]
                 $imgsize = explode(" ", $_GET[imgsize]);        //
[imgwidth, imgheight]
                 $imgbox = explode(" ", $_GET[imgbox]);        //[minx,
miny, maxx, maxy]
                 $g_Map->setextent($imgext[0],$imgext[1], $imgext[2],
$imgext[3]);

                 $cellX = MS_CELLSIZE( $imgext[0], $imgext[2], $imgsize[0]
);
                 $cellY = MS_CELLSIZE( $imgext[1], $imgext[3], $imgsize[1]
);

                 $mapX = MS_IMAGE2MAP_X( $imgxy[0], $imgext[0], $cellX);
                 $mapY = MS_IMAGE2MAP_Y( $imgxy[1], $imgext[3], $cellY);

                 $rect = ms_newRectObj();
                 $rect->setextent($imgext[0],$imgext[1], $imgext[2],
$imgext[3]);

                 $mapPoint = ms_newPointObj();
                 $mapPoint->setXY( $imgxy[0], $imgxy[0], 0 );

                   //                $g_Map->zoomrectange( $rect,
$imgsize[0], $imgsize[1], $g_Map->extent);
                 echo "<pre>$imgxy[0], $imgxy[1] (Image coordinates)\n".
                     "$mapX $mapY (Map coordinates)\n";
                 print_r($_GET);
                 //print_r($g_Map);

                 @$result = $g_Map->queryByPoint($mapPoint, MS_SINGLE,
300);
                 echo "\nresult: $result \n";
                 if( $result == MS_SUCCESS )
                   echo "MS_SUCCESS";

                 for( $i = 0; $i < $g_Map->numlayers; $i++ )
                 {
                         $layer = $g_Map->getLayer($i);
                         if( $layer->status == MS_ON )
                         {
                                 @$result = $layer->queryByPoint($mapPoint,
MS_SINGLE, 3);
                                 echo "result: $result,
".$layer->getNumResults()."\n";
                         }
                 }


         break;

         default:
                 $url = "graphics/transparent_pixel.gif";
         break;
}
if(isset($img))
{
         $img->free();
         if($g_Map->web->error)
                 echo $g_Map->web->error;
         header("Location: $url");
}
?>

/cgi-bin/mapserv -v
MapServer version 4.2-beta3 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT
SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT INPUT=EPPL7 INPUT=POSTGIS
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE

phpinfo();
MapServer version 4.2-beta3 OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP
SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT
SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT INPUT=EPPL7 INPUT=POSTGIS
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE

PHP MapScript Version   ($Revision: 1.194.2.3 $ $Date: 2004/05/13 21:37:44
$)



More information about the MapServer-users mailing list