Hey Lars,

that's great news ;) I did some minor modifications (full patch attached). Now 
if output format has the format option "JSONP" then default substitutions are 
applied to it and the "Content-Disposition" header is omitted (causes browsers 
to display the "Save as" dialog).

The map file should contain

OUTPUTFORMAT
      NAME 'jsonp'
      DRIVER 'OGR/GEOJSON'
      MIMETYPE 'text/javascript; charset=utf-8'
      FORMATOPTION 'LCO:COORDINATE_PRECISION=5'
      FORMATOPTION 'STORAGE=stream'
      FORMATOPTION 'FORM=simple'
      FORMATOPTION 'JSONP=%callback%'
END

WEB
      METADATA
              wfs_getfeature_formatlist "jsonp"
      END
        VALIDATION
              callback '.*'
              default_callback 'my_callback'
      END
END

A WFS GetFeature request should then set the query string to contain 
OUTPUTFORMAT=jsonp and CALLBACK=callme. The default value might be useful if 
you want to run some javascript directly:

  default_callback '(function(j){alert(JSON.stringify(j));})'

creates an immediately called anonymous function that displays the JSON. Of 
course, the real validation pattern should be something more sophisticated.

Just to summarize for all those who didn't follow the thread: The same result 
could be achieved using the template engine as Steve mentioned and all this is 
a workaround for a missing datasource creation option in OGR's JSON driver. 
This patch might provide more performance and might save memory on large result 
sets.

Kind regards!


> -----Ursprüngliche Nachricht-----
> Von: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users-
> boun...@lists.osgeo.org] Im Auftrag von Lars Fricke
> Gesendet: Mittwoch, 14. Januar 2015 17:17
> An: mapserver-users@lists.osgeo.org
> Betreff: Re: [mapserver-users] Setting up a JSONP service
> 
> Hello Andreas,
> 
> I confirm your solution is working perfectly well. I succeeded to
> integrate the JSONP output into my web application with no conflicts.
> Funny this depended so much on the version of code I happened to grab
> wrong. Sorry for producing extra work by that.
> 
> I'd love to see this go to the repositories, it's really helpful until
> someone will extend OGR.
> 
> So thanks again from Mecklenburg to Saxony :-)
> 
> Best
> 
> Lars
> 

Attachment: jsonp.diff
Description: jsonp.diff

_______________________________________________
mapserver-users mailing list
mapserver-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to