[mapserver-users] php mapscript
Worth Lutz
wal3 at mindspring.com
Mon Mar 29 14:30:38 PDT 2010
I'm just a MapServer user. I've copied this reply to the list so your
comments will be seen.
Worth
_____
From: Cristiano Sumariva [mailto:sumariva at gmail.com]
Sent: Monday, March 29, 2010 7:28 AM
To: Worth Lutz
Subject: Re: [mapserver-users] php mapscript
To me would be very good that mapserver documentation includes a since
version.subversion.release flag at documentation function names like php
does on their site.
And for those changes and breaks on code the user contribution on end of
function descriptions would be welcome too.
Example from php
pg_connect
(PHP 4, PHP 5)
resource pg_connect ( string $connection_string )
http://br2.php.net/manual/en/function.pg-connect.php
2010/3/29 Worth Lutz <wal3 at mindspring.com>
I don't think that the documentation has caught up with the changes in the
program. People using older versions of MapServer have to use the older
method and the new method is used for 5.6+ version. It was described
briefly in the migration document but took me some experimentation to get
results.
Worth
-----Original Message-----
From: Sven Schroeter [mailto:schroeter at netgis.de]
Sent: Monday, March 29, 2010 4:18 AM
To: Worth Lutz
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] php mapscript
Hi,
thank you very much, shapeObj resultsGetShape is the solution.
resultsGetShape works fine.
But I don't understand why shapeObj getFeature is in the documentation?
Sven
----- Original Message -----
From: Worth Lutz
To: 'Sven Schroeter' ;
Sent: Friday, March 26, 2010 11:09 PM
Subject: RE: [mapserver-users] php mapscript
This problem is due to the new single pass query in 5.6.
I have marked your code with what I am using.
Try these mods marked with "*************************":
@$datQuery = $query_layer->queryByRect($qRect);
//number of objects
$resnum = $query_layer->getNumResults(); echo "number of objects:
".$resnum."<br>";
//if query success
if ($datQuery == MS_SUCCESS) {
// $query_layer->open(); // <<REMOVE OPEN AND CLOSE ***********
//first row
$result = $query_layer->getResult(0);
//$shpobj =
$query_layer->getShape($result->tileindex,$result->shapeindex);
// resultsGetShape is now the way to get the shape object
***************************
// note: change of order in arguments
************************************************
$shpobj = $query_layer->resultsGetShape($result->shapeindex,
$result->tileindex);
//read attribute
$attr = $shpobj->values;
//write headline
echo '<table cellspacing="0" cellpadding="2" border="1" ><tr>';
foreach($attr as $name=>$wert) {
echo '<td bgcolor="#CCCCCC">'.$name.'</td>';
}
echo '</tr>';
//write datasets
for ($j=0; $j<$query_layer->getNumResults(); $j++) {
$result = $query_layer->getResult($j);
//$shpobj =
$query_layer->getShape($result->tileindex,$result->shapeindex);
// see note above
**********************************************************************
$shpobj = $query_layer->resultsGetShape($result->shapeindex,
$result->tileindex);
$ri = $result->tileindex;
$si = $result->shapeindex;
$attr = $shpobj->values;
echo '<tr id="row'.$si.'" >';
foreach($attr as $name=>$wert) {
echo '<td>'.$wert.'</td>';
}
echo '</tr>';
$shpobj->free();
}
// $query_layer->close(); // <<REMOVE OPEN AND CLOSE ***********
echo '</table>';
} // end success
...
-----Original Message-----
From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Sven Schroeter
Sent: Thursday, March 25, 2010 10:52 AM
To: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] php mapscript
Alan,
thanks for the reply, I tried it with getFeature(), but there comes the same
error.
nextShape() works only after msWhichShapes and here I need a rectobj.
But I want to use the script for queryByShape and queryByAttributes too.
Why there comes no array in $attr = $shpobj->values; ?
Any idea?
Sven
----- Original Message -----
From: "Alan Boudreault" <aboudreault at mapgears.com>
To: <mapserver-users at lists.osgeo.org>
Cc: "Sven Schroeter" <schroeter at netgis.de>
Sent: Thursday, March 25, 2010 2:32 PM
Subject: Re: [mapserver-users] php mapscript
> Sven,
>
> getShape() is deprecated. Use rather getFeature(). I suggest to also take
> a
> look at the nextShape() function:
> http://mapserver.org/mapscript/php/index.html#layerobj-class
>
> Alan
>
> On March 25, 2010 09:18:50 am Sven Schroeter wrote:
>> Hi,
>> I have an old php mapscript code that works fine with mapserver 5.02 or
>> 5.2, but not with 5.6.1.
>> The code runs an attribute tabe from a postgis layer and different querys
>> i.e. queryByRect:
>>
>> ...
>> @$datQuery = $query_layer->queryByRect($qRect);
>>
>> //number of objects
>> $resnum = $query_layer->getNumResults();
>> echo "number of objects: ".$resnum."<br>";
>>
>> //if query success
>> if ($datQuery == MS_SUCCESS) {
>> $query_layer->open();
>>
>> //first row
>> $result = $query_layer->getResult(0);
>> $shpobj =
>> $query_layer->getShape($result->tileindex,$result->shapeindex);
>> //read attribute
>> $attr = $shpobj->values;
>>
>> //write headline
>> echo '<table cellspacing="0" cellpadding="2" border="1" ><tr>';
>> foreach($attr as $name=>$wert) {
>> echo '<td bgcolor="#CCCCCC">'.$name.'</td>';
>> }
>> echo '</tr>';
>>
>> //write datasets
>> for ($j=0; $j<$query_layer->getNumResults(); $j++) {
>> $result = $query_layer->getResult($j);
>> $shpobj =
>> $query_layer->getShape($result->tileindex,$result->shapeindex); $ri =
>> $result->tileindex;
>> $si = $result->shapeindex;
>> $attr = $shpobj->values;
>> echo '<tr id="row'.$si.'" >';
>> foreach($attr as $name=>$wert) {
>> echo '<td>'.$wert.'</td>';
>> }
>> echo '</tr>';
>> $shpobj->free();
>> }
>> $query_layer->close();
>> echo '</table>';
>>
>> } // end success
>> ...
>>
>> In ms 5.6.1 the query is also successful (I get the correct number of
>> objects) but there comes following warning:
>> Invalid argument supplied for foreach() in ... Fatal error: Call to a
>> member function free() on a non-object in ...
>> No object? Why? What has changed?
>> Thanks
>> Sven
>>
>>
>>
>> _______________________________________________
>> mapserver-users mailing list
>> mapserver-users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>
> --
> Alan Boudreault
> Mapgears
> http://www.mapgears.com
>
>
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100329/b9702d0e/attachment.htm>
More information about the MapServer-users
mailing list