Opened 13 years ago

Last modified 13 years ago

#3969 new defect

KML fails to render classes of vector layer

Reported by: davide85 Owned by: assefa
Priority: normal Milestone: 6.0.1 release
Component: Output-KML Version: 6.0
Severity: normal Keywords:
Cc: chodgson, sdlime

Description

When we try to render a vector layer defined by several classes inside the mapfile, the KML ouput doesn't show the different styles. It seems like all the expression classes are evaluated as incorrect by the mapserver parser. Indeed, if we try to bypass the "yyparse" status value inside maputil.c, the KML output is instead set up correctly. To bypass this problem we set up yyparse to 0, in this way the output is correct and all classes with their styles are correctly rendered. Below an example of an expression that is not parsed while it is correct:

class
  name ' < 20'
  expression (([sll] < 20))
  style
    color 50 243 50
  end
end

Attachments (4)

test.map (751 bytes ) - added by chodgson 13 years ago.
test map file
multipoly_test.dbf (76 bytes ) - added by chodgson 13 years ago.
multipoly_test.shp (1.3 KB ) - added by chodgson 13 years ago.
multipoly_test.shx (140 bytes ) - added by chodgson 13 years ago.

Download all attachments as: .zip

Change History (12)

comment:1 by chodgson, 13 years ago

I have seen the same problem. Our expression is a bit more complicated:

EXPRESSION (('[NATION_ENGLISH_NAME]' eq 'Canada') and ('[STATUS]' ne 'Canadian Waters') and ('[NAME]' ne 'British Columbia'))

The same layer renders fine as png, but fails to parse the expression when output using kml - here's the log output:

[Mon Sep 26 11:23:30 2011].807000 msDrawMap(): rendering using outputformat named png (AGG/PNG). [Mon Sep 26 11:23:30 2011].823000 msDrawMap(): WMS/WFS set-up and query, 0.016s [Mon Sep 26 11:23:30 2011].995000 msDrawMap(): Layer 0 (DBM_7H_MIL_POLITICAL), 0.172s [Mon Sep 26 11:23:30 2011].995000 msDrawMap(): Drawing Label Cache, 0.000s [Mon Sep 26 11:23:30 2011].995000 msDrawMap() total time: 0.188s [Mon Sep 26 11:23:31 2011].182000 msSaveImage(stdout) total time: 0.187s [Mon Sep 26 11:23:31 2011].182000 mapserv request processing time (msLoadMap not incl.): 0.375s [Mon Sep 26 11:23:31 2011].182000 msFreeMap(): freeing map at 03FBEBC8. [Mon Sep 26 11:23:38 2011].698000 CGI Request 36 on process 6440 [Mon Sep 26 11:23:38 2011].698000 msDrawMap(): rendering using outputformat named kml (KML). [Mon Sep 26 11:23:38 2011].698000 msDrawMap(): WMS/WFS set-up and query, 0.000s [Mon Sep 26 11:23:38 2011].729000 yyparse(): Expression parser error. syntax error [Mon Sep 26 11:23:38 2011].729000 msEvalExpression: Expression parser error. Failed to parse expression: ('[NATION_ENGLISH_NAME]' eq 'Canada') and ('[STATUS]' ne 'Canadian Waters') and ('[NAME]' ne 'British Columbia') [Mon Sep 26 11:23:38 2011].729000 yyparse(): Expression parser error. syntax error

comment:2 by chodgson, 13 years ago

Sorry, here's that log output with better formatting:

