81 size_t prefixlen = strlen(prefix);
85 size = (
sizeof(
"<Box>/") + (prefixlen*2) ) * 2;
86 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
90 ptr += sprintf(ptr,
"<%sBox", prefix);
92 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
94 ptr += sprintf(ptr,
"/>");
112 size += (
sizeof(
"<Box><coordinates>/") + (prefixlen*2) ) * 2;
113 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
117 if ( srs ) ptr += sprintf(ptr,
"<%sBox srsName=\"%s\">", prefix, srs);
118 else ptr += sprintf(ptr,
"<%sBox>", prefix);
120 ptr += sprintf(ptr,
"<%scoordinates>", prefix);
122 ptr += sprintf(ptr,
"</%scoordinates></%sBox>", prefix, prefix);
136 size_t prefixlen = strlen(prefix);
141 size = (
sizeof(
"<Envelope>/") + (prefixlen*2) ) * 2;
142 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
146 ptr += sprintf(ptr,
"<%sEnvelope", prefix);
147 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
149 ptr += sprintf(ptr,
"/>");
164 size += (
sizeof(
"<Envelope><lowerCorner><upperCorner>//") + (prefixlen*3) ) * 2;
165 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
166 if (
IS_DIMS(opts) ) size +=
sizeof(
" srsDimension=. .");
170 ptr += sprintf(ptr,
"<%sEnvelope", prefix);
171 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
172 if (
IS_DIMS(opts) ) ptr += sprintf(ptr,
" srsDimension=\"%d\"", dimension);
173 ptr += sprintf(ptr,
">");
175 ptr += sprintf(ptr,
"<%slowerCorner>", prefix);
177 ptr += sprintf(ptr,
"</%slowerCorner>", prefix);
185 ptr += sprintf(ptr,
"<%supperCorner>", prefix);
187 ptr += sprintf(ptr,
"</%supperCorner>", prefix);
189 ptr += sprintf(ptr,
"</%sEnvelope>", prefix);
222 return gbox_to_gml3(bbox, srs, precision, opts, prefix);
261 lwerror(
"Cannot convert %s to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.",
lwtype_name(type));
274 size_t prefixlen = strlen(prefix);
277 size += (
sizeof(
"<point><coordinates>/") + (prefixlen*2) ) * 2;
278 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
287 ptr += sprintf(ptr,
"<%sPoint", prefix);
288 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
291 ptr += sprintf(ptr,
"/>");
294 ptr += sprintf(ptr,
">");
295 ptr += sprintf(ptr,
"<%scoordinates>", prefix);
297 ptr += sprintf(ptr,
"</%scoordinates></%sPoint>", prefix, prefix);
318 size_t prefixlen = strlen(prefix);
321 size += (
sizeof(
"<linestring><coordinates>/") + (prefixlen*2) ) * 2;
322 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
332 ptr += sprintf(ptr,
"<%sLineString", prefix);
333 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
337 ptr += sprintf(ptr,
"/>");
340 ptr += sprintf(ptr,
">");
342 ptr += sprintf(ptr,
"<%scoordinates>", prefix);
344 ptr += sprintf(ptr,
"</%scoordinates></%sLineString>", prefix, prefix);
366 size_t prefixlen = strlen(prefix);
368 size =
sizeof(
"<polygon></polygon>") + prefixlen*2;
369 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
372 size += (
sizeof(
"<outerboundaryis><linearring><coordinates>/") + ( prefixlen*3) ) * 2;
373 size += (
sizeof(
"<innerboundaryis><linearring><coordinates>/") + ( prefixlen*2) ) * 2 * poly->
nrings;
375 for (i=0; i<poly->
nrings; i++)
388 ptr += sprintf(ptr,
"<%sPolygon", prefix);
389 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
392 ptr += sprintf(ptr,
"/>");
395 ptr += sprintf(ptr,
">");
396 ptr += sprintf(ptr,
"<%souterBoundaryIs><%sLinearRing><%scoordinates>",
397 prefix, prefix, prefix);
399 ptr += sprintf(ptr,
"</%scoordinates></%sLinearRing></%souterBoundaryIs>", prefix, prefix, prefix);
400 for (i=1; i<poly->
nrings; i++)
402 ptr += sprintf(ptr,
"<%sinnerBoundaryIs><%sLinearRing><%scoordinates>", prefix, prefix, prefix);
404 ptr += sprintf(ptr,
"</%scoordinates></%sLinearRing></%sinnerBoundaryIs>", prefix, prefix, prefix);
406 ptr += sprintf(ptr,
"</%sPolygon>", prefix);
434 size_t prefixlen = strlen(prefix);
438 size =
sizeof(
"<MultiLineString></MultiLineString>");
441 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
443 for (i=0; i<col->
ngeoms; i++)
445 subgeom = col->
geoms[i];
448 size += (
sizeof(
"<pointMember>/") + prefixlen ) * 2;
453 size += (
sizeof(
"<lineStringMember>/") + prefixlen ) * 2;
458 size += (
sizeof(
"<polygonMember>/") + prefixlen ) * 2;
486 ptr += sprintf(ptr,
"<%s%s", prefix, gmltype);
487 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
491 ptr += sprintf(ptr,
"/>");
494 ptr += sprintf(ptr,
">");
496 for (i=0; i<col->
ngeoms; i++)
498 subgeom = col->
geoms[i];
501 ptr += sprintf(ptr,
"<%spointMember>", prefix);
503 ptr += sprintf(ptr,
"</%spointMember>", prefix);
507 ptr += sprintf(ptr,
"<%slineStringMember>", prefix);
509 ptr += sprintf(ptr,
"</%slineStringMember>", prefix);
513 ptr += sprintf(ptr,
"<%spolygonMember>", prefix);
515 ptr += sprintf(ptr,
"</%spolygonMember>", prefix);
520 ptr += sprintf(ptr,
"</%s%s>", prefix, gmltype);
551 size_t prefixlen = strlen(prefix);
554 size =
sizeof(
"<MultiGeometry></MultiGeometry>");
555 size += (prefixlen * 2);
557 if ( srs ) size += strlen(srs) +
sizeof(
" srsName=..");
559 for (i=0; i<col->
ngeoms; i++)
561 subgeom = col->
geoms[i];
563 size += (
sizeof(
"<geometryMember>/") + prefixlen ) * 2;
581 lwerror(
"asgml2_collection_size: Unable to process geometry type!");
601 ptr += sprintf(ptr,
"<%sMultiGeometry", prefix);
602 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
606 ptr += sprintf(ptr,
"/>");
609 ptr += sprintf(ptr,
">");
611 for (i=0; i<col->
ngeoms; i++)
613 subgeom = col->
geoms[i];
615 ptr += sprintf(ptr,
"<%sgeometryMember>", prefix);
635 ptr += sprintf(ptr,
"</%sgeometryMember>", prefix);
639 ptr += sprintf(ptr,
"</%sMultiGeometry>", prefix);
680 sprintf(x,
"%.*f", precision, pt->
x);
682 sprintf(x,
"%g", pt->
x);
686 sprintf(y,
"%.*f", precision, pt->
y);
688 sprintf(y,
"%g", pt->
y);
691 if ( i ) ptr += sprintf(ptr,
" ");
692 ptr += sprintf(ptr,
"%s,%s", x, y);
703 sprintf(x,
"%.*f", precision, pt->
x);
705 sprintf(x,
"%g", pt->
x);
709 sprintf(y,
"%.*f", precision, pt->
y);
711 sprintf(y,
"%g", pt->
y);
715 sprintf(z,
"%.*f", precision, pt->
z);
717 sprintf(z,
"%g", pt->
z);
720 if ( i ) ptr += sprintf(ptr,
" ");
721 ptr += sprintf(ptr,
"%s,%s,%s", x, y, z);
797 size_t prefixlen = strlen(prefix);
800 size += (
sizeof(
"<point><pos>/") + (prefixlen*2) ) * 2;
801 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
802 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
803 if (
IS_DIMS(opts)) size +=
sizeof(
" srsDimension='x'");
815 ptr += sprintf(ptr,
"<%sPoint", prefix);
816 if ( srs ) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
817 if (
id ) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
820 ptr += sprintf(ptr,
"/>");
824 ptr += sprintf(ptr,
">");
825 if (
IS_DIMS(opts)) ptr += sprintf(ptr,
"<%spos srsDimension=\"%d\">", prefix, dimension);
826 else ptr += sprintf(ptr,
"<%spos>", prefix);
828 ptr += sprintf(ptr,
"</%spos></%sPoint>", prefix, prefix);
850 size_t prefixlen = strlen(prefix);
856 sizeof(
"<LineString><posList>/") +
863 sizeof(
"<Curve><segments><LineStringSegment><posList>/") +
867 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
868 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
869 if (
IS_DIMS(opts)) size +=
sizeof(
" srsDimension='x'");
884 ptr += sprintf(ptr,
"<%sLineString", prefix);
888 ptr += sprintf(ptr,
"<%sCurve", prefix);
891 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
892 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
896 ptr += sprintf(ptr,
"/>");
899 ptr += sprintf(ptr,
">");
903 ptr += sprintf(ptr,
"<%ssegments>", prefix);
904 ptr += sprintf(ptr,
"<%sLineStringSegment>", prefix);
909 ptr += sprintf(ptr,
"<%sposList srsDimension=\"%d\">",
914 ptr += sprintf(ptr,
"<%sposList>", prefix);
919 ptr += sprintf(ptr,
"</%sposList>", prefix);
923 ptr += sprintf(ptr,
"</%sLineString>", prefix);
927 ptr += sprintf(ptr,
"</%sLineStringSegment>", prefix);
928 ptr += sprintf(ptr,
"</%ssegments>", prefix);
929 ptr += sprintf(ptr,
"</%sCurve>", prefix);
952 size_t prefixlen = strlen(prefix);
953 size += 2 * (
sizeof(
"<Curve><segments>/" ) + 2 * prefixlen );
954 size += 2 * (
sizeof(
"<ArcString><posList>/" ) + 2 * prefixlen );
955 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
956 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
957 if (
IS_DIMS(opts)) size +=
sizeof(
" srsDimension='x'");
972 ptr += sprintf(ptr,
"<%sCurve", prefix);
975 ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
979 ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
981 ptr += sprintf(ptr,
">");
982 ptr += sprintf(ptr,
"<%ssegments>", prefix);
983 ptr += sprintf(ptr,
"<%sArcString>", prefix);
984 ptr += sprintf(ptr,
"<%sposList", prefix);
988 ptr += sprintf(ptr,
" srsDimension=\"%d\"", dimension);
990 ptr += sprintf(ptr,
">");
993 ptr += sprintf(ptr,
"</%sposList>", prefix);
994 ptr += sprintf(ptr,
"</%sArcString>", prefix);
995 ptr += sprintf(ptr,
"</%ssegments>", prefix);
996 ptr += sprintf(ptr,
"</%sCurve>", prefix);
1017 size_t prefixlen = strlen(prefix);
1020 size = (
sizeof(
"<PolygonPatch><exterior><LinearRing>///") + (prefixlen*3) ) * 2;
1021 size += (
sizeof(
"<interior><LinearRing>//") + (prefixlen*2) ) * 2 * (poly->
nrings - 1);
1022 size += (
sizeof(
"<posList></posList>") + (prefixlen*2) ) * poly->
nrings;
1023 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1024 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1025 if (
IS_DIMS(opts)) size +=
sizeof(
" srsDimension='x'") * poly->
nrings;
1027 for (i=0; i<poly->
nrings; i++)
1043 ptr += sprintf(ptr,
"<%sPolygonPatch", prefix);
1048 ptr += sprintf(ptr,
"<%sPolygon", prefix);
1051 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1052 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
1056 ptr += sprintf(ptr,
"/>");
1057 return (ptr-output);
1059 ptr += sprintf(ptr,
">");
1061 ptr += sprintf(ptr,
"<%sexterior><%sLinearRing>", prefix, prefix);
1062 if (
IS_DIMS(opts)) ptr += sprintf(ptr,
"<%sposList srsDimension=\"%d\">", prefix, dimension);
1063 else ptr += sprintf(ptr,
"<%sposList>", prefix);
1066 ptr += sprintf(ptr,
"</%sposList></%sLinearRing></%sexterior>",
1067 prefix, prefix, prefix);
1068 for (i=1; i<poly->
nrings; i++)
1070 ptr += sprintf(ptr,
"<%sinterior><%sLinearRing>", prefix, prefix);
1071 if (
IS_DIMS(opts)) ptr += sprintf(ptr,
"<%sposList srsDimension=\"%d\">", prefix, dimension);
1072 else ptr += sprintf(ptr,
"<%sposList>", prefix);
1074 ptr += sprintf(ptr,
"</%sposList></%sLinearRing></%sinterior>",
1075 prefix, prefix, prefix);
1077 if (is_patch) ptr += sprintf(ptr,
"</%sPolygonPatch>", prefix);
1078 else ptr += sprintf(ptr,
"</%sPolygon>", prefix);
1080 return (ptr-output);
1091 asgml3_poly_buf(poly, srs, output, precision, opts, is_patch, prefix,
id);
1101 size_t prefixlen = strlen(prefix);
1103 size = (
sizeof(
"<Curve></Curve>" ) + 2 * prefixlen );
1105 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1106 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1108 size += (
sizeof(
"<segments></segments>") + 2 * prefixlen );
1110 for(i= 0; i < col->
ngeoms; ++i )
1112 subgeom = col->
geoms[i];
1116 size +=
sizeof(
"<LineStringSegment></LineStringSegment" ) + 2 * prefixlen;
1117 size +=
sizeof(
"<posList></posList" ) + 2 * prefixlen;
1122 size +=
sizeof(
"<ArcString><posList></ArcString></posList>") + 4 * prefixlen;
1131 size +=
sizeof(
" srsDimension='x'");
1150 ptr += sprintf( ptr,
"<%sCurve", prefix );
1153 ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1157 ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id );
1159 ptr += sprintf( ptr,
">" );
1160 ptr += sprintf( ptr,
"<%ssegments>", prefix );
1162 for( i = 0; i < col->
ngeoms; ++i )
1164 subgeom = col->
geoms[i];
1172 ptr += sprintf( ptr,
"<%sLineStringSegment><%sposList", prefix, prefix );
1175 ptr += sprintf(ptr,
" srsDimension=\"%d\"", dimension);
1177 ptr += sprintf(ptr,
">");
1179 ptr += sprintf( ptr,
"</%sposList></%sLineStringSegment>", prefix, prefix );
1183 ptr += sprintf( ptr,
"<%sArcString><%sposList" , prefix, prefix );
1186 ptr += sprintf(ptr,
" srsDimension=\"%d\"", dimension);
1188 ptr += sprintf(ptr,
">");
1190 ptr += sprintf( ptr,
"</%sposList></%sArcString>", prefix, prefix );
1194 ptr += sprintf( ptr,
"</%ssegments>", prefix );
1195 ptr += sprintf( ptr,
"</%sCurve>", prefix );
1196 return ( ptr - output );
1213 size_t prefixlen = strlen(prefix);
1215 size_t size =
sizeof(
"<Polygon></Polygon" ) + 2 * prefixlen;
1216 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1217 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1220 for( i = 0; i < poly->
nrings; ++i )
1224 size +=
sizeof(
"<exterior></exterior>" ) + 2 * prefixlen;
1228 size +=
sizeof(
"<interior></interior>" ) + 2 * prefixlen;
1230 subgeom = poly->
rings[i];
1234 size +=
sizeof(
"<LinearRing></LinearRing>") + 2 * prefixlen;
1235 size +=
sizeof(
"<posList></posList") + 2 * prefixlen;
1238 size +=
sizeof(
" srsDimension='x'");
1244 size +=
sizeof(
"<Ring></Ring>") + 2 * prefixlen;
1245 size +=
sizeof(
"<CurveMember></CurveMember>") + 2 * prefixlen;
1250 size +=
sizeof(
"<Ring></Ring>") + 2 * prefixlen;
1251 size +=
sizeof(
"<curveMember></curveMember>") + 2 * prefixlen;
1270 ptr += sprintf( ptr,
"<%sPolygon", prefix );
1273 ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1277 ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id );
1279 ptr += sprintf(ptr,
">");
1281 for( i = 0; i < poly->
nrings; ++i )
1285 ptr += sprintf( ptr,
"<%sexterior>", prefix);
1289 ptr += sprintf( ptr,
"<%sinterior>", prefix);
1292 subgeom = poly->
rings[i];
1295 ptr += sprintf( ptr,
"<%sLinearRing>", prefix );
1296 ptr += sprintf( ptr,
"<%sposList", prefix );
1299 ptr += sprintf(ptr,
" srsDimension=\"%d\"", dimension);
1301 ptr += sprintf( ptr,
">" );
1303 ptr += sprintf( ptr,
"</%sposList>", prefix );
1304 ptr += sprintf( ptr,
"</%sLinearRing>", prefix );
1308 ptr += sprintf( ptr,
"<%sRing>", prefix );
1309 ptr += sprintf( ptr,
"<%scurveMember>", prefix );
1311 ptr += sprintf( ptr,
"</%scurveMember>", prefix );
1312 ptr += sprintf( ptr,
"</%sRing>", prefix );
1316 ptr += sprintf( ptr,
"<%sRing>", prefix );
1317 ptr += sprintf( ptr,
"<%scurveMember>", prefix );
1319 ptr += sprintf( ptr,
"</%scurveMember>", prefix );
1320 ptr += sprintf( ptr,
"</%sRing>", prefix );
1325 ptr += sprintf( ptr,
"</%sexterior>", prefix);
1329 ptr += sprintf( ptr,
"</%sinterior>", prefix);
1333 ptr += sprintf( ptr,
"</%sPolygon>", prefix );
1334 return (ptr - output);
1353 size_t prefixlen = strlen(prefix);
1355 size = (
sizeof(
"<Triangle><exterior><LinearRing>///") + (prefixlen*3) ) * 2;
1356 size +=
sizeof(
"<posList></posList>") + (prefixlen*2);
1357 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1358 if (
id) size += strlen(prefix) + strlen(
id) +
sizeof(
" id=..");
1359 if (
IS_DIMS(opts)) size +=
sizeof(
" srsDimension='x'");
1373 ptr += sprintf(ptr,
"<%sTriangle", prefix);
1374 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1375 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
1376 ptr += sprintf(ptr,
">");
1378 ptr += sprintf(ptr,
"<%sexterior><%sLinearRing>", prefix, prefix);
1379 if (
IS_DIMS(opts)) ptr += sprintf(ptr,
"<%sposList srsDimension=\"%d\">", prefix, dimension);
1380 else ptr += sprintf(ptr,
"<%sposList>", prefix);
1383 ptr += sprintf(ptr,
"</%sposList></%sLinearRing></%sexterior>",
1384 prefix, prefix, prefix);
1386 ptr += sprintf(ptr,
"</%sTriangle>", prefix);
1388 return (ptr-output);
1414 size_t prefixlen = strlen(prefix);
1418 size =
sizeof(
"<MultiLineString></MultiLineString>") + prefixlen*2;
1420 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1421 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1423 for (i=0; i<col->
ngeoms; i++)
1425 subgeom = col->
geoms[i];
1428 size += (
sizeof(
"<pointMember>/") + prefixlen ) * 2;
1433 size += (
sizeof(
"<curveMember>/") + prefixlen ) * 2;
1438 size += (
sizeof(
"<surfaceMember>/") + prefixlen ) * 2;
1453 char *ptr, *gmltype;
1465 ptr += sprintf(ptr,
"<%s%s", prefix, gmltype);
1466 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1467 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
1471 ptr += sprintf(ptr,
"/>");
1472 return (ptr-output);
1474 ptr += sprintf(ptr,
">");
1476 for (i=0; i<col->
ngeoms; i++)
1478 subgeom = col->
geoms[i];
1481 ptr += sprintf(ptr,
"<%spointMember>", prefix);
1483 ptr += sprintf(ptr,
"</%spointMember>", prefix);
1487 ptr += sprintf(ptr,
"<%scurveMember>", prefix);
1489 ptr += sprintf(ptr,
"</%scurveMember>", prefix);
1493 ptr += sprintf(ptr,
"<%ssurfaceMember>", prefix);
1495 ptr += sprintf(ptr,
"</%ssurfaceMember>", prefix);
1500 ptr += sprintf(ptr,
"</%s%s>", prefix, gmltype);
1502 return (ptr-output);
1526 size_t prefixlen = strlen(prefix);
1528 size = (
sizeof(
"<PolyhedralSurface><polygonPatches>/") + prefixlen*2) * 2;
1529 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1530 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1532 for (i=0; i<psur->
ngeoms; i++)
1553 ptr += sprintf(ptr,
"<%sPolyhedralSurface", prefix);
1554 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1555 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
1556 ptr += sprintf(ptr,
"><%spolygonPatches>", prefix);
1558 for (i=0; i<psur->
ngeoms; i++)
1564 ptr += sprintf(ptr,
"</%spolygonPatches></%sPolyhedralSurface>",
1567 return (ptr-output);
1591 size_t prefixlen = strlen(prefix);
1593 size = (
sizeof(
"<Tin><trianglePatches>/") + prefixlen*2) * 2;
1594 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1595 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1597 for (i=0; i<tin->
ngeoms; i++)
1618 ptr += sprintf(ptr,
"<%sTin", prefix);
1619 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1620 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
1621 else ptr += sprintf(ptr,
"><%strianglePatches>", prefix);
1623 for (i=0; i<tin->
ngeoms; i++)
1630 ptr += sprintf(ptr,
"</%strianglePatches></%sTin>", prefix, prefix);
1632 return (ptr-output);
1655 size_t prefixlen = strlen(prefix);
1658 size =
sizeof(
"<MultiGeometry></MultiGeometry>") + prefixlen*2;
1660 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1661 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1663 for (i=0; i<col->
ngeoms; i++)
1665 subgeom = col->
geoms[i];
1666 size += (
sizeof(
"<geometryMember>/") + prefixlen ) * 2;
1684 lwerror(
"asgml3_collection_size: unknown geometry type");
1700 ptr += sprintf(ptr,
"<%sMultiGeometry", prefix);
1701 if (srs) ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1702 if (
id) ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id);
1706 ptr += sprintf(ptr,
"/>");
1707 return (ptr-output);
1709 ptr += sprintf(ptr,
">");
1711 for (i=0; i<col->
ngeoms; i++)
1713 subgeom = col->
geoms[i];
1714 ptr += sprintf(ptr,
"<%sgeometryMember>", prefix);
1735 lwerror(
"asgml3_collection_buf: unknown geometry type");
1737 ptr += sprintf(ptr,
"</%sgeometryMember>", prefix);
1741 ptr += sprintf(ptr,
"</%sMultiGeometry>", prefix);
1743 return (ptr-output);
1763 size_t prefixlen = strlen(prefix);
1764 size_t size =
sizeof(
"<MultiCurve></MultiCurve>" ) + 2 * prefixlen;
1765 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1766 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1770 for( i = 0; i < cur->
ngeoms; ++i )
1772 size +=
sizeof(
"<curveMember></curveMember>" ) + 2 * prefixlen;
1773 subgeom = cur->
geoms[i];
1796 ptr += sprintf(ptr,
"<%sMultiCurve", prefix );
1799 ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1803 ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id );
1805 ptr += sprintf( ptr,
">");
1807 for( i = 0; i < cur->
ngeoms; ++i )
1809 ptr += sprintf(ptr,
"<%scurveMember>", prefix );
1810 subgeom = cur->
geoms[i];
1823 ptr += sprintf(ptr,
"</%scurveMember>", prefix );
1825 ptr += sprintf(ptr,
"</%sMultiCurve>", prefix );
1826 return (ptr - output);
1840 size_t prefixlen = strlen(prefix);
1841 size_t size =
sizeof(
"<MultiSurface></MultiSurface>" ) + 2 * prefixlen;
1842 if (srs) size += strlen(srs) +
sizeof(
" srsName=..");
1843 if (
id) size += strlen(
id) + strlen(prefix) +
sizeof(
" id=..");
1847 for( i = 0; i < sur->
ngeoms; ++i )
1849 subgeom = sur->
geoms[i];
1868 ptr += sprintf( ptr,
"<%sMultiSurface", prefix );
1871 ptr += sprintf(ptr,
" srsName=\"%s\"", srs);
1875 ptr += sprintf(ptr,
" %sid=\"%s\"", prefix,
id );
1877 ptr += sprintf( ptr,
">" );
1879 for( i = 0; i < sur->
ngeoms; ++i )
1881 subgeom = sur->
geoms[i];
1891 ptr += sprintf( ptr,
"</%sMultiSurface>", prefix );
1892 return ptr - output;
1927 sprintf(x,
"%.*f", precision, pt->
x);
1929 sprintf(x,
"%g", pt->
x);
1933 sprintf(y,
"%.*f", precision, pt->
y);
1935 sprintf(y,
"%g", pt->
y);
1938 if ( i ) ptr += sprintf(ptr,
" ");
1940 ptr += sprintf(ptr,
"%s %s", y, x);
1942 ptr += sprintf(ptr,
"%s %s", x, y);
1953 sprintf(x,
"%.*f", precision, pt->
x);
1955 sprintf(x,
"%g", pt->
x);
1959 sprintf(y,
"%.*f", precision, pt->
y);
1961 sprintf(y,
"%g", pt->
y);
1965 sprintf(z,
"%.*f", precision, pt->
z);
1967 sprintf(z,
"%g", pt->
z);
1970 if ( i ) ptr += sprintf(ptr,
" ");
1972 ptr += sprintf(ptr,
"%s %s %s", y, x, z);
1974 ptr += sprintf(ptr,
"%s %s %s", x, y, z);
static size_t asgml2_point_size(const LWPOINT *point, const char *srs, int precision, const char *prefix)
static size_t asgml3_multisurface_size(const LWMSURFACE *sur, const char *srs, int precision, int opts, const char *prefix, const char *id)
char * lwgeom_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
VERSION GML 2 takes a GEOMETRY and returns a GML2 representation.
#define LW_GML_SHORTLINE
For GML3, use <LineString> rather than <Curve> for lines.
static size_t asgml3_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static char * asgml2_line(const LWLINE *line, const char *srs, int precision, const char *prefix)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
static char * asgml3_triangle(const LWTRIANGLE *triangle, const char *srs, int precision, int opts, const char *prefix, const char *id)
#define OUT_MAX_DOUBLE_PRECISION
static size_t asgml3_multicurve_buf(const LWMCURVE *cur, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
void trim_trailing_zeros(char *num)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void ptarray_free(POINTARRAY *pa)
static size_t asgml2_line_size(const LWLINE *line, const char *srs, int precision, const char *prefix)
static size_t asgml3_compound_size(const LWCOMPOUND *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_point_buf(const LWPOINT *point, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_poly_size(const LWPOLY *poly, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_line_size(const LWLINE *line, const char *srs, int precision, int opts, const char *prefix, const char *id)
#define POLYHEDRALSURFACETYPE
static size_t asgml3_curvepoly_size(const LWCURVEPOLY *poly, const char *srs, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_psurface(const LWPSURFACE *psur, const char *srs, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_point(const LWPOINT *point, const char *srs, int precision, int opts, const char *prefix, const char *id)
char * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
static size_t asgml2_multi_size(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
static size_t asgml2_poly_size(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
static size_t asgml3_multisurface_buf(const LWMSURFACE *sur, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static char * asgml2_collection(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
static size_t asgml3_tin_size(const LWTIN *tin, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml2_multi_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
static size_t asgml3_collection_size(const LWCOLLECTION *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_compound_buf(const LWCOMPOUND *col, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_triangle_size(const LWTRIANGLE *triangle, const char *srs, int precision, int opts, const char *prefix, const char *id)
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
static size_t asgml3_tin_buf(const LWTIN *tin, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_psurface_size(const LWPSURFACE *psur, const char *srs, int precision, int opts, const char *prefix, const char *id)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE, then a duplicate point will not be added.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
static char * asgml3_compound(const LWCOMPOUND *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_circstring_buf(const LWCIRCSTRING *circ, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_point_size(const LWPOINT *point, const char *srs, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_poly(const LWPOLY *poly, const char *srs, int precision, int opts, int is_patch, const char *prefix, const char *id)
#define LW_TRUE
Return types for functions with status returns.
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
static char * asgml3_multi(const LWCOLLECTION *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
int lwpoly_is_empty(const LWPOLY *poly)
static size_t asgml3_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision, int opts, int is_patch, const char *prefix, const char *id)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
static size_t asgml3_multi_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_multisurface(const LWMSURFACE *sur, const char *srs, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_multicurve(const LWMCURVE *cur, const char *srs, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_line(const LWLINE *line, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t pointArray_GMLsize(POINTARRAY *pa, int precision)
static size_t asgml3_triangle_buf(const LWTRIANGLE *triangle, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
int lwline_is_empty(const LWLINE *line)
static char * asgml3_collection(const LWCOLLECTION *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml2_point_buf(const LWPOINT *point, const char *srs, char *output, int precision, const char *prefix)
char * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, int n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
static size_t asgml3_curvepoly_buf(const LWCURVEPOLY *poly, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
int ptarray_remove_point(POINTARRAY *pa, int where)
Remove a point from an existing POINTARRAY.
static char * asgml2_point(const LWPOINT *point, const char *srs, int precision, const char *prefix)
static size_t asgml2_poly_buf(const LWPOLY *poly, const char *srs, char *output, int precision, const char *prefix)
static size_t pointArray_toGML3(POINTARRAY *pa, char *buf, int precision, int opts)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
int lwpoint_is_empty(const LWPOINT *point)
static size_t asgml2_collection_buf(const LWCOLLECTION *col, const char *srs, char *output, int precision, const char *prefix)
static size_t asgml3_circstring_size(const LWCIRCSTRING *circ, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml2_collection_size(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
static size_t pointArray_toGML2(POINTARRAY *pa, char *buf, int precision)
void * lwalloc(size_t size)
#define OUT_MAX_DIGS_DOUBLE
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
static size_t asgml2_line_buf(const LWLINE *line, const char *srs, char *output, int precision, const char *prefix)
static char * asgml2_multi(const LWCOLLECTION *col, const char *srs, int precision, const char *prefix)
static char * asgml3_curvepoly(const LWCURVEPOLY *poly, const char *srs, int precision, int opts, const char *prefix, const char *id)
#define FLAGS_NDIMS(flags)
char * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
static char * asgml2_poly(const LWPOLY *poly, const char *srs, int precision, const char *prefix)
static char * gbox_to_gml2(const GBOX *bbox, const char *srs, int precision, const char *prefix)
static size_t asgml3_multicurve_size(const LWMCURVE *cur, const char *srs, int precision, int opts, const char *prefix, const char *id)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
static size_t asgml3_multi_size(const LWCOLLECTION *col, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_line_buf(const LWLINE *line, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_tin(const LWTIN *tin, const char *srs, int precision, int opts, const char *prefix, const char *id)
static char * asgml3_circstring(const LWCIRCSTRING *circ, const char *srs, int precision, int opts, const char *prefix, const char *id)
static size_t asgml3_psurface_buf(const LWPSURFACE *psur, const char *srs, char *output, int precision, int opts, const char *prefix, const char *id)
static char * gbox_to_gml3(const GBOX *bbox, const char *srs, int precision, int opts, const char *prefix)