Skip to content

Commit f1abcce

Browse files
author
Olivier Courtin
committed
Merge branch 'master' of https://github.com/mapserver/tinyows
2 parents f1bdd0a + a7b9d46 commit f1abcce

File tree

12 files changed

+120
-53
lines changed

12 files changed

+120
-53
lines changed

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ All code must meet the following rules :
1717

1818
Code dynamically linked with the following other librairies:
1919
- PostgreSQL 8.x and 9.x
20-
- libxml 2.8.x
20+
- libxml 2.9.x
2121
- flex

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.1.1

configure.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ XML2_VER=`$LIBXML2_CONFIG --version`
2929
AC_MSG_RESULT([checking for libxml2 version... $XML2_VER])
3030

3131
xml2_vers=`$LIBXML2_CONFIG --version | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
32-
if test "$xml2_vers" -lt 2008000 ; then
33-
AC_MSG_ERROR([You need at least libxml 2.8.0])
32+
if test "$xml2_vers" -lt 2009000 ; then
33+
AC_MSG_ERROR([You need at least libxml 2.9.0])
3434
fi
3535

3636

src/fe/fe_spatial_ops.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,11 +433,17 @@ static buffer *fe_bbox_layer(ows *o, buffer *typename, buffer *sql, buffer *prop
433433
if (transform) {
434434
buffer_add(sql, ',');
435435
buffer_add_int(sql, srid);
436+
buffer_add(sql, ')');
436437
}
437-
buffer_add(sql, ')');
438438

439439
buffer_add_str(sql, ",");
440+
if (transform) buffer_add_str(sql, "ST_Transform(");
440441
buffer_copy(sql, envelope);
442+
if (transform) {
443+
buffer_add(sql, ',');
444+
buffer_add_int(sql, srid);
445+
buffer_add(sql, ')');
446+
}
441447
buffer_add_str(sql, ") AND ");
442448
if (transform) buffer_add_str(sql, "ST_Transform(");
443449

@@ -448,11 +454,17 @@ static buffer *fe_bbox_layer(ows *o, buffer *typename, buffer *sql, buffer *prop
448454
if (transform) {
449455
buffer_add(sql, ',');
450456
buffer_add_int(sql, srid);
457+
buffer_add(sql, ')');
451458
}
452-
buffer_add(sql, ')');
453459

454460
buffer_add_str(sql, " && ");
461+
if (transform) buffer_add_str(sql, "ST_Transform(");
455462
buffer_copy(sql, envelope);
463+
if (transform) {
464+
buffer_add(sql, ',');
465+
buffer_add_int(sql, srid);
466+
buffer_add(sql, ')');
467+
}
456468
buffer_add_str(sql, ")");
457469

458470
return sql;

src/mapfile/mapfile.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,8 +1672,10 @@ static void end_layer()
16721672
* down here because we want the user's section 1 to have been scanned first.
16731673
* The user has a chance to override it with an option.
16741674
*/
1675+
#ifndef _WIN32
16751676
#include <unistd.h>
16761677
#endif
1678+
#endif
16771679

16781680
#ifndef YY_EXTRA_TYPE
16791681
#define YY_EXTRA_TYPE void *

src/ows/ows_geobbox.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ ows_geobbox *ows_geobbox_copy(ows_geobbox *g)
5858
ows_geobbox *c;
5959

6060
assert(g);
61-
c = malloc(sizeof(g));
62-
return memcpy(c, g, sizeof(g));
61+
c = malloc(sizeof(*g));
62+
return memcpy(c, g, sizeof(*g));
6363
}
6464

6565

src/ows_struct.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ enum wfs_format {
273273
WFS_GML311,
274274
WFS_GML321,
275275
WFS_GEOJSON,
276+
WFS_JSONP,
276277
WFS_TEXT_XML,
277278
WFS_APPLICATION_XML
278279
};
@@ -303,6 +304,7 @@ typedef struct Wfs_request {
303304
buffer * resulttype;
304305
buffer * sortby;
305306
list * sections;
307+
buffer * callback;
306308

307309
alist * insert_results;
308310
int delete_results;

src/struct/buffer.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ buffer *buffer_ftoa(double f)
141141

142142
res = buffer_init();
143143
while (res->size < 100) buffer_realloc(res);
144+
#ifndef _WIN32
144145
snprintf(res->buf, 99, "%f", f);
146+
#else
147+
_snprintf(res->buf, 99, "%f", f);
148+
#endif
145149
res->use = strlen(res->buf);
146150

147151
return res;
@@ -503,8 +507,6 @@ buffer *buffer_encode_xml_entities_str(const char * str)
503507

504508
for( /* empty */ ; *str ; str++) {
505509

506-
if ((int) *str < 32 && (*str != '\n' && *str != '\r' && *str != ' ')) break;
507-
508510
switch(*str) {
509511
case '&':
510512
buffer_add_str(buf, "&amp;");
@@ -538,9 +540,6 @@ buffer *buffer_encode_xml_entities_str(const char * str)
538540
/*
539541
* Modify string to replace encoded characters by their true value
540542
* for JSON output
541-
*
542-
* The replacements performed are:
543-
* " -> \"
544543
*/
545544
buffer *buffer_encode_json_str(const char * str)
546545
{
@@ -555,6 +554,22 @@ buffer *buffer_encode_json_str(const char * str)
555554
buffer_add_str(buf, "\\\"");
556555
break;
557556

557+
case '\n':
558+
buffer_add_str(buf, "\\\\n");
559+
break;
560+
561+
case '\r':
562+
buffer_add_str(buf, "\\\\r");
563+
break;
564+
565+
case '\t':
566+
buffer_add_str(buf, "\\\\t");
567+
break;
568+
569+
case '\\':
570+
buffer_add_str(buf, "\\\\");
571+
break;
572+
558573
default:
559574
buffer_add(buf, *str);
560575
}

src/struct/cgi_request.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
/*
3434
* Max query string length send via QUERY_STRING CGI
3535
*/
36-
#define CGI_QUERY_MAX 32768
36+
#define CGI_QUERY_MAX 1000000
3737

3838

3939
/*

src/wfs/wfs_get_feature.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)