Changeset 195
- Timestamp:
- 01/21/10 22:19:43 (8 months ago)
- Files:
-
- 11 modified
-
configure.in (modified) (1 diff)
-
demo/install.sh.in (modified) (1 diff)
-
src/fe/fe_filter.c (modified) (3 diffs)
-
src/fe/fe_spatial_ops.c (modified) (7 diffs)
-
src/ows/ows.h (modified) (1 diff)
-
src/ows/ows_config.c (modified) (4 diffs)
-
src/ows/ows_psql.c (modified) (1 diff)
-
src/ows/ows_request.c (modified) (2 diffs)
-
src/ows_api.h (modified) (2 diffs)
-
src/wfs/wfs_transaction.c (modified) (5 diffs)
-
test/install.sh.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
configure.in
r100 r195 86 86 87 87 echo "------------------------" 88 echo "This TinyOWS version will need at least PostGIS 1. 4.x"88 echo "This TinyOWS version will need at least PostGIS 1.5.x" 89 89 echo "------------------------" -
demo/install.sh.in
r179 r195 5 5 6 6 PGBIN=@POSTGIS_BIN@ 7 PGSHARE=@POSTGIS_SHARE@/contrib/ 7 PGSHARE=@POSTGIS_SHARE@/contrib/postgis-1.5 8 8 PGUSER=postgres 9 9 DB=tinyows_demo -
src/fe/fe_filter.c
r191 r195 40 40 assert(fe != NULL); 41 41 42 fe->sql = NULL;42 fe->sql = buffer_init(); 43 43 fe->error_code = FE_NO_ERROR; 44 44 … … 56 56 if (fe->sql != NULL) 57 57 buffer_free(fe->sql); 58 58 59 59 free(fe); 60 60 fe = NULL; … … 443 443 xmlInitParser(); 444 444 LIBXML_TEST_VERSION 445 fe->sql = buffer_init();446 445 447 446 xmldoc = xmlParseMemory(xmlchar->buf, xmlchar->use); -
src/fe/fe_spatial_ops.c
r177 r195 57 57 58 58 /* 59 * Transform syntax coordinates from GML 2.1.2 (x1,y1 x2,y2) into Postgis (x1 y1,x2 y2) 60 */ 61 static buffer *fe_transform_coord_gml_to_psql(buffer * coord) 62 { 63 size_t i; 64 assert(coord != NULL); 65 66 /*check if the first separator is a comma else do nothing */ 67 if (check_regexp(coord->buf, "^[0-9.-]+,")) { 68 for (i = 0; i < coord->use; i++) { 69 if (coord->buf[i] == ' ') coord->buf[i] = ','; 70 else if (coord->buf[i] == ',') coord->buf[i] = ' '; 71 } 72 } 73 74 return coord; 75 } 76 77 78 /* 59 79 * Write a polygon geometry according to postgresql syntax from GML bbox 60 80 */ … … 161 181 162 182 /* 163 * Transform syntax coordinates from GML 2.1.2 (x1,y1 x2,y2) into Postgis (x1 y1,x2 y2) 164 */ 165 buffer *fe_transform_coord_gml_to_psql(buffer * coord) 166 { 167 size_t i; 168 169 assert(coord != NULL); 170 171 /*check if the first separator is a comma else do nothing */ 172 if (check_regexp(coord->buf, "^[0-9.-]+,")) { 173 for (i = 0; i < coord->use; i++) { 174 if (coord->buf[i] == ' ') 175 coord->buf[i] = ','; 176 else if (coord->buf[i] == ',') 177 coord->buf[i] = ' '; 178 } 179 } 180 181 return coord; 182 } 183 184 185 /* 186 * Transform syntax coordinates from GML 3.1.1 (x1 y1 x2 y2) into Postgis' (x1 y1,x2 y2) 187 */ 188 buffer *fe_transform_coord_gml3_to_psql(buffer * coord) 189 { 190 size_t i; 191 int nb_spaces; 192 193 assert(coord != NULL); 194 195 nb_spaces = 0; 196 197 for (i = 0; i < coord->use; i++) { 198 if (coord->buf[i] == ' ') { 199 nb_spaces++; 200 201 /* transform the second space separator into comma */ 202 if (nb_spaces == 2) { 203 coord->buf[i] = ','; 204 nb_spaces = 0; 205 } 206 } 207 } 208 209 return coord; 210 } 211 212 213 /* 214 * Transform a geometry expressed in GML into Postgis geometry syntax 215 */ 216 buffer *fe_transform_geometry_gml_to_psql(ows * o, buffer * typename, 217 filter_encoding * fe, xmlNodePtr n) 218 { 219 xmlChar *content; 220 xmlNodePtr node, node_coord; 221 buffer *tmp, *geom; 222 bool first_ring = true; 223 int bracket; 183 * Return the SQL request matching the spatial operator 184 */ 185 static buffer *fe_spatial_functions(ows * o, buffer * typename, 186 filter_encoding * fe, xmlNodePtr n) 187 { 188 bool transform = false; 189 buffer *sql; 224 190 225 191 assert(o != NULL); … … 228 194 assert(n != NULL); 229 195 230 content = NULL;231 232 /* jump to the next element if there are spaces */233 while (n->type != XML_ELEMENT_NODE) n = n->next;234 235 buffer_add_str(fe->sql, "setsrid('");236 237 geom = buffer_init();238 if (strcmp((char *) n->name, "MultiSurface") == 0)239 buffer_add_str(geom, "MultiPolygon");240 else241 buffer_add_str(geom, (char *) n->name);242 243 /* print the geometry type */244 if (buffer_cmp(geom, "MultiPolygon") || buffer_cmp(geom, "MultiSurface")) {245 buffer_add_str(geom, "(((");246 bracket = 3;247 } else if (buffer_cmp(geom, "MultiLineString")248 || buffer_cmp(geom, "Polygon")) {249 buffer_add_str(geom, "((");250 bracket =2;251 } else if (buffer_cmp(geom, "MultiPoint")252 || buffer_cmp(geom, "Point")253 || buffer_cmp(geom, "LineString")) {254 buffer_add_str(geom, "(");255 bracket = 1;256 } else {257 fe->error_code = FE_ERROR_GEOMETRY;258 buffer_free(geom);259 return fe->sql;260 }261 n = n->children;262 263 /* jump to the next element if there are spaces */264 while (n->type != XML_ELEMENT_NODE) n = n->next;265 266 /* print the coordinates */267 for (node = n; node != NULL; node = node->next) {268 269 /*270 * Ignore GML properties if any271 */272 if ((strcmp((char *) node->name, "description") == 0273 || strcmp((char *) node->name, "name") == 0274 || strcmp((char *) node->name, "metaDataProperty") == 0)275 && strcmp((char *) node->ns->href, "http://www.opengis.net/gml") == 0)276 node = node->next;277 278 if (node->type == XML_ELEMENT_NODE) {279 node_coord = node;280 281 282 /* go to node <coordinates> */283 while (strcmp((char *) node_coord->name, "coordinates") != 0284 && strcmp((char *) node_coord->name, "posList") != 0285 && strcmp((char *) node_coord->name, "pos") != 0) {286 287 while (node_coord != NULL && node_coord->type != XML_ELEMENT_NODE) {288 node_coord = node_coord->next;289 }290 291 if (node_coord == NULL) {292 fe->error_code = FE_ERROR_GEOMETRY;293 buffer_free(geom);294 return fe->sql;295 }296 297 if (node_coord != NULL && node_coord->type == XML_ELEMENT_NODE298 && strcmp((char *) node_coord->name, "LinearRing") == 0) {299 buffer_pop(geom, 1); /* remove last coord comma or ( */300 if (!first_ring) buffer_add_str(geom, "),");301 buffer_add_str(geom, "(");302 first_ring = false;303 }304 305 /* jump to the next element if there are spaces */306 if (strcmp((char *) node_coord->name, "coordinates") != 0307 && strcmp((char *) node_coord->name, "posList") != 0308 && strcmp((char *) node_coord->name, "pos") != 0)309 node_coord = node_coord->children;310 }311 312 tmp = buffer_init();313 314 content = xmlNodeGetContent(node_coord);315 buffer_add_str(tmp, (char *) content);316 317 if (strcmp((char *) node_coord->name, "coordinates") == 0)318 tmp = fe_transform_coord_gml_to_psql(tmp);319 else320 tmp = fe_transform_coord_gml3_to_psql(tmp);321 322 buffer_copy(geom, tmp);323 buffer_free(tmp);324 xmlFree(content);325 }326 327 if (node->next != NULL) {328 if (node->next->type == XML_ELEMENT_NODE) {329 if (strcmp((char *) node->next->name,330 "lineStringMember") == 0)331 buffer_add_str(geom, "),(");332 else if (strcmp((char *) node->next->name, "polygonMember") == 0333 || strcmp((char *) node->next->name, "surfaceMember") == 0)334 buffer_add_str(geom, ")),((");335 else336 buffer_add_str(geom, ",");337 }338 }339 }340 341 /* print the geometry type */342 if (bracket == 3) buffer_add_str(geom, ")))");343 else if (bracket == 2) buffer_add_str(geom, "))");344 else buffer_add_str(geom, ")");345 346 if (!ows_psql_is_geometry_valid(o, geom)) {347 fe->error_code = FE_ERROR_GEOMETRY;348 buffer_free(geom);349 return fe->sql;350 }351 352 buffer_add_str(geom, "'::geometry,");353 buffer_copy(fe->sql, geom);354 355 /* print the srid */356 buffer_add_int(fe->sql, ows_srs_get_srid_from_layer(o, typename));357 buffer_add_str(fe->sql, ")");358 359 buffer_free(geom);360 361 return fe->sql;362 }363 364 365 /*366 * Return the SQL request matching the spatial operator367 */368 static buffer *fe_spatial_functions(ows * o, buffer * typename,369 filter_encoding * fe, xmlNodePtr n)370 {371 bool transform = false;372 373 assert(o != NULL);374 assert(typename != NULL);375 assert(fe != NULL);376 assert(n != NULL);377 378 196 if (strcmp((char *) n->name, "Equals") == 0) 379 buffer_add_str(fe->sql, " Equals(");197 buffer_add_str(fe->sql, " ST_Equals("); 380 198 381 199 if (strcmp((char *) n->name, "Disjoint") == 0) 382 buffer_add_str(fe->sql, " Disjoint(");200 buffer_add_str(fe->sql, " ST_Disjoint("); 383 201 384 202 if (strcmp((char *) n->name, "Touches") == 0) 385 buffer_add_str(fe->sql, " Touches(");203 buffer_add_str(fe->sql, " ST_Touches("); 386 204 387 205 if (strcmp((char *) n->name, "Within") == 0) 388 buffer_add_str(fe->sql, " Within(");206 buffer_add_str(fe->sql, " ST_Within("); 389 207 390 208 if (strcmp((char *) n->name, "Overlaps") == 0) 391 buffer_add_str(fe->sql, " Overlaps(");209 buffer_add_str(fe->sql, " ST_Overlaps("); 392 210 393 211 if (strcmp((char *) n->name, "Crosses") == 0) 394 buffer_add_str(fe->sql, " Crosses(");212 buffer_add_str(fe->sql, " ST_Crosses("); 395 213 396 214 if (strcmp((char *) n->name, "Intersects") == 0) 397 buffer_add_str(fe->sql, " Intersects(");215 buffer_add_str(fe->sql, " ST_Intersects("); 398 216 399 217 if (strcmp((char *) n->name, "Contains") == 0) 400 buffer_add_str(fe->sql, " Contains(");218 buffer_add_str(fe->sql, " ST_Contains("); 401 219 402 220 n = n->children; … … 424 242 while (n->type != XML_ELEMENT_NODE) n = n->next; 425 243 426 buffer_add (fe->sql, ',');244 buffer_add_str(fe->sql, ",'"); 427 245 428 246 if (strcmp((char *) n->name, "Box") == 0 429 247 || strcmp((char *) n->name, "Envelope") == 0) 430 248 fe->sql = fe_envelope(o, typename, fe, n); 431 else 432 fe->sql = fe_transform_geometry_gml_to_psql(o, typename, fe, n); 433 434 buffer_add(fe->sql, ')'); 249 else { 250 sql = ows_psql_gml_to_sql(o, n); 251 if (sql != NULL) { 252 buffer_copy(fe->sql, sql); 253 buffer_free(sql); 254 } /* TODO else case */ 255 } 256 257 buffer_add_str(fe->sql, "')"); 435 258 436 259 return fe->sql; … … 446 269 { 447 270 xmlChar *content, *units; 271 buffer *tmp, *op, *sql; 448 272 float km; 449 buffer *tmp, *op;450 273 451 274 assert(o != NULL); … … 482 305 fe->sql = fe_property_name(o, typename, fe, fe->sql, n, true); 483 306 484 buffer_add_str(fe->sql, "),ST_centroid( ");307 buffer_add_str(fe->sql, "),ST_centroid('"); 485 308 486 309 n = n->next; … … 490 313 491 314 /* display the geometry */ 492 fe->sql = fe_transform_geometry_gml_to_psql(o, typename, fe, n); 493 494 buffer_add_str(fe->sql, "))"); 315 sql = ows_psql_gml_to_sql(o, n); 316 if (sql != NULL) { 317 buffer_copy(fe->sql, sql); 318 buffer_free(sql); 319 } /* TODO else case */ 320 321 buffer_add_str(fe->sql, "'))"); 495 322 496 323 n = n->next; -
src/ows/ows.h
r168 r195 421 421 bool wfs_display_bbox; 422 422 423 bool check_schema; 424 bool check_valid_geom; 425 423 426 array * cgi; 424 427 list * psql_requests; -
src/ows/ows_config.c
r193 r195 42 42 43 43 a = xmlTextReaderGetAttribute(r, (xmlChar *) "online_resource"); 44 45 44 if (a != NULL) { 46 45 o->online_resource = buffer_init(); … … 50 49 51 50 a = xmlTextReaderGetAttribute(r, (xmlChar *) "schema_dir"); 52 53 51 if (a != NULL) { 54 52 o->schema_dir = buffer_init(); … … 58 56 59 57 a = xmlTextReaderGetAttribute(r, (xmlChar *) "log"); 60 61 58 if (a != NULL) { 62 59 o->log = buffer_init(); … … 66 63 67 64 a = xmlTextReaderGetAttribute(r, (xmlChar *) "degree_precision"); 68 69 65 if (a != NULL) { 70 66 o->schema_dir = buffer_init(); 71 67 precision = atoi((char *) a); 72 73 68 if (precision > 0 && precision < 12) 74 69 o->degree_precision = precision; 75 76 70 xmlFree(a); 77 71 } 78 72 79 73 a = xmlTextReaderGetAttribute(r, (xmlChar *) "meter_precision"); 80 81 74 if (a != NULL) { 82 75 o->schema_dir = buffer_init(); 83 76 precision = atoi((char *) a); 84 85 77 if (precision > 0 && precision < 12) 86 78 o->meter_precision = precision; 87 88 79 xmlFree(a); 89 80 } 90 81 91 82 a = xmlTextReaderGetAttribute(r, (xmlChar *) "wfs_display_bbox"); 92 93 83 o->wfs_display_bbox = true; 94 95 if (a != NULL) { 96 if (atoi((char *) a)) 97 o->wfs_display_bbox = true; 98 else 99 o->wfs_display_bbox = false; 100 101 xmlFree(a); 102 } 103 84 if (a != NULL) { 85 if (atoi((char *) a)) o->wfs_display_bbox = true; 86 else o->wfs_display_bbox = false; 87 xmlFree(a); 88 } 89 90 a = xmlTextReaderGetAttribute(r, (xmlChar *) "check_schema"); 91 o->check_schema = true; 92 if (a != NULL) { 93 if (atoi((char *) a)) o->check_schema = true; 94 else o->check_schema = false; 95 xmlFree(a); 96 } 97 98 a = xmlTextReaderGetAttribute(r, (xmlChar *) "check_valid_geom"); 99 o->check_valid_geom = true; 100 if (a != NULL) { 101 if (atoi((char *) a)) o->check_valid_geom = true; 102 else o->check_valid_geom = false; 103 xmlFree(a); 104 } 104 105 } 105 106 -
src/ows/ows_psql.c
r192 r195 434 434 435 435 436 437 /* 438 * * Return the number of rows returned by the specified requests 439 * */ 436 /* 437 * Return the number of rows returned by the specified requests 438 */ 440 439 int ows_psql_number_features(ows * o, list * from, list * where) 441 440 { 442 buffer *sql; 443 PGresult *res; 444 list_node *ln_from, *ln_where; 445 int nb; 446 447 assert(o != NULL); 448 assert(from != NULL); 449 assert(where != NULL); 450 451 nb = 0; 452 453 /* checks if from list and where list have the same size */ 454 if (from->size != where->size) return nb; 455 456 457 for (ln_from = from->first, ln_where = where->first; ln_from != NULL; 458 ln_from = ln_from->next, ln_where = ln_where->next) { 459 sql = buffer_init(); 460 461 /* execute the request */ 462 buffer_add_str(sql, "SELECT count(*) FROM \""); 463 buffer_copy(sql, ln_from->value); 464 buffer_add_str(sql, "\" "); 465 buffer_copy(sql, ln_where->value); 466 res = PQexec(o->pg, sql->buf); 467 buffer_free(sql); 468 469 if (PQresultStatus(res) != PGRES_TUPLES_OK) { 470 PQclear(res); 471 return -1; 472 } 473 nb = nb + atoi(PQgetvalue(res, 0, 0)); 441 buffer *sql; 442 PGresult *res; 443 list_node *ln_from, *ln_where; 444 int nb; 445 446 assert(o != NULL); 447 assert(from != NULL); 448 assert(where != NULL); 449 450 nb = 0; 451 452 /* checks if from list and where list have the same size */ 453 if (from->size != where->size) return nb; 454 455 456 for (ln_from = from->first, ln_where = where->first; ln_from != NULL; 457 ln_from = ln_from->next, ln_where = ln_where->next) { 458 sql = buffer_init(); 459 460 /* execute the request */ 461 buffer_add_str(sql, "SELECT count(*) FROM \""); 462 buffer_copy(sql, ln_from->value); 463 buffer_add_str(sql, "\" "); 464 buffer_copy(sql, ln_where->value); 465 res = PQexec(o->pg, sql->buf); 466 buffer_free(sql); 467 468 if (PQresultStatus(res) != PGRES_TUPLES_OK) { 474 469 PQclear(res); 475 } 476 477 return nb; 478 } 470 return -1; 471 } 472 nb = nb + atoi(PQgetvalue(res, 0, 0)); 473 PQclear(res); 474 } 475 476 return nb; 477 } 478 479 480 static xmlNodePtr ows_psql_recursive_parse_gml(ows * o, xmlNodePtr n) 481 { 482 xmlNodePtr c; 483 static xmlNodePtr result=NULL; 484 485 assert(o != NULL); 486 assert(n != NULL); 487 488 if (result) return result; /* avoid recursive loop */ 489 490 /* We are looking for the geometry part inside GML doc */ 491 for (; n ; n = n->next) { 492 493 if (n->type != XML_ELEMENT_NODE) continue; 494 495 /* GML SF Geometries Types */ 496 if ( !strcmp((char *) n->name, "Point") 497 || !strcmp((char *) n->name, "LineString") 498 || !strcmp((char *) n->name, "Curve") 499 || !strcmp((char *) n->name, "Polygon") 500 || !strcmp((char *) n->name, "Surface") 501 || !strcmp((char *) n->name, "MultiPoint") 502 || !strcmp((char *) n->name, "MultiLineString") 503 || !strcmp((char *) n->name, "MultiCurve") 504 || !strcmp((char *) n->name, "MultiPolygon") 505 || !strcmp((char *) n->name, "MultiSurface") 506 || !strcmp((char *) n->name, "MultiGeometry")) { 507 508 return n; 509 } 510 /* TODO Add check on namespace GML 3 and GML 3.2 */ 511 512 /* Recursive exploration */ 513 if (n->children) 514 for (c = n->children ; c ; c = c->next) 515 if ((result = ows_psql_recursive_parse_gml(o, c))) 516 return result; 517 } 518 519 return NULL; 520 } 521 522 523 /* 524 * Transform a GML geometry to PostGIS EWKT 525 * Return NULL on error 526 */ 527 buffer * ows_psql_gml_to_sql(ows * o, xmlNodePtr n) 528 { 529 PGresult *res; 530 xmlNodePtr g; 531 buffer *result, *sql, *gml; 532 533 assert(o != NULL); 534 assert(n != NULL); 535 536 g = ows_psql_recursive_parse_gml(o, n); 537 if (!g) return NULL; /* No Geometry founded in GML doc */ 538 539 /* Retrieve the sub doc and launch GML parse via PostGIS */ 540 gml = buffer_init(); 541 cgi_add_xml_into_buffer(gml, g); 542 543 sql = buffer_init(); 544 buffer_add_str(sql, "SELECT ST_GeomFromGML('"); 545 buffer_add_str(sql, gml->buf); 546 buffer_add_str(sql, "')"); 547 548 res = PQexec(o->pg, sql->buf); 549 buffer_free(gml); 550 551 552 /* GML Parse errors cases */ 553 if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) != 1) { 554 buffer_free(sql); 555 PQclear(res); 556 return NULL; 557 } 558 559 result = buffer_init(); 560 buffer_add_str(result, PQgetvalue(res, 0, 0)); 561 PQclear(res); 562 563 /* Check if geometry is valid */ 564 if (o->check_valid_geom) { 565 566 buffer_empty(sql); 567 buffer_add_str(sql, "SELECT ST_IsValid('"); 568 buffer_add_str(sql, result->buf); 569 buffer_add_str(sql, "')"); 570 571 res = PQexec(o->pg, sql->buf); 572 573 if ( PQresultStatus(res) != PGRES_TUPLES_OK 574 || PQntuples(res) != 1 575 || (char) PQgetvalue(res, 0, 0)[0] != 't') { 576 buffer_free(sql); 577 buffer_free(result); 578 PQclear(res); 579 return NULL; 580 } 581 } 582 583 buffer_free(sql); 584 PQclear(res); 585 586 return result; 587 } 588 479 589 480 590 /* -
src/ows/ows_request.c
r190 r195 390 390 if ((cgi_method_post() && strcmp(getenv("CONTENT_TYPE"), "application/x-www-form-urlencoded") != 0) 391 391 || (!cgi_method_post() && !cgi_method_get() && query[0] == '<')) { 392 xmlstring = buffer_init(); 393 buffer_add_str(xmlstring, query); 394 395 if (or->service == WFS) { 392 393 if (or->service == WFS && o->check_schema) { 394 395 xmlstring = buffer_init(); 396 buffer_add_str(xmlstring, query); 396 397 397 398 if (ows_version_get(or->version) == 100) { … … 418 419 419 420 buffer_free(schema); 420 } 421 422 buffer_free(xmlstring); 423 424 if (valid != 0) 425 ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 421 buffer_free(xmlstring); 422 423 if (valid != 0) 424 ows_error(o, OWS_ERROR_INVALID_PARAMETER_VALUE, 426 425 "xml isn't valid", "request"); 426 } 427 427 } 428 428 } -
src/ows_api.h
r192 r195 55 55 buffer *fe_property_name (ows * o, buffer * typename, filter_encoding * fe, buffer * sql, xmlNodePtr n, bool check_geom_column); 56 56 buffer *fe_spatial_op (ows * o, buffer * typename, filter_encoding * fe, xmlNodePtr n); 57 buffer *fe_transform_coord_gml3_to_psql (buffer * coord);58 buffer *fe_transform_coord_gml_to_psql (buffer * coord);59 buffer *fe_transform_geometry_gml_to_psql (ows * o, buffer * typename, filter_encoding * fe, xmlNodePtr n);60 57 buffer *fe_xpath_property_name (ows * o, buffer * typename, buffer * property); 61 58 buffer *fill_fe_error (ows * o, filter_encoding * fe); … … 147 144 buffer *ows_psql_generate_id (ows * o, buffer * layer_name); 148 145 int ows_psql_number_features(ows * o, list * from, list * where); 146 buffer * ows_psql_gml_to_sql(ows * o, xmlNodePtr n); 149 147 void ows_request_check (ows * o, ows_request * or, const array * cgi, const char *query); 150 148 void ows_request_flush (ows_request * or, FILE * output); -
src/wfs/wfs_transaction.c
r192 r195 316 316 static buffer *wfs_insert_xml(ows * o, wfs_request * wr, xmlDocPtr xmldoc, xmlNodePtr n) 317 317 { 318 buffer *values, *column, *layer_name, *layer_prefix, *result, *sql ;318 buffer *values, *column, *layer_name, *layer_prefix, *result, *sql, *gml; 319 319 buffer *id, *handle, *id_column, *fid_full_name, *dup_sql; 320 320 filter_encoding *fe; … … 332 332 sql = buffer_init(); 333 333 handle = buffer_init(); 334 id = buffer_init();335 334 336 335 /* retrieve handle attribute to report it in transaction response */ … … 471 470 while (elemt->type != XML_ELEMENT_NODE) elemt = elemt->next; 472 471 473 fe = filter_encoding_init();474 fe->sql = buffer_init();475 476 472 if (strcmp((char *) elemt->name, "Box") == 0 477 473 || strcmp((char *) elemt->name, "Envelope") == 0) { 474 475 fe = filter_encoding_init(); 476 fe->sql = buffer_init(); 478 477 fe->sql = fe_envelope(o, layer_name, fe, elemt); 479 478 buffer_copy(values, fe->sql); 479 filter_encoding_free(fe); 480 480 481 } else if (strcmp((char *) elemt->name, "Null") == 0) { 481 482 buffer_add_str(values, "''"); 482 483 } else { 483 fe->sql = fe_transform_geometry_gml_to_psql(o, layer_name, fe, elemt); 484 485 /* FIXME is it really the right way to handle that ? 486 * What about an ows error instead ? 487 */ 488 if (fe->error_code) 489 buffer_add_str(values, "NULL"); 490 else 491 buffer_copy(values, fe->sql); 484 gml = ows_psql_gml_to_sql(o, n); 485 if (gml != NULL) { 486 buffer_add_str(values, "'"); 487 buffer_copy(values, gml); 488 buffer_add_str(values, "'"); 489 buffer_free(gml); 490 } /* TODO else case */ 492 491 } 493 492 494 filter_encoding_free(fe);495 493 } else { 496 494 values = wfs_retrieve_value(o, wr, values, xmldoc, node); … … 726 724 static buffer *wfs_update_xml(ows * o, wfs_request * wr, xmlDocPtr xmldoc, xmlNodePtr n) 727 725 { 728 buffer *typename, *xmlstring, *result, *sql, *property_name, *values ;726 buffer *typename, *xmlstring, *result, *sql, *property_name, *values, *gml; 729 727 filter_encoding *filter, *fe; 730 728 xmlNodePtr node, elemt; … … 797 795 elemt = elemt->next; 798 796 799 fe = filter_encoding_init();800 fe->sql = buffer_init();801 802 797 if (strcmp((char *) elemt->name, "Box") == 0 803 798 || strcmp((char *) elemt->name, "Envelope") == 0) { 799 800 fe = filter_encoding_init(); 801 fe->sql = buffer_init(); 804 802 fe->sql = fe_envelope(o, typename, fe, elemt); 805 803 buffer_copy(values, fe->sql); 804 filter_encoding_free(fe); 805 806 806 } else if (strcmp((char *) elemt->name, "Null") == 0) { 807 807 buffer_add_str(values, "''"); 808 808 } else { 809 fe->sql = fe_transform_geometry_gml_to_psql(o, typename, fe, elemt); 810 buffer_copy(values, fe->sql); 809 gml = ows_psql_gml_to_sql(o, n); 810 if (gml != NULL) { 811 buffer_add_str(values, "'"); 812 buffer_copy(values, gml); 813 buffer_add_str(values, "'"); 814 buffer_free(gml); 815 } /* TODO else case */ 811 816 } 812 817 813 filter_encoding_free(fe);814 818 } else { 815 819 values = wfs_retrieve_value(o, wr, values, xmldoc, node); -
test/install.sh.in
r183 r195 5 5 6 6 PG_BIN=@POSTGIS_BIN@ 7 PG_SHARE=@POSTGIS_SHARE@/contrib/ 7 PG_SHARE=@POSTGIS_SHARE@/contrib/postgis-1.5 8 8 PG_USER=postgres 9 9 DB=tinyows_test