Dear all,

While using the query editor plugin, I've came across some troubles. As I
am not sure whereas the problems I've encountered are related to the source
code or to my local installation, I send you the errors (and corrections
I've made) for anybody to evaluate if the source code must be modified or
not.
I run pmapper 4.3.1 on windows 7 and XP with the ms4W package (MS4W 3.0.6
with Mapserver 6.0.3).
First of all, I found out that when trying to query a field whith text, the
query wouldn't retrieve any results. I went to see the pm_debug.log (in
\ms4w\apps\pmapper\pmapper-4.3.1\plugins\queryeditor\) and found out that
the query string which was passed to Mapserver was not correct.
Here is an example of what was on pm_debug.log:

[30-Sep-2013 19:32:34] P.MAPPER debug info
Parameters for REQUEST array
file: query.php->q_execAttributeQuery

 Array
(
    [PHPSESSID] => rdpo6s4e0ktp14a2uhr216lik7
    [operation] => query
    [layername] => Conduta
    [layerType] => shape
    [query] => [Material] ILIKE 'PVC'
    [selectMethode] => new
    [externalSearchDefinition] => 1
    [mode] => search
    [layerName] => Conduta
    [firstFld] => MATERIAU
    [qStr] => (( "[MATERIAU]" ~ /^PVC$/))
)

What should have been passed to Mapserver is this:

 Array
(
    [PHPSESSID] => vq055tjimjg95k7ur1902839g5
    [operation] => query
    [layername] => Conduta
    [layerType] => shape
    [query] => [Material] ILIKE 'pvc'
    [selectMethode] => new
    [externalSearchDefinition] => 1
    [mode] => search
    [layerName] => Conduta
    [firstFld] => MATERIAU
    [qStr] => (( "[MATERIAU]" ~ 'pvc'))
)

Therefore, I changed the following in
"\ms4w\apps\pmapper\pmapper-4.3.1\plugins\queryeditor\x_queryeditor.php":

$modifiedQueryTmp =
preg_replace("/([^\[]*)\[([^\]]*)\]\s*([^\s]*)\s*'([^']*[^\\\])'/", "$1
\"[$2]\" $3 /'$4'/", $modifiedQueryWithoutEOL); (around line 134 in my file)

to

$modifiedQueryTmp =
preg_replace("/([^\[]*)\[([^\]]*)\]\s*([^\s]*)\s*'([^']*[^\\\])'/", "$1
\"[$2]\" $3 '$4'", $modifiedQueryWithoutEOL);

so that the string that is passed to Mapserver is compliant with the
Mapserver expressions.


Another "error" I came across with was, again, related to the syntax and
the query string passed to Mapserver (it was not compliant with Mapserver
expressions) with the term "ILIKE".
Line 136 in x_queryeditor.php, I changed the following

$modifiedQueryTmp = str_replace(" ILIKE ", " =~ ", $modifiedQueryTmp);

to

$modifiedQueryTmp = str_replace(" ILIKE ", " ~", $modifiedQueryTmp);
This last one can also be changed to
$modifiedQueryTmp = str_replace(" ILIKE ", " =*", $modifiedQueryTmp);


Finally, I also had to modify the file
ms4w\apps\pmapper\pmapper-4.3.1\plugins\queryeditor\queryeditor.js also
because of errors related to the query string passed to Mapserver. Line
393, I changed:

} else if (attrOperator == 'different') {
queryPartToAdd += ' <> ' + attrVal;"

to

} else if (attrOperator == 'different') {
queryPartToAdd += ' != ' + attrVal;

so that the string passed to Mapserver complies with Mapserver expressions
ie, to get "attribute value is different from value", Mapserver must
read "[ATTRIBUTE]!=VALUE" instead of "[ATTRIBUTE]<>VALUE".


I also made an optional change in queryeditordlg.phtml as I find more
"user-friendly" to have the symbol "≠" instead of "!=" for the user to read
"is different from". Line 148 in queryeditordlg.phtml, I changed

"<option label="!=" value="different">!=</option>"

to

 "<option label="&ne;" value="different">&ne;</option>"

This last one is not critical but I think, for people who are not used to
programming languages, it would make it easier for a common user to
understand the "≠" instead of "!="

Anybody knows if the changes I've made are related to my local installation
or if it's a code-related issue?Some people I know who are using pmapper
with ms4w have also encountered the same problems and solved them with the
suggestions I make in this post.


Best regards,
Sylvain Arabeyre.
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
pmapper-users mailing list
pmapper-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pmapper-users

Reply via email to