layer->queryByFeatures strangeness

Tim Norris tibben at OCF.BERKELEY.EDU
Wed Aug 31 09:55:39 EDT 2005


Hi All

did anyone get a chance to look at this??  thanks - tim

>Hi all
>
>I have discovered a strange difference between mapServer 4.4.2 and mapServer
>4.6.0. - particularly with the $layer->queryByFeatures() method under
>PHP/Mapscript.
>
>Currently I have two machines configured as below
>
>Machine #1
>Fedora Core 3
>PHP 5.0.3 :: './configure' '--enable-shared' '--with-regex=system'
>'--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--with-zlib'
>'--with-gd=/usr/local' '--with-freetype-dir=/usr'
>'--enable-force-cgi-redirect' '--enable-dbase' '--with-pdflib'
>'--with-mysql' '--with-config-file-path=/usr/local/php/'
>'--prefix=/usr/local/php'
>MapServer version 4.4.2 OUTPUT=GIF 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=OGR INPUT=GDAL
>INPUT=SHAPEFILE
>
>Machine #2
>Fedora Core 4
>PHP 5.0.3 :: './configure' '--enable-shared' '--with-regex-system'
>'--with-png-dir=/usr' '--with-zlib' '--with-gd=/usr/local'
>'--with-freetype-dir=/usr' '--enable-force-cgi-redirect' '--enable-dbase'
>'--with-pdflib' '--with-mysql' '--with-config-file-path=/usr/local/php/'
>'--prefix=/usr/local/php'
>MapServer version 4.6.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=WBMP OUTPUT=SVG
>SUPPORTS=PROJ SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT
>SUPPORTS=WFS_SERVER SUPPORTS=THREADS INPUT=EPPL7 INPUT=OGR INPUT=GDAL
>INPUT=SHAPEFILE
>
>There is no relevant part of the map file - both layers that are relevant
>are dynamically loaded depending on the request.
>
>The relevant script is as follows (PHP):
>
>// this is a dynamically loaded point layer - MapInfo format
>$lyr_currentLink = ms_newLayerObj($ms_map);
>$lyr_currentLink->set('name',$my_link_name);
>$lyr_currentLink->set('type',MS_LAYER_POINT);
>$lyr_currentLink->set('status',MS_ON);
>$lyr_currentLink->set('connection',"myLocationData.TAB");
>$lyr_currentLink->set('connectiontype',MS_OGR);
>$lyr_currentLink->setProjection("proj=latlong");
>$obj_linkClass = ms_newClassObj($lyr_currentLink);
>$obj_linkClass->set('template','NULL');
>// there is more script defining colors etc. . . .
>
>// this is a dynamically loaded polygon district layer - MapInfo format
>$lyr_districts = ms_newLayerObj($ms_map);
>$lyr_districts->set('name',$my_districts);
>$lyr_districts->set('type',MS_LAYER_POLYGON);
>$lyr_districts->set('connection',"myDistricts.TAB");
>$lyr_districts->set('connectiontype',MS_OGR);
>$lyr_districts->setProjection("proj=latlong");
>$obj_districtsClass = ms_newClassObj($lyr_districts);
>$obj_districtsClass->set('template','NULL');
>// more script defining colors etc. . . .
>
>// get the correct district based on the request - querying against the
>field "DN" with the $my_district_number from the request.
>$b_qRes=$lyr_districts->queryByAttributes("DN",$my_district_number,"MS_SINGLE");
>$obj_district = $lyr_districts->getResult(0);
>// NOTE: I open the layer and get the feature for drawing later - perhaps
>this is part of the problem and there is a better way to draw the particular
>district? using the layer->drawQuery() method? would this make a difference?
>$lyr_districts->open();
>$ftr_district=$lyr_districts->getShape($obj_district->tileindex,$obj_district->shapeindex);
>// then I create a new layer and add the $ftr_district to the new layer with
>all of its colors etc. . . .
>
>// now for the problem query - specificially to count the point data within
>the district
>$lyr_currentLink->queryByFeatures($lyr_districts->index);
>$str_locationCount = $lyr_currentLink->getNumResults();
>
>now for the wierdness: on both machines the code executes without error, BUT
>on the 4.4.2 version I get the correct number and on the 4.6.0 version I get
>an incorrect count (it is way to high).
>
>As an aside - I have tried using the $layer->queryByShape($ftr_district)
>method and keep getting errors (either mapServer crashes entirely with no
>visible error message in 4.4.2 or, once again the wrong count in 4.6.0 -
>incidentally it is the SAME wrong count) - this includes the reprojection of
>the $ftr_district->project($inProj,$outProj) to make sure that there are no
>projection problems/conflicts.
>
>any help on this would be great - I would like to use the 4.6.0 version, but
>right now I cannot get it to return the correct result - perhaps a bug??? or
>perhaps I am doing something wrong???
>
>and another aside - which documentation set is current????
>http://ms.gis.umn.edu/ OR http://mapserver.gis.umn.edu/
>or is
>http://ms.gis.umn.edu/ for 4.6.0 and
>http://mapserver.gis.umn.edu/ for 4.2.?
>
>and finally in the mapscript documentation at http://ms.gis.umn.edu/ it
>shows using $layer->queryByFeatures as follows:
>
>queryByFeatures( mapObj map, int slayer )
>
>but when I include the mapObj in the parameters I get a "invalid _handle_
>property" error - even on the machine with 4.6.0. Is there some explanation
>for this? Could it be related to the previously noted bugs with queries on
>dynamically loaded layers? Should I be including the mapObj parameter? It
>seems to function (but with the wrong count as noted above) without the
>mapObj parameter.
>
>I will continue to play with this . . . perhaps make the districts layer
>part of the map file and see what happens on the 4.6.0 machine.
>
>thanks
>tim
>
>Tim Norris
>UC Industry-University Cooperative Research Program
>Berkeley CA



More information about the mapserver-users mailing list