[Mon Sep 26 11:23:30 2011].807000 msDrawMap(): rendering using outputformat named png (AGG/PNG).
[Mon Sep 26 11:23:30 2011].823000 msDrawMap(): WMS/WFS set-up and query, 0.016s
[Mon Sep 26 11:23:30 2011].995000 msDrawMap(): Layer 0 (DBM_7H_MIL_POLITICAL), 0.172s
[Mon Sep 26 11:23:30 2011].995000 msDrawMap(): Drawing Label Cache, 0.000s
[Mon Sep 26 11:23:30 2011].995000 msDrawMap() total time: 0.188s
[Mon Sep 26 11:23:31 2011].182000 msSaveImage(stdout) total time: 0.187s
[Mon Sep 26 11:23:31 2011].182000 mapserv request processing time (msLoadMap not incl.): 0.375s
[Mon Sep 26 11:23:31 2011].182000 msFreeMap(): freeing map at 03FBEBC8.
[Mon Sep 26 11:23:38 2011].698000 CGI Request 36 on process 6440
[Mon Sep 26 11:23:38 2011].698000 msDrawMap(): rendering using outputformat named kml (KML).
[Mon Sep 26 11:23:38 2011].698000 msDrawMap(): WMS/WFS set-up and query, 0.000s
[Mon Sep 26 11:23:38 2011].729000 yyparse(): Expression parser error. syntax error
[Mon Sep 26 11:23:38 2011].729000 msEvalExpression: Expression parser error. Failed to parse expression: ('[NATION_ENGLISH_NAME]' eq 'Canada') and ('[STATUS]' ne 'Canadian Waters') and ('[NAME]' ne 'British Columbia')
[Mon Sep 26 11:23:38 2011].729000 yyparse(): Expression parser error. syntax error
}}

comment:3 by chodgson, 13 years ago

Cc: chodgson added

comment:4 by chodgson, 13 years ago

Cc: sdlime added

msTokenizeExpression is being called twice for kml output (and possibly others?), resulting in the tokens being duplicated in the expressionObj, and thus the expression tree is not valid, and fails to parse. eg. ('[NAME]' eq 'a') ends up as this list of tokens [NAME], eq, "a", [NAME], eq, "a" - it's not duplicated like this for png output.

I've tracked it down to msLayerWhichItems() being called twice, the second time by msDrawVectorLayer(). I haven't been able to figure out where it is getting called the first time.

Seems like we'd be better off not calling msLayerWhichItems() two times... but an alternative fix might be to just check if the expression is already tokenized before doing it again (or at least replacing the existing tokenization instead of tacking it on the end of the existing one).

I'm adding Steve to the CC list as this seems like it related to his revamped expression parsing.

comment:5 by chodgson, 13 years ago

Just a little more details about my use case - ubuntu linux, mapserver compiled from svn, single shapefile layer, WMS getmap request:

http://localhost/cgi-bin/mapserv-svn
?map=/mapfiles/test/test.map
&request=getMap
&service=wms
&width=500
&height=500
&version=1.3.0
&layers=holypoly
&crs=epsg:4326
&bbox=54,-138,63,-112
&format=kml

comment:6 by sdlime, 13 years ago

Does anyone have a trivial test case I could use to debug this? msLayerWhichItems() is not called that many places (layer drawing or layer query code) so it should be that hard to track down.

Steve

comment:7 by chodgson, 13 years ago

All it takes is a single shapefile layer with a class with an expression in it (not a classitem) in a WMS-enabled mapfile, and do a getmap request with format=kml. I'm away from my regular computer this week, or would attach the mapfile that I was testing with...

by chodgson, 13 years ago

Attachment: test.map added

test map file

by chodgson, 13 years ago

Attachment: multipoly_test.dbf added

by chodgson, 13 years ago

Attachment: multipoly_test.shp added

by chodgson, 13 years ago

Attachment: multipoly_test.shx added

comment:8 by chodgson, 13 years ago

Ok I was able to get a hold of my test mapfile and shapefile. I cut out some extraneous garbage from the mapfile that shouldn't have been related, but I haven't tested this exact file. You should be able to use a wms request like the one above to replicate the problem, and then change to format=png and get a valid image back.

Let me know if you can't replicate the problem with this mapfile and shapefile.

Note: See TracTickets for help on using tickets.