GML 3.1 (MapServer limits GML encoding to the level 0 profile) */
| 381 | |
| 382 | /* GML 3.1 (MapServer limits GML encoding to the level 0 profile) */ |
| 383 | static int gmlWriteGeometry_GML3(FILE *stream, gmlGeometryListObj *geometryList, shapeObj *shape, const char *srsname, char *namespace, char *tab) |
| 384 | { |
| 385 | int i, j, k; |
| 386 | int *innerlist, *outerlist, numouters; |
| 387 | char *srsname_encoded = NULL; |
| 388 | |
| 389 | int geometry_aggregate_index, geometry_simple_index; |
| 390 | char *geometry_aggregate_name = NULL, *geometry_simple_name = NULL; |
| 391 | |
| 392 | if(!stream) return(MS_FAILURE); |
| 393 | if(!shape) return(MS_FAILURE); |
| 394 | if(!tab) return(MS_FAILURE); |
| 395 | if(!geometryList) return(MS_FAILURE); |
| 396 | |
| 397 | if(shape->numlines <= 0) return(MS_SUCCESS); /* empty shape, nothing to output */ |
| 398 | |
| 399 | if(srsname) |
| 400 | srsname_encoded = msEncodeHTMLEntities(srsname); |
| 401 | |
| 402 | /* feature geometry */ |
| 403 | switch(shape->type) { |
| 404 | case(MS_SHAPE_POINT): |
| 405 | geometry_simple_index = msGMLGeometryLookup(geometryList, "point"); |
| 406 | geometry_aggregate_index = msGMLGeometryLookup(geometryList, "multipoint"); |
| 407 | if(geometry_simple_index >= 0) geometry_simple_name = geometryList->geometries[geometry_simple_index].name; |
| 408 | if(geometry_aggregate_index >= 0) geometry_aggregate_name = geometryList->geometries[geometry_aggregate_index].name; |
| 409 | |
| 410 | if((geometry_simple_index != -1 && shape->line[0].numpoints == 1 && shape->numlines == 1) || |
| 411 | (geometry_simple_index != -1 && geometry_aggregate_index == -1) || |
| 412 | (geometryList->numgeometries == 0 && shape->line[0].numpoints == 1 && shape->numlines == 1)) { /* write a Point(s) */ |
| 413 | |
| 414 | for(i=0; i<shape->numlines; i++) { |
| 415 | for(j=0; j<shape->line[i].numpoints; j++) { |
| 416 | gmlStartGeometryContainer(stream, geometry_simple_name, namespace, tab); |
| 417 | |
| 418 | /* Point */ |
| 419 | if(srsname_encoded) |
| 420 | msIO_fprintf(stream, "%s <gml:Point srsName=\"%s\">\n", tab, srsname_encoded); |
| 421 | else |
| 422 | msIO_fprintf(stream, "%s <gml:Point>\n", tab); |
| 423 | msIO_fprintf(stream, "%s <gml:pos>%f %f</gml:pos>\n", tab, shape->line[i].point[j].x, shape->line[i].point[j].y); |
| 424 | msIO_fprintf(stream, "%s </gml:Point>\n", tab); |
| 425 | |
| 426 | gmlEndGeometryContainer(stream, geometry_simple_name, namespace, tab); |
| 427 | } |
| 428 | } |
| 429 | } else if((geometry_aggregate_index != -1) || (geometryList->numgeometries == 0)) { /* write a MultiPoint */ |
| 430 | gmlStartGeometryContainer(stream, geometry_aggregate_name, namespace, tab); |
| 431 | |
| 432 | /* MultiPoint */ |
| 433 | if(srsname_encoded) |
| 434 | msIO_fprintf(stream, "%s <gml:MultiPoint srsName=\"%s\">\n", tab, srsname_encoded); |
| 435 | else |
| 436 | msIO_fprintf(stream, "%s <gml:MultiPoint>\n", tab); |
| 437 | |
| 438 | msIO_fprintf(stream, "%s <gml:pointMembers>\n", tab); |
| 439 | for(i=0; i<shape->numlines; i++) { |
| 440 | for(j=0; j<shape->line[i].numpoints; j++) { |
no test coverage detected