[mapguide-users] Shapefile Query don't return all results

Normand Savard nsavard at mapgears.com
Tue May 1 20:06:46 EDT 2007


Hi,
I'm doing a query on a shapefile that has the attributes definition 
below.  The query is "(MUNICIPALI LIKE '$szMunicipality') AND (NOM LIKE 
'$szStreet') AND ((ADR_DEB_G <= $szAddress AND ADR_FIN_G >=$szAddress) 
OR  (ADR_DEB_DR <= $szAddress AND ADR_FIN_DR >= $szAddress))".  The 
query results don't contain all the expected results.  I did a test with 
the following values:
$szMunicipality = "Mandeville"
$szStreet = "Bergeron"
$szAddress = "1"
and it didn't return any value.  But by opening the dbf file in 
OpenOffice I can see that this value is there.  I pasted the code I'm 
using to do this query.  Can someone point me out what's wrong with my 
query string or if I made an error in the code?

I also tested with the following query "(MUNICIPALI LIKE 
'$szMunicipality') AND (NOM LIKE '$szStreet') " and it returns only one 
result but it should return two results.

Thanks.
Norm


Shapefile attributes:
BNDG_ID: String (15.0)
CLASSE: String (3.0)
NOM: String (50.0)
TYPE: String (6.0)
DIRECTION: String (2.0)
ADR_DEB_G: Real (11.0)
ADR_FIN_G: Real (11.0)
ADR_DEB_DR: Real (11.0)
ADR_FIN_DR: Real (11.0)
MUNICIPALI: String (50.0)

-------------------------------------
Code:
// ----- Beginning of AJAX-specific code ----------
// Get the localisation of the address
//
$szOptions = "(MUNICIPALI LIKE '$szMunicipality') AND (NOM LIKE 
'$szStreet') AND
((ADR_DEB_G <= $szAddress AND ADR_FIN_G >=$szAddress) OR
 (ADR_DEB_DR <= $szAddress AND ADR_FIN_DR >= $szAddress))";
$queryOptions->SetFilter($szOptions);
$featureResId = new MgResourceIdentifier(
    "Library://Maskinonge/data/address.FeatureSource");
$featureReader = $featureService->SelectFeatures($featureResId,
"localisation_residents_BV",  $queryOptions);
// ----- End of AJAX-specific code ----------------
$layer = $map->GetLayers()->GetItem('address');
$selection = new MgSelection($map);
// Process each item in the MgFeatureReader, displaying
//the owner name and address
$agfReaderWriter = new MgAgfReaderWriter();
$wktReaderWriter = new MgWktReaderWriter();
while ($featureReader->ReadNext())
{
    $szMunicipality = $featureReader->GetString('MUNICIPALI');
    $szStreetName = $featureReader->GetString('NOM');
    $nAddressDeb = $featureReader->GetDouble('ADR_DEB_G');
    $szFeatId = $featureReader->GetInt32('FeatId');
    error_log('municipality='.$szMunicipality);
    error_log('street name ='.$szStreetName);
    error_log('address='.$nAddressDeb);
    error_log('FeatId='.$szFeatId);
}




More information about the mapguide-users mailing list