[Mapserver-users] Which is better: PHPMapScript query engine or PHP dBase functions?

Norbert Thieme norbert.thieme at ilmenau.baw.de
Tue May 4 04:20:16 EDT 2004


Ryan, Adam schrieb:
> Eduardo,
> 
> I might be off track but...
> 
> I thought about this myself.  In order to display the result shapes you need
> to have a query result either from doing the query in mapscript or loading a
> saved query file.  The former defeats the point of querying the dBase since
> you're duplicating your steps, and the later requires you to manually build
> a query file but you can't do that unless you can get at the dBase record -
> shapefile index relationship which I don't know how to do.
> 
> Again, I may be off track, but querying the dBase file may not be feasible.
> 
> Adam
> 
> -----Original Message-----
> From: Eduardo Patto Kanegae [mailto:eduardo at consultoria.eti.br] 
> Sent: Monday, May 03, 2004 11:06 AM
> To: mapserver-users at lists.gis.umn.edu
> Subject: [Mapserver-users] Which is better: PHPMapScript query engine or PHP
> dBase functions?
> 
> 
> I have a mapserver+php+mapscript that will query on a shapefile database on
> a single layer, through its atributes.
> 
> The system will give as result a set of items on a result list as a first
> step. 
> Then as a second step a map displaying these results should be given.
> 
> my doubt is: to create this result list which will be best strategy: 
> - use PHPMapScript to query against the mapfile ?
> or
> - simply use PHP dBase functions to query against dBase files of the
> mapfile?
> 
> which one is the best/fastest alternative?
> 
> best regards.
> 
> Eduardo Patto Kanegae
> http://www.consultoria.eti.br
> UIN: 303747254
> 
> I Encontro Nacional de Usuários MapServer -
> http://mapserver.cttmar.univali.br/encontro2004
> Projeto MapServer Brasil - http://mapserver.cttmar.univali.br
> 
> ***Fim da Mensagem / End of Message ***
> 
> 
> 
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 
> _______________________________________________
> Mapserver-users mailing list
> Mapserver-users at lists.gis.umn.edu
> http://lists.gis.umn.edu/mailman/listinfo/mapserver-users
> 
> 


Hi,

I think you can use both. If you use querybyattributes then you use the 
ability of the mapserver to search only in your current extent. But you 
have the problem that the qstring must be exactly the same (case 
sensitive). If anyone knows a way (without much own code) to search with 
the mapserver after only parts of words and case ignoring it would be 
great if he shares it. Because that would work with all kinds of types 
of data not only for shapes.

For the other case I use the following code to search the way described 
above - I cut it a bit:

//this first part is a seperate form but it should work also in one

$recs = dbase_numrecords($dbi);//opened dbf

$q_index_array = array();//save the indexes from the .dbf in this array

for ($i = 1; $i < $recs; $i++)
{
   $s_field = dbase_get_record_with_names($dbi, ($i + 1));

   if (!(strpos(strtolower($s_field[$qitem]), strtolower($qstring))) === 
false))
   {
     $q_index_array[] = $i;
   }
}

//second part - map

for ($i = 0; $i < count($q_index_array); $i++)
{
   if (@$map->queryByIndex($qlayer->index, 0, $q_index_array[$i], 
MS_FALSE) == MS_SUCCESS)
   {
     $q_img  = $map->drawquery();
     $q_path = $q_img->savewebimage();
     echo "<img src=".$q_path.">";
   }
}

Regards,
Norbert



More information about the mapserver-users mailing list