Opened 18 years ago

Closed 18 years ago

#1626 closed defect (later)

Error when combining Mapserver Expression with Regular Expression

Reported by: rosilva@… Owned by: sdlime
Priority: highest Milestone:
Component: MapServer C Library Version: 4.8
Severity: normal Keywords:
Cc:

Description

At first site combining the MapServer Expression with Regular Expression works
fine, but I noticed that when entering square brackets to get a range of
characters like in the examples below:

LAYER
    NAME "Predios"
    ...
    FILTER ('[Bairro]' =~ /[A-Z]/)

or

 ...
 CLASS
	NAME "Predios"
	EXPRESSION ('[Bairro]' =~ /[A-Z]/)
        ...


In both cases it presents the following error:

    msDrawMap(): Image handling error. Failed to draw layer named 'Predios'.
    msDBFGetItemIndex(): DBASE file error. Item 'A-Z' not found.
    msSHPOpenFile(): Unable to access file. (C:\MapData\..\Prediosx_point) 

PS: The layer was in ESRI Shapfile format when I posted this bug but I am using
MapInfo files through OGR and I got an error that seems prety much the same.

Change History (3)

comment:1 by sdlime, 18 years ago

I know about this problem but haven't figured out a good way to fix it yet. In 
your particular case there is a work around. Just use a straight regular 
expression:

FILTERITEM 'bairro'
FILTER /[A-Z]/

It will execute faster anyway. The real problem crops up when you want to 
combine a range regular expression with other logical operators in a single 
expression:

([area] > 10 AND '[name]' =~ /[A-Z]/)

Steve

comment:2 by rosilva@…, 18 years ago

Thank you Steve, 

I notice this issue because in the map application that I’m working in, I am
applying filters to different attributes for a specific layer dynamically, like
this: 

FILTER ((('[Bairro]' =~ /LAPA/) AND ([AreaTerreno] > 1500)) OR ('[Endereco]' =~
// ))

***The same filter but attributes translated in English below
FILTER ((('[Neighborhood]' =~ /LAPA/) AND ([Area] > 1500)) OR ('[Address]' =~ // ))


Making a substitution in my php code:

...
$that_layer->setFilter("(( '[Bairro]' =~ /".$_POST['valor']."/) AND
([AreaTerreno] >".$_POST['tam_terr']." ) )");
...

So when someone selects the Neighborhood = [A-Z] AND Area >= 1500 for the school
layer it would bring me all the schools with area greater than 1500 square meters. 

I could still use a sentence like the one below that is working fine (there
isn't schools without vogals in Brasil, at least not in my resultset) even when
combined with other logical operators in the same sentence.

FILTER ((('[Neighborhood]' =~ /A|E|I|O|U/) AND ([Area] > 1500)) OR ('[Address]'
=~ // ))

I tested both situations below:

EXPRESSION ('[Bairro]' =~ /[A-Z]/) #din't work

and

EXPRESSION ('[Bairro]' =~ /A|E|I|O|U/) #worked

I just thought that you weren’t aware of the problem, but thanks again.

Regards,

Rodrigo.

comment:3 by sdlime, 18 years ago

Resolution: later
Status: newclosed
I'd like to fix at some point, so marking as LATER for now.

Steve
Note: See TracTickets for help on using tickets.