[mapserver-users] mapscript php with agg rendering?

Jean-François Gigand jean-francois at gigand.fr
Tue Feb 15 09:54:21 PST 2011


Great!

Thanks for the ticket. I will also prefer to manage output formats
programmatically.
I will follow that.

Jeff


2011/2/15 Michael Schulz <mandschulz at googlemail.com>:
> Jean-Francois,
>
> you saved my day :-) That got it working...
>
> I definitely think there is something wrong when trying to create an
> outputformat with php/mapscript from scratch. I'll try to narrow this
> down a bit and maybe open the mentioned ticket again.
>
> Thanks, Michael
>
>
> 2011/2/15 Jean-François Gigand <jean-francois at gigand.fr>:
>> I had the same problem, with PHP MapScript.
>>
>> In my case, I needed to let MapServer handle the WMS request
>> (msMap->owsDispatch() or CGI with generated MapFile), so I would have
>> no control over the output format selection (which depends of the WMS
>> request).
>>
>> It seemed that MapScript does not give control over the list of output formats.
>>
>> Eventually, as a workaround, I define my output formats as a map
>> string and create the map object with ms_newMapObjFromString() rather
>> than ms_newMapObj().
>>
>> Here is my code :
>> --------------------
>>    $formats = array
>>      ('aggpng24' => array('driver' => 'AGG/PNG',
>>                           'imagemode' => 'RGB',
>>                           'mimetype' => 'image/png',
>>                           'extension' => 'png'),
>>       'aggjpeg' => array('driver' => 'AGG/JPEG',
>>                          'imagemode' => 'RGB',
>>                          'mimetype' => 'image/jpeg',
>>                          'extension' => 'jpg'),
>>       'gdtiff' => array('driver' => 'GDAL/GTiff',
>>                         'imagemode' => 'RGB',
>>                         'mimetype' => 'image/tiff',
>>                         'extension' => 'tif'),
>>       'gdgif' => array('driver' => 'GD/GIF',
>>                        'imagemode' => 'PC256',
>>                        'mimetype' => 'image/gif',
>>                        'extension' => 'gif'),
>>       );
>>    $mapStrContent = array('MAP');
>>    foreach ($formats as $name => $format) {
>>      $mapStrContent[] = 'OUTPUTFORMAT';
>>      $mapStrContent[] = 'NAME '.$name;
>>      foreach ($format as $prop => $val) {
>>        $mapStrContent[] = strtoupper($prop).' "'.$val.'"';
>>      }
>>      $mapStrContent[] = 'END';
>>    }
>>    $mapStrContent[] = 'END';
>>    $msMap = ms_newMapObjFromString(implode("\n", $mapStrContent));
>> --------------------
>>
>> To me, this is a bug, as I thought that anything definable in a map
>> file should be definable thought MapScript as well.
>> If there is a full MapScript solution for this need, I'm interested too.
>>
>>
>> Jeff Gigand
>>
>>
>> 2011/2/15 Gregor at HostGIS <gregor at hostgis.com>:
>>> Hey there. I had some issues with the imagetype settings using PHP
>>> MapScript, but we do use PNG24. For what it's worth, here's the outputformat
>>> section of our PHP:
>>>
>>> $map->imagecolor->setRGB(255,255,255);
>>> $map->outputformat->set('name','gif');
>>> $map->outputformat->set('mimetype','image/png; mode=24bit');
>>> $map->outputformat->set('driver','AGG/PNG');
>>> $map->outputformat->set('imagemode',MS_IMAGEMODE_RGBA);
>>> $map->outputformat->set('transparent',MS_OFF);
>>> $map->outputformat->set('extension','png');
>>> $map->outputformat->setOption('INTERLACE','OFF');
>>> //$map->outputformat->setOption('QUANTIZE_FORCE','ON');
>>> //$map->outputformat->setOption('QUANTIZE_COLORS',256);
>>>
>>> For reasons which now elude my memory (this was written some 3 years ago) we
>>> had to use 'gif' as the output format, then simply reconfigure what 'gif'
>>> means. This may have been a bug specific to our own version of MapServer
>>> back in the day, but if it helps, I'm glad.
>>>
>>> --
>>> HostGIS, Open Source solutions for the global GIS community
>>> Greg Allensworth - SysAdmin, Programmer, GIS Person, Security
>>>   Network+   Server+   A+   Security+   Linux+
>>>   PHP   PostgreSQL   MySQL   DHTML/JavaScript/AJAX
>>>
>>> "No one cares if you can back up — only if you can recover."
>>> _______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>>
>>
>
>
>
> --
> -----------------------------------------------------------
> Michael Schulz
>
> Christoph-Mang-Str. 5
> D-79100 Freiburg
>



More information about the MapServer-users mailing list