@@ -511,7 +511,7 @@ static buffer *wfs_retrieve_sql_request_select(ows * o, wfs_request * wr, buffer
511511 buffer_add_str (select , ") AS \"" );
512512 buffer_copy (select , an -> key );
513513 buffer_add_str (select , "\" " );
514- } else if (wr -> format == WFS_GEOJSON ) {
514+ } else if (wr -> format == WFS_GEOJSON || wr -> format == WFS_JSONP ) {
515515 buffer_add_str (select , "ST_AsGeoJSON(" );
516516
517517 /* Geometry Reprojection on the fly step if asked */
@@ -786,7 +786,17 @@ static void wfs_geojson_display_results(ows * o, wfs_request * wr, mlist * reque
786786 prop = buffer_init ();
787787 id_name = buffer_init ();
788788
789- fprintf (o -> output , "Content-Type: application/json\n\n" );
789+ if (wr -> format == WFS_JSONP )
790+ {
791+ assert (wr -> callback );
792+
793+ fprintf (o -> output , "Content-Type: application/javascript\n\n" );
794+ fprintf (o -> output , wr -> callback -> buf );
795+ fprintf (o -> output , "(" );
796+
797+ } else fprintf (o -> output , "Content-Type: application/json\n\n" );
798+
799+
790800 fprintf (o -> output , "{\"type\": \"FeatureCollection\", \"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"" );
791801 if (ows_version_get (o -> request -> version ) == 100 )
792802 fprintf (o -> output , "EPSG:%i" , wr -> srs -> srid );
@@ -872,6 +882,7 @@ static void wfs_geojson_display_results(ows * o, wfs_request * wr, mlist * reque
872882 }
873883
874884 fprintf (o -> output , "]}" );
885+ if (wr -> format == WFS_JSONP ) fprintf (o -> output , ");" );
875886
876887 buffer_free (geom );
877888 buffer_free (prop );
@@ -897,7 +908,7 @@ void wfs_get_feature(ows * o, wfs_request * wr)
897908 else
898909 wfs_gml_display_results (o , wr , request_list );
899910
900- } else if (wr -> format == WFS_GEOJSON )
911+ } else if (wr -> format == WFS_GEOJSON || wr -> format == WFS_JSONP )
901912 wfs_geojson_display_results (o , wr , request_list );
902913
903914 /* Add here other functions to display GetFeature response in other formats */
0 commit comments