Using PHP Mapscript to change DATA for Oracle Spatial

Fernando S. simon at INF.UNIVALI.BR
Tue Nov 16 03:53:21 EST 2004


Hi,
    I tested here and the problem is with the mapscript code, you can't
set the layer->data directly, you need to call set() function. I'm using
the PHP Mapscript.
   In my example:

With this way the data is draw corectly:
.....
$dataLayer = $map->getLayerByName("flisk");
echo $dataLayer->data."<br>";
$data = str_replace("cola_a", "cola_b", $dataLayer->data);
echo $data."<br>";
$dataLayer->set("data", $data);
echo $dataLayer->data."<br>";
$image=$map->draw();
.....


This way don't have efect:
.....
$dataLayer = $map->getLayerByName("flisk");
echo $dataLayer->data."<br>";
$data = str_replace("cola_a", "cola_b", $dataLayer->data);
echo $data."<br>";
$dataLayer->data = $data;
echo $dataLayer->data."<br>";
$image=$map->draw();
.....

I used this layer:
LAYER
        NAME "flisk"
        STATUS ON
        TYPE polygon
        CONNECTIONTYPE oraclespatial
        CONNECTION "XXXX/XXXX at XXXXXX"
        data "coordenada from (SELECT shape as coordenada FROM
cola_markets WHERE name = 'cola_a') USING GEOMRELATE"
        type polygon
        class
            color 255 0 0
            outlinecolor 0 0 200
        end
END

Thanks.

----------------------------------------------------------------
Fernando Simon - simon at inf.univali.br
Mapserver and Oracle Spatial developer
G10 - Laboratorio de Computacao Aplicada
http://g10.cttmar.univali.br
----------------------------------------------------------------


Steve Hall wrote:

> Hi all,
>
> I'm working with the 4.4.0 beta2 release so i'm not sure if this is a
> bug, me doing something wrong or it's just not meant to do what i'm
> trying!
>
> I have an Oracle Spatial layer defined in my map file:
>
> LAYER
>   NAME PostcodeData
>   GROUP all
>   TYPE POLYGON
>   STATUS ON
>   CONNECTIONTYPE oraclespatial
>   CONNECTION "user/pwd at db <mailto:user/pwd at db>"
>   DATA "GEOM FROM (SELECT B.GEOM, R.RESULTS, B.BASENAME, R.REPORT_ID
> FROM BASE B, RS_RESULTS_NUMBER R WHERE B.BASEID=R.GEOGID AND
> R.REPORT_ID = !REPORT_ID!) USING SRID 8192"
> [more of the "usual" stuff here]
>
> END
>
> The !REPORT_ID! is a placeholder that I want to replace at runtime
> with a know value, which I try using a fragment of PHP code like this :
>
>  $map = ms_newMapObj($map_path."thematic.map");
>  $dataLayer = $map->getLayerByName("PostcodeData");
>  echo $dataLayer->data."<br>";
>  $data = str_replace("!REPORT_ID!", "19594", $dataLayer->data);
>  echo $data."<br>";
>  $dataLayer->data = $data;
>  echo $dataLayer->data."<br>";
>  $image=$map->draw();
> Although the string replace is working fine and it looks like the
> assignment to $dataLayer->data is working too, when I make the call to
> draw() then it fails and throws out the SQL stored in the .map file,
> not the one I have manipulated on the fly.
>
> I have managed to workaround this using the FILTER statement (and
> corresponding PHP calls) for now but ideally i'd like to prove this
> can be done at the SQL level as i'm going to be doing more complex
> alterations to this SQL later on.
>
> Many thanks,
>
> Steve



More information about the mapserver-users mailing list