Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#4063 closed defect (invalid)

trimlast does not work in templated JSON output

Reported by: davidfawcett Owned by: sdlime
Priority: normal Milestone: 6.0.2 release
Component: MapServer C Library Version: 6.0
Severity: normal Keywords: json template trimlast
Cc: sdlime

Description

In the template-driven output section of the MapServer docs, the geoJSON example demonstrates the use of 'trimlast' to remove the trailing delimiter in the output.

http://mapserver.org/output/template_output.html

When trying to use this functionality in MapServer 6.0.1, I can't get trimlast to work. Others have also had the same issue.

http://www.osgeo.org/pipermail/mapserver-users/2011-September/070257.html

Attached is a simple map file with a shapefile containing one feature (the state of MN). The URL used to make the query call is:

http://localhost/cgi-bin/mapserv?mode=nquery&map=/test/trimlast.map&mapxy=-94+45&layers=state

Attachments (3)

data.zip (781 bytes ) - added by davidfawcett 13 years ago.
Simple shapfile with one polygon feature
trimlast.map (455 bytes ) - added by davidfawcett 13 years ago.
The map file to replicate the bug
jsonTemplate.js (209 bytes ) - added by davidfawcett 13 years ago.
The template file to reproduce the bug

Download all attachments as: .zip

Change History (10)

by davidfawcett, 13 years ago

Attachment: data.zip added

Simple shapfile with one polygon feature

by davidfawcett, 13 years ago

Attachment: trimlast.map added

The map file to replicate the bug

by davidfawcett, 13 years ago

Attachment: jsonTemplate.js added

The template file to reproduce the bug

in reply to:  description comment:1 by davidfawcett, 13 years ago

I forgot to include an example of the output.

The CGI call:

http://localhost/cgi-bin/mapserv?mode=nquery&map=/test/trimlast.map&mapxy=-94+45&layers=state

Returns the result:

{ "state": [ { "perimeter": "2.22222e+006", "area": "3.33333e+007" }, ] }

comment:2 by sdlime, 12 years ago

Status: newassigned

comment:3 by sdlime, 12 years ago

Milestone: 6.0.2 release

comment:4 by sdlime, 12 years ago

David: What happens if you use double quotes instead of single quotes inside the feature tag. That is [feature trimlast=","].

Steve

in reply to:  4 comment:5 by davidfawcett, 12 years ago

Replying to sdlime:

David: What happens if you use double quotes instead of single quotes inside the feature tag. That is [feature trimlast=","].

Steve

Steve,

When I change the quotes around the 'character to be trimmed' to be double quotes, the trim functionality works.

Since MapServer is pretty agnostic on the type of quotes used (as long as they are properly nested), I hope that the fix will be make it work with both types of quotes.

David.

Here is the template text that works"

mapserver template [resultset layer=state] {

"state": [

[feature trimlast=","] {

"perimeter": "[PERIMETER]", "area": "[AREA]"

}, feature

]

} resultset

comment:6 by sdlime, 12 years ago

Resolution: invalid
Status: assignedclosed

The issue is in the tag attribute parsing not the template tags themselves. I'm going to close this as invalid and open a new, more specific ticket.

Steve

comment:7 by sdlime, 12 years ago

See #4122... Steve

Note: See TracTickets for help on using tickets.