¿How to programatically change the raster file a layer is pointing to?

4 messages Options
Embed this post
Permalink
jsanchez

¿How to programatically change the raster file a layer is pointing to?

Reply Threaded More More options
Print post
Permalink


As I suspected, my kung-fu wasn't strong enough to solve the problem I described in my previous post.
Thank to Paul tips I've made some progress but I failed to get what I was looking for.
I've changed a little my initial approach and that's why I'm posting this in a new thread.

1) I'm using a little mapfile with only four layers, one of them (the base layer) is a raster which points to a 'image1.tif'.

2) I'd like to have the possibility to select the geotiff shown as base layer.

3) I think the way to do this in mapscript is to 'redirect' the parameter 'data' of the layer to a new raster file:

            $oMap = ms_newMapObj($szMapFile);
            $baselayer=$oMap->getLayer(0);
            $baselayer->set("data" "image2.tif");

But I have no idea about how to transfer the name of new image from my form at index.html to LoadMap.php.

4) From Paul code I understood that the right way to do this was introducing in index.html a couple of functions like these:

function ChangeRaster(newimage) {
    var params='mapfile=/var/www/data/mapfile.map&newdata='+newimage;
    var opts = {parameters: params, onComplete: reload.bind(null)};
    var s =  "layers/MapServer/php/ChangeRaster.php";
    Fusion.ajaxRequest(s, opts);
}

function reload(){
    var mapWidget=Fusion.getMapById('Map');
    maps=mapWidget.getAllMaps();
    map=maps[0];
    map.reloadMap();
}

ChangeRaster.php is just a copy of LoadMap.php in which I inserted the mapscript code mentioned above to change the data of the layer:

            $newimage=$_REQUEST['newdata'];
            $oMap = ms_newMapObj($szMapFile);
            $baselayer=$oMap->getLayer(0);
            $baselayer->set("data", $newimage);

As far as I understand, by selecting a new raster from a listbox, 'ChangeRaster()' is called, then 'ChangeRaster.php' is executed and when completed, 'reload()' is called to make a map reload showing the updated image.

Unfortunately, it didn't work and I have no more ideas to test.....
 Any clues would be appreciated.


J. Sanchez
Kenneth Skovhede, GEOGRAF A/S

Re: ¿How to programatically change the raster file a layer is pointing to?

Reply Threaded More More options
Print post
Permalink
Instead of fidling with dynamic layer setup, could you just create a
number of layers,
and then toggle visibility to show only the correct GeoTiff?

Regards, Kenneth Skovhede, GEOGRAF A/S



jsanchez skrev:

>
> As I suspected, my kung-fu wasn't strong enough to solve the problem I
> described in my previous post.
> Thank to Paul tips I've made some progress but I failed to get what I was
> looking for.
> I've changed a little my initial approach and that's why I'm posting this in
> a new thread.
>
> 1) I'm using a little mapfile with only four layers, one of them (the base
> layer) is a raster which points to a 'image1.tif'.
>
> 2) I'd like to have the possibility to select the geotiff shown as base
> layer.
>
> 3) I think the way to do this in mapscript is to 'redirect' the parameter
> 'data' of the layer to a new raster file:
>
>             $oMap = ms_newMapObj($szMapFile);
>             $baselayer=$oMap->getLayer(0);
>             $baselayer->set("data" "image2.tif");
>
> But I have no idea about how to transfer the name of new image from my form
> at index.html to LoadMap.php.
>
> 4) From Paul code I understood that the right way to do this was introducing
> in index.html a couple of functions like these:
>
> function ChangeRaster(newimage) {
>     var params='mapfile=/var/www/data/mapfile.map&newdata='+newimage;
>     var opts = {parameters: params, onComplete: reload.bind(null)};
>     var s =  "layers/MapServer/php/ChangeRaster.php";
>     Fusion.ajaxRequest(s, opts);
> }
>
> function reload(){
>     var mapWidget=Fusion.getMapById('Map');
>     maps=mapWidget.getAllMaps();
>     map=maps[0];
>     map.reloadMap();
> }
>
> ChangeRaster.php is just a copy of LoadMap.php in which I inserted the
> mapscript code mentioned above to change the data of the layer:
>
>             $newimage=$_REQUEST['newdata'];
>             $oMap = ms_newMapObj($szMapFile);
>             $baselayer=$oMap->getLayer(0);
>             $baselayer->set("data", $newimage);
>
> As far as I understand, by selecting a new raster from a listbox,
> 'ChangeRaster()' is called, then 'ChangeRaster.php' is executed and when
> completed, 'reload()' is called to make a map reload showing the updated
> image.
>
> Unfortunately, it didn't work and I have no more ideas to test.....
>  Any clues would be appreciated.
>
>
> J. Sanchez
>  
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
jsanchez

Re: ¿How to programatically change the raster file a layer is pointing to?

Reply Threaded More More options
Print post
Permalink

Thank for your reply Kenneth,

but do you think that approach would be reasonable when there are more than 10000 TIFFs to select (satellite images)?  I guess the mapfile would be unnecessary big taken into account that only one of this layers would be ON each time. I don't know how this could affect overall performance...


Regards,
J. Sanchez


Instead of fidling with dynamic layer setup, could you just create a
number of layers,
and then toggle visibility to show only the correct GeoTiff?

Regards, Kenneth Skovhede, GEOGRAF A/S




Kenneth Skovhede, GEOGRAF A/S

Re: ¿How to programatically change the raster file a layer is pointing to?

Reply Threaded More More options
Print post
Permalink
No, perhaps not if you have more than a few hundred layers.

Regards, Kenneth Skovhede, GEOGRAF A/S



jsanchez skrev:

> Thank for your reply Kenneth,
>
> but do you think that approach would be reasonable when there are more than
> 10000 TIFFs to select (satellite images)?  I guess the mapfile would be
> unnecessary big taken into account that only one of this layers would be ON
> each time. I don't know how this could affect overall performance...
>
>
> Regards,
> J. Sanchez
>
>
> Instead of fidling with dynamic layer setup, could you just create a
> number of layers,
> and then toggle visibility to show only the correct GeoTiff?
>
> Regards, Kenneth Skovhede, GEOGRAF A/S
>
>
>
>
>
>  
_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users