MCPcopy Create free account
hub / github.com/MapServer/MapServer / gmlWriteGeometry_GML2

Function gmlWriteGeometry_GML2

mapgml.c:123–380  ·  view source on GitHub ↗

GML 2.1.2 */

Source from the content-addressed store, hash-verified

121
122/* GML 2.1.2 */
123static int gmlWriteGeometry_GML2(FILE *stream, gmlGeometryListObj *geometryList, shapeObj *shape, const char *srsname, char *namespace, char *tab)
124{
125 int i, j, k;
126 int *innerlist, *outerlist, numouters;
127 char *srsname_encoded = NULL;
128
129 int geometry_aggregate_index, geometry_simple_index;
130 char *geometry_aggregate_name = NULL, *geometry_simple_name = NULL;
131
132 if(!stream) return(MS_FAILURE);
133 if(!shape) return(MS_FAILURE);
134 if(!tab) return(MS_FAILURE);
135 if(!geometryList) return(MS_FAILURE);
136
137 if(shape->numlines <= 0) return(MS_SUCCESS); /* empty shape, nothing to output */
138
139 if(srsname)
140 srsname_encoded = msEncodeHTMLEntities(srsname);
141
142 /* feature geometry */
143 switch(shape->type) {
144 case(MS_SHAPE_POINT):
145 geometry_simple_index = msGMLGeometryLookup(geometryList, "point");
146 geometry_aggregate_index = msGMLGeometryLookup(geometryList, "multipoint");
147 if(geometry_simple_index >= 0) geometry_simple_name = geometryList->geometries[geometry_simple_index].name;
148 if(geometry_aggregate_index >= 0) geometry_aggregate_name = geometryList->geometries[geometry_aggregate_index].name;
149
150 if((geometry_simple_index != -1 && shape->line[0].numpoints == 1 && shape->numlines == 1) ||
151 (geometry_simple_index != -1 && geometry_aggregate_index == -1) ||
152 (geometryList->numgeometries == 0 && shape->line[0].numpoints == 1 && shape->numlines == 1)) { /* write a Point(s) */
153
154 for(i=0; i<shape->numlines; i++) {
155 for(j=0; j<shape->line[i].numpoints; j++) {
156 gmlStartGeometryContainer(stream, geometry_simple_name, namespace, tab);
157
158 /* Point */
159 if(srsname_encoded)
160 msIO_fprintf(stream, "%s<gml:Point srsName=\"%s\">\n", tab, srsname_encoded);
161 else
162 msIO_fprintf(stream, "%s<gml:Point>\n", tab);
163 msIO_fprintf(stream, "%s <gml:coordinates>%f,%f</gml:coordinates>\n", tab, shape->line[i].point[j].x, shape->line[i].point[j].y);
164 msIO_fprintf(stream, "%s</gml:Point>\n", tab);
165
166 gmlEndGeometryContainer(stream, geometry_simple_name, namespace, tab);
167 }
168 }
169 } else if((geometry_aggregate_index != -1) || (geometryList->numgeometries == 0)) { /* write a MultiPoint */
170 gmlStartGeometryContainer(stream, geometry_aggregate_name, namespace, tab);
171
172 /* MultiPoint */
173 if(srsname_encoded)
174 msIO_fprintf(stream, "%s<gml:MultiPoint srsName=\"%s\">\n", tab, srsname_encoded);
175 else
176 msIO_fprintf(stream, "%s<gml:MultiPoint>\n", tab);
177
178 for(i=0; i<shape->numlines; i++) {
179 for(j=0; j<shape->line[i].numpoints; j++) {
180 msIO_fprintf(stream, "%s <gml:pointMember>\n", tab);

Callers 1

gmlWriteGeometryFunction · 0.85

Calls 8

msEncodeHTMLEntitiesFunction · 0.85
msGMLGeometryLookupFunction · 0.85
msIO_fprintfFunction · 0.85
gmlEndGeometryContainerFunction · 0.85
msGetOuterListFunction · 0.85
msGetInnerListFunction · 0.85
msFreeFunction · 0.85

Tested by

no test coverage detected