[pmapper-users] Query editor source code issues?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[pmapper-users] Query editor source code issues?

Sylvain Arabeyre
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/pmapper-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pmapper-users] Query editor source code issues?

Thomas
Hi,

Thanks for your contribution. Indeed I never use SHP files, so your
corrections are welcome...

Replies below...

Le 01/10/2013 14:47, Sylvain Arabeyre a écrit :
> 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).

I think you should try MapServer 6.2.1 from here:
http://www.maptools.org/dl/ms4w/ms4w_3.1.0-beta1.zip

> 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.

OK, will be committed soon...


>
> 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);

OK, will be committed soon...


>
> 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've kept the previous code with the "!=" and added in the PHP something
like that for SHP files :

$modifiedQueryTmp = str_replace(" != ", " <> ", $modifiedQueryTmp);




> 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 "!="

Of course, you're right!



>
> 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.

Thanks again.


> ------------------------------------------------------------------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/pmapper-users


------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/pmapper-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pmapper-users] Query editor source code issues?

Thomas
Hi,

I've just committed small corrections in the query editor concerning
text fields and operators like "contains", stard with", ... for SHP files.

Jose, your messages are not visible on pmapper the mailing list...

Thomas

Le 01/10/2013 15:48, Thomas RAFFIN a écrit :

> Hi,
>
> Thanks for your contribution. Indeed I never use SHP files, so your
> corrections are welcome...
>
> Replies below...
>
> Le 01/10/2013 14:47, Sylvain Arabeyre a écrit :
>> 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).
> I think you should try MapServer 6.2.1 from here:
> http://www.maptools.org/dl/ms4w/ms4w_3.1.0-beta1.zip
>
>> 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.
> OK, will be committed soon...
>
>
>> 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);
> OK, will be committed soon...
>
>
>> 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've kept the previous code with the "!=" and added in the PHP something
> like that for SHP files :
>
> $modifiedQueryTmp = str_replace(" != ", " <> ", $modifiedQueryTmp);
>
>
>
>
>> 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 "!="
> Of course, you're right!
>
>
>
>> 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.
> Thanks again.
>
>
>> ------------------------------------------------------------------------------
>> 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
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/pmapper-users
>
> ------------------------------------------------------------------------------
> 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
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/pmapper-users


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
pmapper-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/pmapper-users
Loading...