PostGIS  2.1.10dev-r@@SVN_REVISION@@
cu_out_gml.c
Go to the documentation of this file.
1 /**********************************************************************
2  * $Id: cu_out_gml.c 13242 2015-02-19 00:22:22Z pramsey $
3  *
4  * PostGIS - Spatial Types for PostgreSQL
5  * http://postgis.net
6  *
7  * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU General Public Licence. See the COPYING file.
11  *
12  **********************************************************************/
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include "CUnit/Basic.h"
18 
19 #include "liblwgeom_internal.h"
20 #include "cu_tester.h"
21 
22 static void do_gml2_test(char * in, char * out, char * srs, int precision)
23 {
24  LWGEOM *g;
25  char *h;
26 
28  h = lwgeom_to_gml2(g, srs, precision, "gml:");
29 
30  if (strcmp(h, out))
31  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
32 
33  CU_ASSERT_STRING_EQUAL(h, out);
34 
35  lwgeom_free(g);
36  lwfree(h);
37 }
38 
39 static void do_gml2_test_prefix(char * in, char * out, char * srs, int precision, const char *prefix)
40 {
41  LWGEOM *g;
42  char *h;
43 
45  h = lwgeom_to_gml2(g, srs, precision, prefix);
46 
47  if (strcmp(h, out))
48  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
49 
50  CU_ASSERT_STRING_EQUAL(h, out);
51 
52  lwgeom_free(g);
53  lwfree(h);
54 }
55 
56 static void do_gml3_test_opts(char * in, char * out, char * srs, int precision, int opts)
57 {
58  LWGEOM *g;
59  char *h;
60 
62  h = lwgeom_to_gml3(g, srs, precision, opts, "gml:", NULL);
63 
64  if (strcmp(h, out))
65  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
66 
67  CU_ASSERT_STRING_EQUAL(h, out);
68 
69  lwgeom_free(g);
70  lwfree(h);
71 }
72 
73 static void do_gml3_test(char * in, char * out, char * srs, int precision, int is_geodetic)
74 {
75  LWGEOM *g;
76  char *h;
77  int opts = LW_GML_IS_DIMS;
78  if ( is_geodetic ) opts |= LW_GML_IS_DEGREE;
79 
81  h = lwgeom_to_gml3(g, srs, precision, opts, "gml:", NULL);
82 
83  if (strcmp(h, out))
84  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
85 
86  CU_ASSERT_STRING_EQUAL(h, out);
87 
88  lwgeom_free(g);
89  lwfree(h);
90 }
91 
92 static void do_gml3_test_prefix(char * in, char * out, char * srs, int precision, int is_geodetic, const char *prefix)
93 {
94  LWGEOM *g;
95  char *h;
96  int opts = LW_GML_IS_DIMS;
97 
98  if ( is_geodetic ) opts |= LW_GML_IS_DEGREE;
99 
101  h = lwgeom_to_gml3(g, srs, precision, opts, prefix, NULL);
102 
103  if (strcmp(h, out))
104  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
105 
106  CU_ASSERT_STRING_EQUAL(h, out);
107 
108  lwgeom_free(g);
109  lwfree(h);
110 }
111 
112 static void do_gml3_test_nodims(char * in, char * out, char * srs, int precision, int is_geodetic, int is_dims, const char *prefix)
113 {
114  LWGEOM *g;
115  char *h;
116  int opts = 0;
117 
118  if ( is_geodetic ) opts |= LW_GML_IS_DEGREE;
119  if ( is_dims ) opts |= LW_GML_IS_DIMS;
120 
122  h = lwgeom_to_gml3(g, srs, precision, opts, prefix, NULL);
123 
124  if (strcmp(h, out))
125  fprintf(stderr, "\nIn: %s\nOut: %s\nTheo: %s\n", in, h, out);
126 
127  CU_ASSERT_STRING_EQUAL(h, out);
128 
129  lwgeom_free(g);
130  lwfree(h);
131 }
132 
133 static void do_gml2_unsupported(char * in, char * out)
134 {
135  LWGEOM *g;
136  char *h;
137 
139  h = lwgeom_to_gml2(g, NULL, 0, "");
140 
141  if (strcmp(cu_error_msg, out))
142  fprintf(stderr, "\nGML 2 - In: %s\nOut: %s\nTheo: %s\n",
143  in, cu_error_msg, out);
144  CU_ASSERT_STRING_EQUAL(out, cu_error_msg);
146 
147  lwfree(h);
148  lwgeom_free(g);
149 }
150 
151 static void do_gml3_unsupported(char * in, char * out)
152 {
153  LWGEOM *g;
154  char *h;
155  int opts = LW_GML_IS_DIMS;
156 
158  h = lwgeom_to_gml3(g, NULL, 0, opts, "", NULL);
159 
160  if (strcmp(cu_error_msg, out))
161  fprintf(stderr, "\nGML 3 - In: %s\nOut: %s\nTheo: %s\n",
162  in, cu_error_msg, out);
163 
164  CU_ASSERT_STRING_EQUAL(out, cu_error_msg);
166 
167  lwfree(h);
168  lwgeom_free(g);
169 }
170 
171 static void do_gml2_extent_test(char * in, char * out, char * srs,
172  double precision, char * prefix)
173 {
174  LWGEOM *g;
175  char *h;
176 
178  h = lwgeom_extent_to_gml2(g, srs, precision, prefix);
179  if ( ! h ) h = strdup(cu_error_msg);
180 
181  if (strcmp(h, out))
182  fprintf(stderr, "\nEXT GML 2 - In: %s\nObt: %s\nExp: %s\n",
183  in, h, out);
184  CU_ASSERT_STRING_EQUAL(out, h);
186 
187  lwfree(h);
188  lwgeom_free(g);
189 }
190 
191 static void do_gml3_extent_test(char * in, char * out, char * srs,
192  double precision, int opts, char* prefix)
193 {
194  LWGEOM *g;
195  char *h;
196 
198  h = lwgeom_extent_to_gml3(g, srs, precision, opts, prefix);
199  if ( ! h ) h = strdup(cu_error_msg);
200 
201  if (strcmp(h, out))
202  fprintf(stderr, "\nEXT GML 3 - In: %s\nObt: %s\nExp: %s\n",
203  in, h, out);
204  CU_ASSERT_STRING_EQUAL(out, h);
206 
207  lwfree(h);
208  lwgeom_free(g);
209 }
210 
211 static void out_gml_test_precision(void)
212 {
213  /* GML2 - 0 precision, i.e a round */
214  do_gml2_test(
215  "POINT(1.1111111111111 1.1111111111111)",
216  "<gml:Point><gml:coordinates>1,1</gml:coordinates></gml:Point>",
217  NULL, 0);
218 
219  /* GML3 - 0 precision, i.e a round */
220  do_gml3_test(
221  "POINT(1.1111111111111 1.1111111111111)",
222  "<gml:Point><gml:pos srsDimension=\"2\">1 1</gml:pos></gml:Point>",
223  NULL, 0, 0);
224 
225 
226  /* GML2 - 3 digits precision */
227  do_gml2_test(
228  "POINT(1.1111111111111 1.1111111111111)",
229  "<gml:Point><gml:coordinates>1.111,1.111</gml:coordinates></gml:Point>",
230  NULL, 3);
231 
232  /* GML3 - 3 digits precision */
233  do_gml3_test(
234  "POINT(1.1111111111111 1.1111111111111)",
235  "<gml:Point><gml:pos srsDimension=\"2\">1.111 1.111</gml:pos></gml:Point>",
236  NULL, 3, 0);
237 
238 
239  /* GML2 - 9 digits precision */
240  do_gml2_test(
241  "POINT(1.2345678901234 1.2345678901234)",
242  "<gml:Point><gml:coordinates>1.23456789,1.23456789</gml:coordinates></gml:Point>",
243  NULL, 9);
244 
245  /* GML3 - 9 digits precision */
246  do_gml3_test(
247  "POINT(1.2345678901234 1.2345678901234)",
248  "<gml:Point><gml:pos srsDimension=\"2\">1.23456789 1.23456789</gml:pos></gml:Point>",
249  NULL, 9, 0);
250 
251 
252  /* GML2 - huge data */
253  do_gml2_test(
254  "POINT(1E300 -1E300)",
255  "<gml:Point><gml:coordinates>1e+300,-1e+300</gml:coordinates></gml:Point>",
256  NULL, 0);
257 
258  /* GML3 - huge data */
259  do_gml3_test(
260  "POINT(1E300 -1E300)",
261  "<gml:Point><gml:pos srsDimension=\"2\">1e+300 -1e+300</gml:pos></gml:Point>",
262  NULL, 0, 0);
263 }
264 
265 static void out_gml_test_srid(void)
266 {
267  /* GML2 - Point with SRID */
268  do_gml2_test(
269  "POINT(0 1)",
270  "<gml:Point srsName=\"EPSG:4326\"><gml:coordinates>0,1</gml:coordinates></gml:Point>",
271  "EPSG:4326", 0);
272 
273  /* GML3 - Point with SRID */
274  do_gml3_test(
275  "POINT(0 1)",
276  "<gml:Point srsName=\"EPSG:4326\"><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point>",
277  "EPSG:4326", 0, 0);
278 
279 
280  /* GML2 - Linestring with SRID */
281  do_gml2_test(
282  "LINESTRING(0 1,2 3,4 5)",
283  "<gml:LineString srsName=\"EPSG:4326\"><gml:coordinates>0,1 2,3 4,5</gml:coordinates></gml:LineString>",
284  "EPSG:4326", 0);
285 
286  /* GML3 - Linestring with SRID */
287  do_gml3_test(
288  "LINESTRING(0 1,2 3,4 5)",
289  "<gml:Curve srsName=\"EPSG:4326\"><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">0 1 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve>",
290  "EPSG:4326", 0, 0);
291 
292  /* GML3 - Linestring with SRID and short tag*/
294  "LINESTRING(0 1,2 3,4 5)",
295  "<gml:LineString srsName=\"EPSG:4326\"><gml:posList>0 1 2 3 4 5</gml:posList></gml:LineString>",
296  "EPSG:4326", 0, LW_GML_SHORTLINE);
297 
298 
299  /* GML2 Polygon with SRID */
300  do_gml2_test(
301  "POLYGON((0 1,2 3,4 5,0 1))",
302  "<gml:Polygon srsName=\"EPSG:4326\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,1 2,3 4,5 0,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>",
303  "EPSG:4326", 0);
304 
305  /* GML3 Polygon with SRID */
306  do_gml3_test(
307  "POLYGON((0 1,2 3,4 5,0 1))",
308  "<gml:Polygon srsName=\"EPSG:4326\"><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>",
309  "EPSG:4326", 0, 0);
310 
311 
312  /* GML2 MultiPoint with SRID */
313  do_gml2_test(
314  "MULTIPOINT(0 1,2 3)",
315  "<gml:MultiPoint srsName=\"EPSG:4326\"><gml:pointMember><gml:Point><gml:coordinates>0,1</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>2,3</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>",
316  "EPSG:4326", 0);
317 
318  /* GML3 MultiPoint with SRID */
319  do_gml3_test(
320  "MULTIPOINT(0 1,2 3)",
321  "<gml:MultiPoint srsName=\"EPSG:4326\"><gml:pointMember><gml:Point><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension=\"2\">2 3</gml:pos></gml:Point></gml:pointMember></gml:MultiPoint>",
322  "EPSG:4326", 0, 0);
323 
324 
325  /* GML2 Multiline with SRID */
326  do_gml2_test(
327  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
328  "<gml:MultiLineString srsName=\"EPSG:4326\"><gml:lineStringMember><gml:LineString><gml:coordinates>0,1 2,3 4,5</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates>6,7 8,9 10,11</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>",
329  "EPSG:4326", 0);
330 
331 
332  /* GML3 Multiline with SRID */
333  do_gml3_test(
334  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
335  "<gml:MultiCurve srsName=\"EPSG:4326\"><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">0 1 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">6 7 8 9 10 11</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve>",
336  "EPSG:4326", 0, 0);
337 
338  /* GML3 Multiline with SRID and LineString tag */
340  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
341  "<gml:MultiCurve srsName=\"EPSG:4326\"><gml:curveMember><gml:LineString><gml:posList>0 1 2 3 4 5</gml:posList></gml:LineString></gml:curveMember><gml:curveMember><gml:LineString><gml:posList>6 7 8 9 10 11</gml:posList></gml:LineString></gml:curveMember></gml:MultiCurve>",
342  "EPSG:4326", 0, LW_GML_SHORTLINE);
343 
344 
345  /* GML2 MultiPolygon with SRID */
346  do_gml2_test(
347  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
348  "<gml:MultiPolygon srsName=\"EPSG:4326\"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,1 2,3 4,5 0,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,7 8,9 10,11 6,7</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>",
349  "EPSG:4326", 0);
350 
351  /* GML3 MultiPolygon with SRID */
352  do_gml3_test(
353  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
354  "<gml:MultiSurface srsName=\"EPSG:4326\"><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface>",
355  "EPSG:4326", 0, 0);
356 
357  /* GML3 PolyhedralSurface with SRID */
358  do_gml3_test(
359  "POLYHEDRALSURFACE(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
360  "<gml:PolyhedralSurface srsName=\"EPSG:4326\"><gml:polygonPatches><gml:PolygonPatch><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:PolygonPatch><gml:PolygonPatch><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</gml:posList></gml:LinearRing></gml:exterior></gml:PolygonPatch></gml:polygonPatches></gml:PolyhedralSurface>",
361  "EPSG:4326", 0, 0);
362 
363  /* GML3 Tin with SRID */
364  do_gml3_test(
365  "TIN(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
366  "<gml:Tin srsName=\"EPSG:4326\"><gml:trianglePatches><gml:Triangle><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:Triangle><gml:Triangle><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</gml:posList></gml:LinearRing></gml:exterior></gml:Triangle></gml:trianglePatches></gml:Tin>",
367  "EPSG:4326", 0, 0);
368 
369 
370  /* GML2 GeometryCollection with SRID */
371  do_gml2_test(
372  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
373  "<gml:MultiGeometry srsName=\"EPSG:4326\"><gml:geometryMember><gml:Point><gml:coordinates>0,1</gml:coordinates></gml:Point></gml:geometryMember><gml:geometryMember><gml:LineString><gml:coordinates>2,3 4,5</gml:coordinates></gml:LineString></gml:geometryMember></gml:MultiGeometry>",
374  "EPSG:4326", 0);
375 
376  /* GML3 GeometryCollection with SRID */
377  do_gml3_test(
378  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
379  "<gml:MultiGeometry srsName=\"EPSG:4326\"><gml:geometryMember><gml:Point><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point></gml:geometryMember><gml:geometryMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:geometryMember></gml:MultiGeometry>",
380  "EPSG:4326", 0, 0);
381 }
382 
383 
384 static void out_gml_test_geodetic(void)
385 {
386  /* GML3 - Geodetic Point */
387  do_gml3_test(
388  "POINT(0 1)",
389  "<gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\"><gml:pos srsDimension=\"2\">1 0</gml:pos></gml:Point>",
390  "urn:ogc:def:crs:EPSG::4326", 0, 1);
391 
392  /* GML3 - 3D Geodetic Point */
393  do_gml3_test(
394  "POINT(0 1 2)",
395  "<gml:Point srsName=\"urn:ogc:def:crs:EPSG::4326\"><gml:pos srsDimension=\"3\">1 0 2</gml:pos></gml:Point>",
396  "urn:ogc:def:crs:EPSG::4326", 0, 1);
397 }
398 
399 
400 static void out_gml_test_dims(void)
401 {
402  /* GML2 - 3D */
403  do_gml2_test(
404  "POINT(0 1 2)",
405  "<gml:Point><gml:coordinates>0,1,2</gml:coordinates></gml:Point>",
406  NULL, 0);
407 
408  /* GML3 - 3D */
409  do_gml3_test(
410  "POINT(0 1 2)",
411  "<gml:Point><gml:pos srsDimension=\"3\">0 1 2</gml:pos></gml:Point>",
412  NULL, 0, 0);
413 
414 
415  /* GML2 - 3DM */
416  do_gml2_test(
417  "POINTM(0 1 2)",
418  "<gml:Point><gml:coordinates>0,1</gml:coordinates></gml:Point>",
419  NULL, 0);
420 
421  /* GML3 - 3DM */
422  do_gml3_test(
423  "POINTM(0 1 2)",
424  "<gml:Point><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point>",
425  NULL, 0, 0);
426 
427 
428  /* GML2 - 4D */
429  do_gml2_test(
430  "POINT(0 1 2 3)",
431  "<gml:Point><gml:coordinates>0,1,2</gml:coordinates></gml:Point>",
432  NULL, 0);
433 
434  /* GML3 - 4D */
435  do_gml3_test(
436  "POINT(0 1 2 3)",
437  "<gml:Point><gml:pos srsDimension=\"3\">0 1 2</gml:pos></gml:Point>",
438  NULL, 0, 0);
439 }
440 
441 
442 static void out_gml_test_geoms(void)
443 {
444  /* GML2 - Linestring */
445  do_gml2_test(
446  "LINESTRING(0 1,2 3,4 5)",
447  "<gml:LineString><gml:coordinates>0,1 2,3 4,5</gml:coordinates></gml:LineString>",
448  NULL, 0);
449 
450  /* GML3 - Linestring */
451  do_gml3_test(
452  "LINESTRING(0 1,2 3,4 5)",
453  "<gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">0 1 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve>",
454  NULL, 0, 0);
455 
456 
457  /* GML2 Polygon */
458  do_gml2_test(
459  "POLYGON((0 1,2 3,4 5,0 1))",
460  "<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,1 2,3 4,5 0,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>",
461  NULL, 0);
462 
463  /* GML3 Polygon */
464  do_gml3_test(
465  "POLYGON((0 1,2 3,4 5,0 1))",
466  "<gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon>",
467  NULL, 0, 0);
468 
469  /* GML2 Polygon - with internal ring */
470  do_gml2_test(
471  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
472  "<gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,1 2,3 4,5 0,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>6,7 8,9 10,11 6,7</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>",
473  NULL, 0);
474 
475  /* GML3 Polygon - with internal ring */
476  do_gml3_test(
477  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
478  "<gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior><gml:interior><gml:LinearRing><gml:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</gml:posList></gml:LinearRing></gml:interior></gml:Polygon>",
479  NULL, 0, 0);
480 
481 
482  /* GML3 Triangle */
483  do_gml3_test(
484  "TRIANGLE((0 1,2 3,4 5,0 1))",
485  "<gml:Triangle><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:Triangle>",
486  NULL, 0, 0);
487 
488 
489  /* GML2 MultiPoint */
490  do_gml2_test(
491  "MULTIPOINT(0 1,2 3)",
492  "<gml:MultiPoint><gml:pointMember><gml:Point><gml:coordinates>0,1</gml:coordinates></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:coordinates>2,3</gml:coordinates></gml:Point></gml:pointMember></gml:MultiPoint>",
493  NULL, 0);
494 
495  /* GML3 MultiPoint */
496  do_gml3_test(
497  "MULTIPOINT(0 1,2 3)",
498  "<gml:MultiPoint><gml:pointMember><gml:Point><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point></gml:pointMember><gml:pointMember><gml:Point><gml:pos srsDimension=\"2\">2 3</gml:pos></gml:Point></gml:pointMember></gml:MultiPoint>",
499  NULL, 0, 0);
500 
501 
502  /* GML2 Multiline */
503  do_gml2_test(
504  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
505  "<gml:MultiLineString><gml:lineStringMember><gml:LineString><gml:coordinates>0,1 2,3 4,5</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString><gml:coordinates>6,7 8,9 10,11</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>",
506  NULL, 0);
507 
508  /* GML3 Multiline */
509  do_gml3_test(
510  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
511  "<gml:MultiCurve><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">0 1 2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember><gml:curveMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">6 7 8 9 10 11</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:curveMember></gml:MultiCurve>",
512  NULL, 0, 0);
513 
514 
515  /* GML2 MultiPolygon */
516  do_gml2_test(
517  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
518  "<gml:MultiPolygon><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>0,1 2,3 4,5 0,1</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>6,7 8,9 10,11 6,7</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>",
519  NULL, 0);
520 
521  /* GML3 MultiPolygon */
522  do_gml3_test(
523  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
524  "<gml:MultiSurface><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember><gml:surfaceMember><gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</gml:posList></gml:LinearRing></gml:exterior></gml:Polygon></gml:surfaceMember></gml:MultiSurface>",
525  NULL, 0, 0);
526 
527 
528  /* GML2 - GeometryCollection */
529  do_gml2_test(
530  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
531  "<gml:MultiGeometry><gml:geometryMember><gml:Point><gml:coordinates>0,1</gml:coordinates></gml:Point></gml:geometryMember><gml:geometryMember><gml:LineString><gml:coordinates>2,3 4,5</gml:coordinates></gml:LineString></gml:geometryMember></gml:MultiGeometry>",
532  NULL, 0);
533 
534  /* GML3 - GeometryCollection */
535  do_gml3_test(
536  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
537  "<gml:MultiGeometry><gml:geometryMember><gml:Point><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point></gml:geometryMember><gml:geometryMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:geometryMember></gml:MultiGeometry>",
538  NULL, 0, 0);
539 
540 
541  /* GML2 - Nested GeometryCollection */
542  do_gml2_test(
543  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
544  "<gml:MultiGeometry><gml:geometryMember><gml:Point><gml:coordinates>0,1</gml:coordinates></gml:Point></gml:geometryMember><gml:geometryMember><gml:MultiGeometry><gml:geometryMember><gml:LineString><gml:coordinates>2,3 4,5</gml:coordinates></gml:LineString></gml:geometryMember></gml:MultiGeometry></gml:geometryMember></gml:MultiGeometry>",
545  NULL, 0);
546 
547  /* GML3 - Nested GeometryCollection */
548  do_gml3_test(
549  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
550  "<gml:MultiGeometry><gml:geometryMember><gml:Point><gml:pos srsDimension=\"2\">0 1</gml:pos></gml:Point></gml:geometryMember><gml:geometryMember><gml:MultiGeometry><gml:geometryMember><gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension=\"2\">2 3 4 5</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve></gml:geometryMember></gml:MultiGeometry></gml:geometryMember></gml:MultiGeometry>",
551  NULL, 0, 0);
552 
553 
554 
555  /* GML2 - CircularString */
557  "CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)",
558  "lwgeom_to_gml2: 'CircularString' geometry type not supported");
559  /* GML3 - CircularString */
561  "CIRCULARSTRING(-2 0,0 2,2 0,0 2,2 4)",
562  "lwgeom_to_gml3: 'CircularString' geometry type not supported");
563 
564  /* GML2 - CompoundCurve */
566  "COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))",
567  "lwgeom_to_gml2: 'CompoundCurve' geometry type not supported");
568  /* GML3 - CompoundCurve */
570  "COMPOUNDCURVE(CIRCULARSTRING(0 0,1 1,1 0),(1 0,0 1))",
571  "lwgeom_to_gml3: 'CompoundCurve' geometry type not supported");
572 
573  /* GML2 - CurvePolygon */
575  "CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))",
576  "lwgeom_to_gml2: 'CurvePolygon' geometry type not supported");
577 
578  /* GML3 - CurvePolygon */
580  "CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0))",
581  "lwgeom_to_gml3: 'CurvePolygon' geometry type not supported");
582 
583 
584  /* GML2 - MultiCurve */
586  "MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))",
587  "lwgeom_to_gml2: 'MultiCurve' geometry type not supported");
588 
589  /* GML3 - MultiCurve */
591  "MULTICURVE((5 5,3 5,3 3,0 3),CIRCULARSTRING(0 0,2 1,2 2))",
592  "lwgeom_to_gml3: 'MultiCurve' geometry type not supported");
593 
594  /* GML2 - MultiSurface */
596  "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
597  "lwgeom_to_gml2: 'MultiSurface' geometry type not supported");
598 
599  /* GML3 - MultiSurface */
601  "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
602  "lwgeom_to_gml3: 'MultiSurface' geometry type not supported");
603 
604  /* GML2 - PolyhedralSurface */
606  "POLYHEDRALSURFACE(((0 1,2 3,4 5,0 1)))",
607  "Cannot convert PolyhedralSurface to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.");
608 
609  /* GML2 - Tin */
611  "TIN(((0 1,2 3,4 5,0 1)))",
612  "Cannot convert Tin to GML2. Try ST_AsGML(3, <geometry>) to generate GML3.");
613 }
614 
615 static void out_gml_test_geoms_prefix(void)
616 {
617  /* GML2 - Linestring */
619  "LINESTRING(0 1,2 3,4 5)",
620  "<custom:LineString><custom:coordinates>0,1 2,3 4,5</custom:coordinates></custom:LineString>",
621  NULL, 0, "custom:");
622 
623  /* GML3 - Linestring */
625  "LINESTRING(0 1,2 3,4 5)",
626  "<custom:Curve><custom:segments><custom:LineStringSegment><custom:posList srsDimension=\"2\">0 1 2 3 4 5</custom:posList></custom:LineStringSegment></custom:segments></custom:Curve>",
627  NULL, 0, 0, "custom:");
628 
629 
630  /* GML2 Polygon */
632  "POLYGON((0 1,2 3,4 5,0 1))",
633  "<custom:Polygon><custom:outerBoundaryIs><custom:LinearRing><custom:coordinates>0,1 2,3 4,5 0,1</custom:coordinates></custom:LinearRing></custom:outerBoundaryIs></custom:Polygon>",
634  NULL, 0, "custom:");
635 
636  /* GML3 Polygon */
638  "POLYGON((0 1,2 3,4 5,0 1))",
639  "<custom:Polygon><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</custom:posList></custom:LinearRing></custom:exterior></custom:Polygon>",
640  NULL, 0, 0, "custom:");
641 
642 
643  /* GML2 Polygon - with internal ring */
645  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
646  "<custom:Polygon><custom:outerBoundaryIs><custom:LinearRing><custom:coordinates>0,1 2,3 4,5 0,1</custom:coordinates></custom:LinearRing></custom:outerBoundaryIs><custom:innerBoundaryIs><custom:LinearRing><custom:coordinates>6,7 8,9 10,11 6,7</custom:coordinates></custom:LinearRing></custom:innerBoundaryIs></custom:Polygon>",
647  NULL, 0, "custom:");
648 
649  /* GML3 Polygon - with internal ring */
651  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
652  "<custom:Polygon><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</custom:posList></custom:LinearRing></custom:exterior><custom:interior><custom:LinearRing><custom:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</custom:posList></custom:LinearRing></custom:interior></custom:Polygon>",
653  NULL, 0, 0, "custom:");
654 
655  /* GML3 Triangle */
657  "TRIANGLE((0 1,2 3,4 5,0 1))",
658  "<custom:Triangle><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</custom:posList></custom:LinearRing></custom:exterior></custom:Triangle>",
659  NULL, 0, 0, "custom:");
660 
661 
662  /* GML2 MultiPoint */
664  "MULTIPOINT(0 1,2 3)",
665  "<custom:MultiPoint><custom:pointMember><custom:Point><custom:coordinates>0,1</custom:coordinates></custom:Point></custom:pointMember><custom:pointMember><custom:Point><custom:coordinates>2,3</custom:coordinates></custom:Point></custom:pointMember></custom:MultiPoint>",
666  NULL, 0, "custom:");
667 
668  /* GML3 MultiPoint */
670  "MULTIPOINT(0 1,2 3)",
671  "<custom:MultiPoint><custom:pointMember><custom:Point><custom:pos srsDimension=\"2\">0 1</custom:pos></custom:Point></custom:pointMember><custom:pointMember><custom:Point><custom:pos srsDimension=\"2\">2 3</custom:pos></custom:Point></custom:pointMember></custom:MultiPoint>",
672  NULL, 0, 0, "custom:");
673 
674 
675  /* GML2 Multiline */
677  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
678  "<custom:MultiLineString><custom:lineStringMember><custom:LineString><custom:coordinates>0,1 2,3 4,5</custom:coordinates></custom:LineString></custom:lineStringMember><custom:lineStringMember><custom:LineString><custom:coordinates>6,7 8,9 10,11</custom:coordinates></custom:LineString></custom:lineStringMember></custom:MultiLineString>",
679  NULL, 0, "custom:");
680 
681  /* GML3 Multiline */
683  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
684  "<custom:MultiCurve><custom:curveMember><custom:Curve><custom:segments><custom:LineStringSegment><custom:posList srsDimension=\"2\">0 1 2 3 4 5</custom:posList></custom:LineStringSegment></custom:segments></custom:Curve></custom:curveMember><custom:curveMember><custom:Curve><custom:segments><custom:LineStringSegment><custom:posList srsDimension=\"2\">6 7 8 9 10 11</custom:posList></custom:LineStringSegment></custom:segments></custom:Curve></custom:curveMember></custom:MultiCurve>",
685  NULL, 0, 0, "custom:");
686 
687 
688  /* GML2 MultiPolygon */
690  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
691  "<custom:MultiPolygon><custom:polygonMember><custom:Polygon><custom:outerBoundaryIs><custom:LinearRing><custom:coordinates>0,1 2,3 4,5 0,1</custom:coordinates></custom:LinearRing></custom:outerBoundaryIs></custom:Polygon></custom:polygonMember><custom:polygonMember><custom:Polygon><custom:outerBoundaryIs><custom:LinearRing><custom:coordinates>6,7 8,9 10,11 6,7</custom:coordinates></custom:LinearRing></custom:outerBoundaryIs></custom:Polygon></custom:polygonMember></custom:MultiPolygon>",
692  NULL, 0, "custom:");
693 
694  /* GML3 MultiPolygon */
696  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
697  "<custom:MultiSurface><custom:surfaceMember><custom:Polygon><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</custom:posList></custom:LinearRing></custom:exterior></custom:Polygon></custom:surfaceMember><custom:surfaceMember><custom:Polygon><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</custom:posList></custom:LinearRing></custom:exterior></custom:Polygon></custom:surfaceMember></custom:MultiSurface>",
698  NULL, 0, 0, "custom:");
699 
700  /* GML3 PolyhedralSurface */
702  "POLYHEDRALSURFACE(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
703  "<custom:PolyhedralSurface><custom:polygonPatches><custom:PolygonPatch><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</custom:posList></custom:LinearRing></custom:exterior></custom:PolygonPatch><custom:PolygonPatch><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</custom:posList></custom:LinearRing></custom:exterior></custom:PolygonPatch></custom:polygonPatches></custom:PolyhedralSurface>",
704  NULL, 0, 0, "custom:");
705 
706  /* GML3 Tin */
708  "TIN(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
709  "<custom:Tin><custom:trianglePatches><custom:Triangle><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">0 1 2 3 4 5 0 1</custom:posList></custom:LinearRing></custom:exterior></custom:Triangle><custom:Triangle><custom:exterior><custom:LinearRing><custom:posList srsDimension=\"2\">6 7 8 9 10 11 6 7</custom:posList></custom:LinearRing></custom:exterior></custom:Triangle></custom:trianglePatches></custom:Tin>",
710  NULL, 0, 0, "custom:");
711 
712  /* GML2 - GeometryCollection */
714  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
715  "<custom:MultiGeometry><custom:geometryMember><custom:Point><custom:coordinates>0,1</custom:coordinates></custom:Point></custom:geometryMember><custom:geometryMember><custom:LineString><custom:coordinates>2,3 4,5</custom:coordinates></custom:LineString></custom:geometryMember></custom:MultiGeometry>",
716  NULL, 0, "custom:");
717 
718  /* GML3 - GeometryCollection */
720  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
721  "<custom:MultiGeometry><custom:geometryMember><custom:Point><custom:pos srsDimension=\"2\">0 1</custom:pos></custom:Point></custom:geometryMember><custom:geometryMember><custom:Curve><custom:segments><custom:LineStringSegment><custom:posList srsDimension=\"2\">2 3 4 5</custom:posList></custom:LineStringSegment></custom:segments></custom:Curve></custom:geometryMember></custom:MultiGeometry>",
722  NULL, 0, 0, "custom:");
723 
724  /* GML2 - Nested GeometryCollection */
726  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
727  "<custom:MultiGeometry><custom:geometryMember><custom:Point><custom:coordinates>0,1</custom:coordinates></custom:Point></custom:geometryMember><custom:geometryMember><custom:MultiGeometry><custom:geometryMember><custom:LineString><custom:coordinates>2,3 4,5</custom:coordinates></custom:LineString></custom:geometryMember></custom:MultiGeometry></custom:geometryMember></custom:MultiGeometry>",
728  NULL, 0, "custom:");
729 
730  /* GML3 - Nested GeometryCollection */
732  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
733  "<custom:MultiGeometry><custom:geometryMember><custom:Point><custom:pos srsDimension=\"2\">0 1</custom:pos></custom:Point></custom:geometryMember><custom:geometryMember><custom:MultiGeometry><custom:geometryMember><custom:Curve><custom:segments><custom:LineStringSegment><custom:posList srsDimension=\"2\">2 3 4 5</custom:posList></custom:LineStringSegment></custom:segments></custom:Curve></custom:geometryMember></custom:MultiGeometry></custom:geometryMember></custom:MultiGeometry>",
734  NULL, 0, 0, "custom:");
735 
736  /*------------- empty prefixes below ------------------------ */
737 
738  /* GML2 - Linestring */
740  "LINESTRING(0 1,2 3,4 5)",
741  "<LineString><coordinates>0,1 2,3 4,5</coordinates></LineString>",
742  NULL, 0, "");
743 
744  /* GML3 - Linestring */
746  "LINESTRING(0 1,2 3,4 5)",
747  "<Curve><segments><LineStringSegment><posList srsDimension=\"2\">0 1 2 3 4 5</posList></LineStringSegment></segments></Curve>",
748  NULL, 0, 0, "");
749 
750 
751  /* GML2 Polygon */
753  "POLYGON((0 1,2 3,4 5,0 1))",
754  "<Polygon><outerBoundaryIs><LinearRing><coordinates>0,1 2,3 4,5 0,1</coordinates></LinearRing></outerBoundaryIs></Polygon>",
755  NULL, 0, "");
756 
757  /* GML3 Polygon */
759  "POLYGON((0 1,2 3,4 5,0 1))",
760  "<Polygon><exterior><LinearRing><posList srsDimension=\"2\">0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Polygon>",
761  NULL, 0, 0, "");
762 
763 
764  /* GML2 Polygon - with internal ring */
766  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
767  "<Polygon><outerBoundaryIs><LinearRing><coordinates>0,1 2,3 4,5 0,1</coordinates></LinearRing></outerBoundaryIs><innerBoundaryIs><LinearRing><coordinates>6,7 8,9 10,11 6,7</coordinates></LinearRing></innerBoundaryIs></Polygon>",
768  NULL, 0, "");
769 
770  /* GML3 Polygon - with internal ring */
772  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
773  "<Polygon><exterior><LinearRing><posList srsDimension=\"2\">0 1 2 3 4 5 0 1</posList></LinearRing></exterior><interior><LinearRing><posList srsDimension=\"2\">6 7 8 9 10 11 6 7</posList></LinearRing></interior></Polygon>",
774  NULL, 0, 0, "");
775 
776  /* GML3 Triangle */
778  "TRIANGLE((0 1,2 3,4 5,0 1))",
779  "<Triangle><exterior><LinearRing><posList srsDimension=\"2\">0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Triangle>",
780  NULL, 0, 0, "");
781 
782 
783  /* GML2 MultiPoint */
785  "MULTIPOINT(0 1,2 3)",
786  "<MultiPoint><pointMember><Point><coordinates>0,1</coordinates></Point></pointMember><pointMember><Point><coordinates>2,3</coordinates></Point></pointMember></MultiPoint>",
787  NULL, 0, "");
788 
789  /* GML3 MultiPoint */
791  "MULTIPOINT(0 1,2 3)",
792  "<MultiPoint><pointMember><Point><pos srsDimension=\"2\">0 1</pos></Point></pointMember><pointMember><Point><pos srsDimension=\"2\">2 3</pos></Point></pointMember></MultiPoint>",
793  NULL, 0, 0, "");
794 
795 
796  /* GML2 Multiline */
798  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
799  "<MultiLineString><lineStringMember><LineString><coordinates>0,1 2,3 4,5</coordinates></LineString></lineStringMember><lineStringMember><LineString><coordinates>6,7 8,9 10,11</coordinates></LineString></lineStringMember></MultiLineString>",
800  NULL, 0, "");
801 
802  /* GML3 Multiline */
804  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
805  "<MultiCurve><curveMember><Curve><segments><LineStringSegment><posList srsDimension=\"2\">0 1 2 3 4 5</posList></LineStringSegment></segments></Curve></curveMember><curveMember><Curve><segments><LineStringSegment><posList srsDimension=\"2\">6 7 8 9 10 11</posList></LineStringSegment></segments></Curve></curveMember></MultiCurve>",
806  NULL, 0, 0, "");
807 
808 
809  /* GML2 MultiPolygon */
811  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
812  "<MultiPolygon><polygonMember><Polygon><outerBoundaryIs><LinearRing><coordinates>0,1 2,3 4,5 0,1</coordinates></LinearRing></outerBoundaryIs></Polygon></polygonMember><polygonMember><Polygon><outerBoundaryIs><LinearRing><coordinates>6,7 8,9 10,11 6,7</coordinates></LinearRing></outerBoundaryIs></Polygon></polygonMember></MultiPolygon>",
813  NULL, 0, "");
814 
815  /* GML3 MultiPolygon */
817  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
818  "<MultiSurface><surfaceMember><Polygon><exterior><LinearRing><posList srsDimension=\"2\">0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Polygon></surfaceMember><surfaceMember><Polygon><exterior><LinearRing><posList srsDimension=\"2\">6 7 8 9 10 11 6 7</posList></LinearRing></exterior></Polygon></surfaceMember></MultiSurface>",
819  NULL, 0, 0, "");
820 
821  /* GML3 PolyhedralSurface */
823  "POLYHEDRALSURFACE(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
824  "<PolyhedralSurface><polygonPatches><PolygonPatch><exterior><LinearRing><posList srsDimension=\"2\">0 1 2 3 4 5 0 1</posList></LinearRing></exterior></PolygonPatch><PolygonPatch><exterior><LinearRing><posList srsDimension=\"2\">6 7 8 9 10 11 6 7</posList></LinearRing></exterior></PolygonPatch></polygonPatches></PolyhedralSurface>",
825  NULL, 0, 0, "");
826 
827  /* GML3 PolyhedralSurface */
829  "TIN(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
830  "<Tin><trianglePatches><Triangle><exterior><LinearRing><posList srsDimension=\"2\">0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Triangle><Triangle><exterior><LinearRing><posList srsDimension=\"2\">6 7 8 9 10 11 6 7</posList></LinearRing></exterior></Triangle></trianglePatches></Tin>",
831  NULL, 0, 0, "");
832 
833  /* GML2 - GeometryCollection */
835  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
836  "<MultiGeometry><geometryMember><Point><coordinates>0,1</coordinates></Point></geometryMember><geometryMember><LineString><coordinates>2,3 4,5</coordinates></LineString></geometryMember></MultiGeometry>",
837  NULL, 0, "");
838 
839  /* GML3 - GeometryCollection */
841  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
842  "<MultiGeometry><geometryMember><Point><pos srsDimension=\"2\">0 1</pos></Point></geometryMember><geometryMember><Curve><segments><LineStringSegment><posList srsDimension=\"2\">2 3 4 5</posList></LineStringSegment></segments></Curve></geometryMember></MultiGeometry>",
843  NULL, 0, 0, "");
844 
845  /* GML2 - Nested GeometryCollection */
847  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
848  "<MultiGeometry><geometryMember><Point><coordinates>0,1</coordinates></Point></geometryMember><geometryMember><MultiGeometry><geometryMember><LineString><coordinates>2,3 4,5</coordinates></LineString></geometryMember></MultiGeometry></geometryMember></MultiGeometry>",
849  NULL, 0, "");
850 
851  /* GML3 - Nested GeometryCollection */
853  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
854  "<MultiGeometry><geometryMember><Point><pos srsDimension=\"2\">0 1</pos></Point></geometryMember><geometryMember><MultiGeometry><geometryMember><Curve><segments><LineStringSegment><posList srsDimension=\"2\">2 3 4 5</posList></LineStringSegment></segments></Curve></geometryMember></MultiGeometry></geometryMember></MultiGeometry>",
855  NULL, 0, 0, "");
856 
857 
858 
859 }
860 
861 
862 static void out_gml_test_geoms_nodims(void)
863 {
864  /* GML3 - Linestring */
866  "LINESTRING(0 1,2 3,4 5)",
867  "<Curve><segments><LineStringSegment><posList>0 1 2 3 4 5</posList></LineStringSegment></segments></Curve>",
868  NULL, 0, 0, 0, "");
869 
870 
871  /* GML3 Polygon */
873  "POLYGON((0 1,2 3,4 5,0 1))",
874  "<Polygon><exterior><LinearRing><posList>0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Polygon>",
875  NULL, 0, 0, 0, "");
876 
877 
878  /* GML3 Polygon - with internal ring */
880  "POLYGON((0 1,2 3,4 5,0 1),(6 7,8 9,10 11,6 7))",
881  "<Polygon><exterior><LinearRing><posList>0 1 2 3 4 5 0 1</posList></LinearRing></exterior><interior><LinearRing><posList>6 7 8 9 10 11 6 7</posList></LinearRing></interior></Polygon>",
882  NULL, 0, 0, 0, "");
883 
884  /* GML3 Triangle */
886  "TRIANGLE((0 1,2 3,4 5,0 1))",
887  "<Triangle><exterior><LinearRing><posList>0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Triangle>",
888  NULL, 0, 0, 0, "");
889 
890 
891  /* GML3 MultiPoint */
893  "MULTIPOINT(0 1,2 3)",
894  "<MultiPoint><pointMember><Point><pos>0 1</pos></Point></pointMember><pointMember><Point><pos>2 3</pos></Point></pointMember></MultiPoint>",
895  NULL, 0, 0, 0, "");
896 
897 
898  /* GML3 Multiline */
900  "MULTILINESTRING((0 1,2 3,4 5),(6 7,8 9,10 11))",
901  "<MultiCurve><curveMember><Curve><segments><LineStringSegment><posList>0 1 2 3 4 5</posList></LineStringSegment></segments></Curve></curveMember><curveMember><Curve><segments><LineStringSegment><posList>6 7 8 9 10 11</posList></LineStringSegment></segments></Curve></curveMember></MultiCurve>",
902  NULL, 0, 0, 0, "");
903 
904 
905  /* GML3 MultiPolygon */
907  "MULTIPOLYGON(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
908  "<MultiSurface><surfaceMember><Polygon><exterior><LinearRing><posList>0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Polygon></surfaceMember><surfaceMember><Polygon><exterior><LinearRing><posList>6 7 8 9 10 11 6 7</posList></LinearRing></exterior></Polygon></surfaceMember></MultiSurface>",
909  NULL, 0, 0, 0, "");
910 
911  /* GML3 PolyhedralSurface */
913  "POLYHEDRALSURFACE(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
914  "<PolyhedralSurface><polygonPatches><PolygonPatch><exterior><LinearRing><posList>0 1 2 3 4 5 0 1</posList></LinearRing></exterior></PolygonPatch><PolygonPatch><exterior><LinearRing><posList>6 7 8 9 10 11 6 7</posList></LinearRing></exterior></PolygonPatch></polygonPatches></PolyhedralSurface>",
915  NULL, 0, 0, 0, "");
916 
917  /* GML3 Tin */
919  "TIN(((0 1,2 3,4 5,0 1)),((6 7,8 9,10 11,6 7)))",
920  "<Tin><trianglePatches><Triangle><exterior><LinearRing><posList>0 1 2 3 4 5 0 1</posList></LinearRing></exterior></Triangle><Triangle><exterior><LinearRing><posList>6 7 8 9 10 11 6 7</posList></LinearRing></exterior></Triangle></trianglePatches></Tin>",
921  NULL, 0, 0, 0, "");
922 
923  /* GML3 - GeometryCollection */
925  "GEOMETRYCOLLECTION(POINT(0 1),LINESTRING(2 3,4 5))",
926  "<MultiGeometry><geometryMember><Point><pos>0 1</pos></Point></geometryMember><geometryMember><Curve><segments><LineStringSegment><posList>2 3 4 5</posList></LineStringSegment></segments></Curve></geometryMember></MultiGeometry>",
927  NULL, 0, 0, 0, "");
928 
929  /* GML3 - Nested GeometryCollection */
931  "GEOMETRYCOLLECTION(POINT(0 1),GEOMETRYCOLLECTION(LINESTRING(2 3,4 5)))",
932  "<MultiGeometry><geometryMember><Point><pos>0 1</pos></Point></geometryMember><geometryMember><MultiGeometry><geometryMember><Curve><segments><LineStringSegment><posList>2 3 4 5</posList></LineStringSegment></segments></Curve></geometryMember></MultiGeometry></geometryMember></MultiGeometry>",
933  NULL, 0, 0, 0, "");
934 }
935 
936 static void out_gml2_extent(void)
937 {
938  /* GML2: Point */
940  "POINT(-15 60)",
941  "<Box><coordinates>-15,60 -15,60</coordinates></Box>",
942  NULL, 15, "");
944  "POINT(-15 60)",
945  "<gml:Box><gml:coordinates>-15,60 -15,60</gml:coordinates></gml:Box>",
946  NULL, 15, "gml:");
948  "POINT(-15 60)",
949  "<Box srsName=\"urn:ogc:def:crs:EPSG::4326\"><coordinates>-15,60 -15,60</coordinates></Box>",
950  "urn:ogc:def:crs:EPSG::4326", 15, "");
951 
952  /* GML2: Multipoint */
954  "MULTIPOINT(2 3, -5 -6)",
955  "<Box><coordinates>-5,-6 2,3</coordinates></Box>",
956  NULL, 15, "");
957 
958  /* GML2: Linestring */
960  "LINESTRING(0 1,2 3,4 5)",
961  "<Box><coordinates>0,1 4,5</coordinates></Box>",
962  NULL, 15, "");
963 
964  /* GML2: MultiLinestring */
966  "MULTILINESTRING((0 1,2 3),(4 5, 10 6))",
967  "<Box><coordinates>0,1 10,6</coordinates></Box>",
968  NULL, 15, "");
969 
970  /* GML2: Polygon */
972  "POLYGON((1 7,7 14, 14 7, 1 7))",
973  "<Box><coordinates>1,7 14,14</coordinates></Box>",
974  NULL, 15, "");
975 
976  /* GML2: MultiPolygon */
978  "MULTIPOLYGON(((1 7,7 14, 14 7, 1 7)),((-4 -6, -15 3, 0 0, -4 -6)))",
979  "<Box><coordinates>-15,-6 14,14</coordinates></Box>",
980  NULL, 15, "");
981 
982  /* GML2: MultiSurface */
984  "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
985  "<Box><coordinates>-2,-1 10,14</coordinates></Box>",
986  NULL, 15, "");
987 
988  /* GML2: empty */
990  "GEOMETRYCOLLECTION EMPTY",
991  "<Box/>",
992  NULL, 15, "");
993 
994  /* GML2: empty with srsName */
996  "GEOMETRYCOLLECTION EMPTY",
997  "<Box srsName=\"urn:ogc:def:crs:EPSG::4326\"/>",
998  "urn:ogc:def:crs:EPSG::4326", 15, "");
999 
1000 }
1001 
1002 static void out_gml3_extent(void)
1003 {
1004  /* GML3: Point */
1006  "POINT(-15 60)",
1007  "<Envelope><lowerCorner>-15 60</lowerCorner><upperCorner>-15 60</upperCorner></Envelope>",
1008  NULL, 15, 0, "");
1010  "POINT(-15 60)",
1011  "<gml:Envelope><gml:lowerCorner>-15 60</gml:lowerCorner><gml:upperCorner>-15 60</gml:upperCorner></gml:Envelope>",
1012  NULL, 15, 0, "gml:");
1014  "POINT(-15 60)",
1015  "<Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\"><lowerCorner>-15 60</lowerCorner><upperCorner>-15 60</upperCorner></Envelope>",
1016  "urn:ogc:def:crs:EPSG::4326", 15, 0, "");
1017 
1018  /* GML3: Multipoint */
1020  "MULTIPOINT(2 3, -5 -6)",
1021  "<Envelope><lowerCorner>-5 -6</lowerCorner><upperCorner>2 3</upperCorner></Envelope>",
1022  NULL, 15, 0, "");
1023 
1024  /* GML3: Linestring */
1026  "LINESTRING(0 1,2 3,4 5)",
1027  "<Envelope><lowerCorner>0 1</lowerCorner><upperCorner>4 5</upperCorner></Envelope>",
1028  NULL, 15, 0, "");
1029 
1030  /* GML3: MultiLinestring */
1032  "MULTILINESTRING((0 1,2 3),(4 5, 10 6))",
1033  "<Envelope><lowerCorner>0 1</lowerCorner><upperCorner>10 6</upperCorner></Envelope>",
1034  NULL, 15, 0, "");
1036  "MULTILINESTRING((0 1,2 3),(4 5, 10 6))",
1037  "<Envelope><lowerCorner>1 0</lowerCorner><upperCorner>6 10</upperCorner></Envelope>",
1038  NULL, 15, LW_GML_IS_DEGREE, "");
1040  "MULTILINESTRING((0 1,2 3),(4 5, 10 6))",
1041  "<Envelope srsDimension=\"2\"><lowerCorner>1 0</lowerCorner><upperCorner>6 10</upperCorner></Envelope>",
1042  NULL, 15, LW_GML_IS_DEGREE|LW_GML_IS_DIMS, "");
1044  "MULTILINESTRING((0 1 10,2 3 30),(4 5 50, 10 6 -70))",
1045  "<Envelope srsDimension=\"3\"><lowerCorner>1 0 -70</lowerCorner><upperCorner>6 10 50</upperCorner></Envelope>",
1046  NULL, 15, LW_GML_IS_DEGREE|LW_GML_IS_DIMS, "");
1047 
1048  /* GML3: Polygon */
1050  "POLYGON((1 7,7 14, 14 7, 1 7))",
1051  "<Envelope><lowerCorner>1 7</lowerCorner><upperCorner>14 14</upperCorner></Envelope>",
1052  NULL, 15, 0, "");
1053 
1054  /* GML3: MultiPolygon */
1056  "MULTIPOLYGON(((1 7,7 14, 14 7, 1 7)),((-4 -6, -15 3, 0 0, -4 -6)))",
1057  "<Envelope><lowerCorner>-15 -6</lowerCorner><upperCorner>14 14</upperCorner></Envelope>",
1058  NULL, 15, 0, "");
1059 
1060  /* GML3: MultiSurface */
1062  "MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0,-1 -1,0 0,1 -1,2 0,0 2,-2 0),(-1 0,0 0.5,1 0,0 1,-1 0)),((7 8,10 10,6 14,4 11,7 8)))",
1063  "<Envelope><lowerCorner>-2 -1</lowerCorner><upperCorner>10 14</upperCorner></Envelope>",
1064  NULL, 15, 0, "");
1065 
1066  /* GML3: empty */
1068  "GEOMETRYCOLLECTION EMPTY",
1069  "<Envelope/>",
1070  NULL, 15, 0, "");
1071 
1072  /* GML3: empty with srsName */
1074  "GEOMETRYCOLLECTION EMPTY",
1075  "<Envelope srsName=\"urn:ogc:def:crs:EPSG::4326\"/>",
1076  "urn:ogc:def:crs:EPSG::4326", 15, 0, "");
1077 
1078 }
1079 
1080 /*
1081 ** Used by test harness to register the tests in this file.
1082 */
1083 void out_gml_suite_setup(void);
1085 {
1086  CU_pSuite suite = CU_add_suite("GML Output", NULL, NULL);
1094  PG_ADD_TEST(suite, out_gml2_extent);
1095  PG_ADD_TEST(suite, out_gml3_extent);
1096 }
static void out_gml_test_geoms(void)
Definition: cu_out_gml.c:442
static void do_gml3_test_opts(char *in, char *out, char *srs, int precision, int opts)
Definition: cu_out_gml.c:56
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.
Definition: lwout_gml.c:211
static void out_gml_test_dims(void)
Definition: cu_out_gml.c:400
static void do_gml3_test_nodims(char *in, char *out, char *srs, int precision, int is_geodetic, int is_dims, const char *prefix)
Definition: cu_out_gml.c:112
#define LW_GML_SHORTLINE
For GML3, use rather than for lines.
Definition: liblwgeom.h:1362
void lwfree(void *mem)
Definition: lwutil.c:190
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
static void out_gml_test_geoms_prefix(void)
Definition: cu_out_gml.c:615
static void do_gml3_extent_test(char *in, char *out, char *srs, double precision, int opts, char *prefix)
Definition: cu_out_gml.c:191
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:844
static void do_gml2_test_prefix(char *in, char *out, char *srs, int precision, const char *prefix)
Definition: cu_out_gml.c:39
static void out_gml_test_geoms_nodims(void)
Definition: cu_out_gml.c:862
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:1706
static void out_gml_test_geodetic(void)
Definition: cu_out_gml.c:384
void cu_error_msg_reset()
#define PG_ADD_TEST(suite, testfunc)
static void do_gml2_extent_test(char *in, char *out, char *srs, double precision, char *prefix)
Definition: cu_out_gml.c:171
static void do_gml3_unsupported(char *in, char *out)
Definition: cu_out_gml.c:151
char * lwgeom_extent_to_gml2(const LWGEOM *geom, const char *srs, int precision, const char *prefix)
Definition: lwout_gml.c:178
static void out_gml_test_precision(void)
Definition: cu_out_gml.c:211
static void out_gml_test_srid(void)
Definition: cu_out_gml.c:265
static void out_gml2_extent(void)
Definition: cu_out_gml.c:936
char * lwgeom_extent_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix)
Definition: lwout_gml.c:193
static void do_gml2_unsupported(char *in, char *out)
Definition: cu_out_gml.c:133
static void do_gml3_test(char *in, char *out, char *srs, int precision, int is_geodetic)
Definition: cu_out_gml.c:73
#define LW_GML_IS_DIMS
Macros for specifying GML options.
Definition: liblwgeom.h:1358
void out_gml_suite_setup(void)
Definition: cu_out_gml.c:1084
char * lwgeom_to_gml3(const LWGEOM *geom, const char *srs, int precision, int opts, const char *prefix, const char *id)
Definition: lwout_gml.c:711
static void do_gml3_test_prefix(char *in, char *out, char *srs, int precision, int is_geodetic, const char *prefix)
Definition: cu_out_gml.c:92
char cu_error_msg[MAX_CUNIT_ERROR_LENGTH+1]
static void out_gml3_extent(void)
Definition: cu_out_gml.c:1002
static void do_gml2_test(char *in, char *out, char *srs, int precision)
Definition: cu_out_gml.c:22
#define LW_GML_IS_DEGREE
For GML3 only, declare that datas are lat/lon.
Definition: liblwgeom.h:1360