]> granicus.if.org Git - postgis/commitdiff
Add LW_GML_SHORTLINE flag to prefer <LineString> over <Curve> tag for lines GML3...
authorSandro Santilli <strk@keybit.net>
Tue, 22 Feb 2011 14:25:15 +0000 (14:25 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 22 Feb 2011 14:25:15 +0000 (14:25 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@6850 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/liblwgeom.h
liblwgeom/lwout_gml.c

index b06e5df66df5eb9459cc2255dd849cceb22366d0..81da1db24d0aa420096b57db36c1c87d343a9606 100644 (file)
@@ -1788,9 +1788,11 @@ extern LWCOLLECTION *lwcollection_segmentize2d(LWCOLLECTION *coll, double dist);
  * @{
  */
 /** For GML3 only, include srsDimension attribute in output */
-#define LW_GML_IS_DIMS   (1<<0)
+#define LW_GML_IS_DIMS     (1<<0)
 /** For GML3 only, declare that datas are lat/lon. Swaps axis order */
-#define LW_GML_IS_DEGREE (1<<1)
+#define LW_GML_IS_DEGREE   (1<<1)
+/** For GML3, use <LineString> rather than <Curve> for lines */
+#define LW_GML_SHORTLINE   (1<<2)
 
 #define IS_DIMS(x) ((x) & LW_GML_IS_DIMS)
 #define IS_DEGREE(x) ((x) & LW_GML_IS_DEGREE)
index 025f61cc3d99ac9df3cbb29edaca33464d5c335c..98e4918f700bd2c410a7361a9518dbe9c0ba1e31 100644 (file)
@@ -650,7 +650,20 @@ asgml3_line_size(const LWLINE *line, char *srs, int precision, int opts, const c
        size_t prefixlen = strlen(prefix);
 
        size = pointArray_GMLsize(line->points, precision);
-       size += ( sizeof("<Curve><segments><LineStringSegment><posList>/") + ( prefixlen * 4 ) ) * 2;
+       if ( opts & LW_GML_SHORTLINE )
+       {
+               size += (
+                 sizeof("<LineString><posList>/") +
+                 ( prefixlen * 2 )
+               ) * 2;
+       }
+       else
+       {
+               size += (
+                 sizeof("<Curve><segments><LineStringSegment><posList>/") +
+                 ( prefixlen * 4 )
+               ) * 2;
+       }
        if (srs)     size += strlen(srs) + sizeof(" srsName=..");
        if (IS_DIMS(opts)) size += sizeof(" srsDimension='x'");
        return size;
@@ -661,24 +674,45 @@ asgml3_line_buf(const LWLINE *line, char *srs, char *output, int precision, int
 {
        char *ptr=output;
        int dimension=2;
+       int shortline = ( opts & LW_GML_SHORTLINE );
 
        if (FLAGS_GET_Z(line->flags)) dimension = 3;
-       if ( srs )
-       {
-               ptr += sprintf(ptr, "<%sCurve srsName=\"%s\">", prefix, srs);
+
+       if ( shortline ) {
+               ptr += sprintf(ptr, "<%sLineString", prefix);
+       } else {
+               ptr += sprintf(ptr, "<%sCurve", prefix);
        }
-       else
-       {
-               ptr += sprintf(ptr, "<%sCurve>", prefix);
+
+       if ( srs ) {
+               ptr += sprintf(ptr, " srsName=\"%s\">", srs);
+       } else {
+               ptr += sprintf(ptr, ">");
        }
-       ptr += sprintf(ptr, "<%ssegments>", prefix);
-       ptr += sprintf(ptr, "<%sLineStringSegment>", prefix);
-       if (IS_DIMS(opts)) ptr += sprintf(ptr, "<%sposList srsDimension=\"%d\">", prefix, dimension);
-       else         ptr += sprintf(ptr, "<%sposList>", prefix);
+
+       if ( ! shortline ) {
+               ptr += sprintf(ptr, "<%ssegments>", prefix);
+               ptr += sprintf(ptr, "<%sLineStringSegment>", prefix);
+       }
+
+       if (IS_DIMS(opts)) {
+               ptr += sprintf(ptr, "<%sposList srsDimension=\"%d\">",
+                       prefix, dimension);
+       } else {
+               ptr += sprintf(ptr, "<%sposList>", prefix);
+       }
+
        ptr += pointArray_toGML3(line->points, ptr, precision, opts);
-       ptr += sprintf(ptr, "</%sposList></%sLineStringSegment>", prefix, prefix);
-       ptr += sprintf(ptr, "</%ssegments>", prefix);
-       ptr += sprintf(ptr, "</%sCurve>", prefix);
+
+       ptr += sprintf(ptr, "</%sposList>", prefix);
+
+       if ( shortline ) {
+               ptr += sprintf(ptr, "</%sLineString>", prefix);
+       } else {
+               ptr += sprintf(ptr, "</%sLineStringSegment>", prefix);
+               ptr += sprintf(ptr, "</%ssegments>", prefix);
+               ptr += sprintf(ptr, "</%sCurve>", prefix);
+       }
 
        return (ptr-output);
 }