]> granicus.if.org Git - postgis/commitdiff
Make stylish
authorSandro Santilli <strk@keybit.net>
Sun, 21 Feb 2010 12:21:04 +0000 (12:21 +0000)
committerSandro Santilli <strk@keybit.net>
Sun, 21 Feb 2010 12:21:04 +0000 (12:21 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5271 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_homogenize.c
liblwgeom/cunit/cu_tester.c
liblwgeom/lwhomogenize.c
postgis/lwgeom_gml.c
postgis/lwgeom_in_kml.c

index f9137ed7ea55295989a4e017a1e5834732132d9b..b70f7a348b0565c1c327db2161f4de5432a05bd1 100644 (file)
@@ -26,10 +26,10 @@ CU_pSuite register_homogenize_suite(void)
        }
 
        if (    (NULL == CU_add_test(pSuite, "test_coll_point()", test_coll_point)) ||
-               (NULL == CU_add_test(pSuite, "test_coll_line()", test_coll_line))   ||
-               (NULL == CU_add_test(pSuite, "test_coll_poly()", test_coll_poly))   ||
-               (NULL == CU_add_test(pSuite, "test_coll_coll()", test_coll_coll))   ||
-               (NULL == CU_add_test(pSuite, "test_geom()", test_geom))
+               (NULL == CU_add_test(pSuite, "test_coll_line()", test_coll_line))   ||
+               (NULL == CU_add_test(pSuite, "test_coll_poly()", test_coll_poly))   ||
+               (NULL == CU_add_test(pSuite, "test_coll_coll()", test_coll_coll))   ||
+               (NULL == CU_add_test(pSuite, "test_geom()", test_geom))
           )
        {
                CU_cleanup_registry();
@@ -65,8 +65,8 @@ static do_geom_test(char * in, char * out)
        h = lwgeom_homogenize(g);
        if (strcmp(lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out))
                fprintf(stderr, "\nIn:   %s\nOut:  %s\nTheo: %s\n",
-                       in, lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out);
-       CU_ASSERT_STRING_EQUAL(lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out); 
+                       in, lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out);
+       CU_ASSERT_STRING_EQUAL(lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out);
        lwfree(g);
        lwgeom_free(h);
 }
@@ -80,8 +80,8 @@ static do_coll_test(char * in, char * out)
        h = lwcollection_homogenize((LWCOLLECTION *) g);
        if (strcmp(lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out))
                fprintf(stderr, "\nIn:   %s\nOut:  %s\nTheo: %s\n",
-                       in, lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out);
-       CU_ASSERT_STRING_EQUAL(lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out); 
+                       in, lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out);
+       CU_ASSERT_STRING_EQUAL(lwgeom_to_ewkt(h, PARSER_CHECK_NONE), out);
        lwfree(g);
        lwgeom_free(h);
 }
@@ -90,66 +90,66 @@ static do_coll_test(char * in, char * out)
 void test_coll_point(void)
 {
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2))",
-                    "POINT(1 2)");
+                    "POINT(1 2)");
 
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))",
-                    "MULTIPOINT(1 2,3 4)");
+                    "MULTIPOINT(1 2,3 4)");
 
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4),POINT(5 6))",
-                    "MULTIPOINT(1 2,3 4,5 6)");
+                    "MULTIPOINT(1 2,3 4,5 6)");
 
        do_coll_test("GEOMETRYCOLLECTION(MULTIPOINT(1 2,3 4),POINT(5 6))",
-                    "MULTIPOINT(1 2,3 4,5 6)");
+                    "MULTIPOINT(1 2,3 4,5 6)");
 
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),MULTIPOINT(3 4,5 6))",
-                    "MULTIPOINT(1 2,3 4,5 6)");
+                    "MULTIPOINT(1 2,3 4,5 6)");
 
        do_coll_test("GEOMETRYCOLLECTION(MULTIPOINT(1 2,3 4),MULTIPOINT(5 6,7 8))",
-                    "MULTIPOINT(1 2,3 4,5 6,7 8)");
+                    "MULTIPOINT(1 2,3 4,5 6,7 8)");
 }
 
 
 void test_coll_line(void)
 {
        do_coll_test("GEOMETRYCOLLECTION(LINESTRING(1 2,3 4))",
-                    "LINESTRING(1 2,3 4)");
+                    "LINESTRING(1 2,3 4)");
 
        do_coll_test("GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),LINESTRING(5 6,7 8))",
-                    "MULTILINESTRING((1 2,3 4),(5 6,7 8))");
+                    "MULTILINESTRING((1 2,3 4),(5 6,7 8))");
 
        do_coll_test("GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),LINESTRING(5 6,7 8),LINESTRING(9 10,11 12))",
-                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12))");
+                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12))");
 
        do_coll_test("GEOMETRYCOLLECTION(MULTILINESTRING((1 2,3 4),(5 6,7 8)),LINESTRING(9 10,11 12))",
-                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12))");
+                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12))");
 
        do_coll_test("GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),MULTILINESTRING((5 6,7 8),(9 10,11 12)))",
-                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12))");
+                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12))");
 
        do_coll_test("GEOMETRYCOLLECTION(MULTILINESTRING((1 2,3 4),(5 6,7 8)),MULTILINESTRING((9 10,11 12),(13 14,15 16)))",
-                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12),(13 14,15 16))");
+                    "MULTILINESTRING((1 2,3 4),(5 6,7 8),(9 10,11 12),(13 14,15 16))");
 }
 
 
 void test_coll_poly(void)
 {
        do_coll_test("GEOMETRYCOLLECTION(POLYGON((1 2,3 4,5 6,1 2)))",
-                    "POLYGON((1 2,3 4,5 6,1 2))");
+                    "POLYGON((1 2,3 4,5 6,1 2))");
 
        do_coll_test("GEOMETRYCOLLECTION(POLYGON((1 2,3 4,5 6,1 2)),POLYGON((7 8,9 10,11 12,7 8)))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))");
 
        do_coll_test("GEOMETRYCOLLECTION(POLYGON((1 2,3 4,5 6,1 2)),POLYGON((7 8,9 10,11 12,7 8)),POLYGON((13 14,15 16,17 18,13 14)))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
 
        do_coll_test("GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8))),POLYGON((13 14,15 16,17 18,13 14)))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
 
        do_coll_test("GEOMETRYCOLLECTION(POLYGON((1 2,3 4,5 6,1 2)),MULTIPOLYGON(((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14))))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
 
        do_coll_test("GEOMETRYCOLLECTION(MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8))),MULTIPOLYGON(((13 14,15 16,17 18,13 14)),((19 20,21 22,23 24,19 20))))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)),((19 20,21 22,23 24,19 20)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)),((19 20,21 22,23 24,19 20)))");
 }
 
 
@@ -157,39 +157,39 @@ void test_coll_coll(void)
 {
        /* Two different types together must produce a Collection as output */
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))",
-                    "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))");
+                    "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))");
 
        do_coll_test("GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),POLYGON((5 6,7 8,9 10,5 6)))",
-                    "GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),POLYGON((5 6,7 8,9 10,5 6)))");
+                    "GEOMETRYCOLLECTION(LINESTRING(1 2,3 4),POLYGON((5 6,7 8,9 10,5 6)))");
 
 
-       /* Ability to produce a single MULTI with same type */ 
+       /* Ability to produce a single MULTI with same type */
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6),POINT(7 8))",
-                    "GEOMETRYCOLLECTION(MULTIPOINT(1 2,7 8),LINESTRING(3 4,5 6))");
+                    "GEOMETRYCOLLECTION(MULTIPOINT(1 2,7 8),LINESTRING(3 4,5 6))");
 
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6),MULTIPOINT(7 8,9 10))",
-                    "GEOMETRYCOLLECTION(MULTIPOINT(1 2,7 8,9 10),LINESTRING(3 4,5 6))");
+                    "GEOMETRYCOLLECTION(MULTIPOINT(1 2,7 8,9 10),LINESTRING(3 4,5 6))");
 
 
        /* Recursive Collection handle */
        do_coll_test("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(POINT(1 2))))",
-                    "POINT(1 2)");
+                    "POINT(1 2)");
 
        do_coll_test("GEOMETRYCOLLECTION(POINT(1 2),GEOMETRYCOLLECTION(LINESTRING(3 4,5 6)))",
-                    "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))");
+                    "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))");
 
 
        /* EMPTY Collection */
-       do_coll_test("GEOMETRYCOLLECTION EMPTY", 
-                    "GEOMETRYCOLLECTION EMPTY"); 
+       do_coll_test("GEOMETRYCOLLECTION EMPTY",
+                    "GEOMETRYCOLLECTION EMPTY");
 
 
        /* Recursive EMPTY Collection */
        do_coll_test("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY)",
-                    "GEOMETRYCOLLECTION EMPTY"); 
+                    "GEOMETRYCOLLECTION EMPTY");
 
        do_coll_test("GEOMETRYCOLLECTION(GEOMETRYCOLLECTION(GEOMETRYCOLLECTION EMPTY))",
-                    "GEOMETRYCOLLECTION EMPTY"); 
+                    "GEOMETRYCOLLECTION EMPTY");
 }
 
 
@@ -197,82 +197,82 @@ void test_geom(void)
 {
        /* Already simple geometry */
        do_geom_test("POINT(1 2)",
-                    "POINT(1 2)");
+                    "POINT(1 2)");
 
        do_geom_test("LINESTRING(1 2,3 4)",
-                    "LINESTRING(1 2,3 4)");
+                    "LINESTRING(1 2,3 4)");
 
        do_geom_test("POLYGON((1 2,3 4,5 6,1 2))",
-                    "POLYGON((1 2,3 4,5 6,1 2))");
+                    "POLYGON((1 2,3 4,5 6,1 2))");
 
        do_geom_test("POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))",
-                    "POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))");
+                    "POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))");
 
 
        /* Empty geometry */
-       do_geom_test("GEOMETRYCOLLECTION EMPTY", 
-                    "GEOMETRYCOLLECTION EMPTY"); 
+       do_geom_test("GEOMETRYCOLLECTION EMPTY",
+                    "GEOMETRYCOLLECTION EMPTY");
 
 
        /* A MULTI with a single geometry inside */
        do_geom_test("MULTIPOINT(1 2)",
-                    "POINT(1 2)");
+                    "POINT(1 2)");
 
        do_geom_test("MULTILINESTRING((1 2,3 4))",
-                    "LINESTRING(1 2,3 4)");
+                    "LINESTRING(1 2,3 4)");
 
        do_geom_test("MULTIPOLYGON(((1 2,3 4,5 6,1 2)))",
-                    "POLYGON((1 2,3 4,5 6,1 2))");
+                    "POLYGON((1 2,3 4,5 6,1 2))");
 
        do_geom_test("MULTIPOLYGON(((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8)))",
-                    "POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))");
+                    "POLYGON((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8))");
 
 
        /* A real MULTI */
        do_geom_test("MULTIPOINT(1 2,3 4)",
-                    "MULTIPOINT(1 2,3 4)");
+                    "MULTIPOINT(1 2,3 4)");
 
        do_geom_test("MULTILINESTRING((1 2,3 4),(5 6,7 8))",
-                    "MULTILINESTRING((1 2,3 4),(5 6,7 8))");
+                    "MULTILINESTRING((1 2,3 4),(5 6,7 8))");
 
        do_geom_test("MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2)),((7 8,9 10,11 12,7 8)))");
 
        do_geom_test("MULTIPOLYGON(((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))",
-                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
+                    "MULTIPOLYGON(((1 2,3 4,5 6,1 2),(7 8,9 10,11 12,7 8)),((13 14,15 16,17 18,13 14)))");
 
 
        /* A Collection */
        do_geom_test("GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))",
-                    "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))");
+                    "GEOMETRYCOLLECTION(POINT(1 2),LINESTRING(3 4,5 6))");
 
 
        /* SRID */
        do_geom_test("SRID=4326;GEOMETRYCOLLECTION EMPTY",
-                    "SRID=4326;GEOMETRYCOLLECTION EMPTY");
+                    "SRID=4326;GEOMETRYCOLLECTION EMPTY");
 
        do_geom_test("SRID=4326;POINT(1 2)",
-                    "SRID=4326;POINT(1 2)");
+                    "SRID=4326;POINT(1 2)");
 
        do_geom_test("SRID=4326;MULTIPOINT(1 2)",
-                    "SRID=4326;POINT(1 2)");
+                    "SRID=4326;POINT(1 2)");
 
        do_geom_test("SRID=4326;MULTIPOINT(1 2,3 4)",
-                    "SRID=4326;MULTIPOINT(1 2,3 4)");
+                    "SRID=4326;MULTIPOINT(1 2,3 4)");
 
        do_geom_test("SRID=4326;MULTILINESTRING((1 2,3 4))",
-                    "SRID=4326;LINESTRING(1 2,3 4)");
+                    "SRID=4326;LINESTRING(1 2,3 4)");
 
        do_geom_test("SRID=4326;MULTILINESTRING((1 2,3 4),(5 6,7 8))",
-                    "SRID=4326;MULTILINESTRING((1 2,3 4),(5 6,7 8))");
+                    "SRID=4326;MULTILINESTRING((1 2,3 4),(5 6,7 8))");
 
        /* 3D and 4D */
        do_geom_test("POINT(1 2 3)",
-                    "POINT(1 2 3)");
+                    "POINT(1 2 3)");
 
        do_geom_test("POINTM(1 2 3)",
-                    "POINTM(1 2 3)");
+                    "POINTM(1 2 3)");
 
        do_geom_test("POINT(1 2 3 4)",
-                    "POINT(1 2 3 4)");
+                    "POINT(1 2 3 4)");
 }
index 107c04dee0c55aff79752510a70791fca7ce803e..5d11609c0e2e716541f0c09b3ab3e5a4feaf2343 100644 (file)
@@ -18,7 +18,7 @@
 
 
 /**
- * CUnit error handler 
+ * CUnit error handler
  * Log message in a global var instead of printing in stderr
  *
  * CAUTION: Not stop execution on lwerror case !!!
 static void
 cu_errorreporter(const char *fmt, va_list ap)
 {
-        char *msg;
+       char *msg;
 
-        /** This is a GNU extension.
-        * Dunno how to handle errors here.
-         */
-        if (!lw_vasprintf (&msg, fmt, ap))
-        {
-                va_end (ap);
-                return;
-        }
+       /** This is a GNU extension.
+       * Dunno how to handle errors here.
+        */
+       if (!lw_vasprintf (&msg, fmt, ap))
+       {
+               va_end (ap);
+               return;
+       }
 
        strncpy(cu_error_msg, msg, MAX_CUNIT_ERROR_LENGTH);
 }
@@ -52,11 +52,11 @@ cu_error_msg_reset()
 */
 void lwgeom_init_allocators(void)
 {
-        lwalloc_var = default_allocator;
-        lwrealloc_var = default_reallocator;
-        lwfree_var = default_freeor;
-        lwnotice_var = default_noticereporter;
-        lwerror_var = cu_errorreporter;
+       lwalloc_var = default_allocator;
+       lwrealloc_var = default_reallocator;
+       lwfree_var = default_freeor;
+       lwnotice_var = default_noticereporter;
+       lwerror_var = cu_errorreporter;
 
 }
 
index e31005e0f7ca6d44b9c457d33a43537bd22d7ad0..548b664a368e393b7bcf13faaef222e49873e394 100644 (file)
@@ -23,7 +23,7 @@
 /*
 ** Given a generic geometry, return the "simplest" form.
 **
-** eg: 
+** eg:
 **     LINESTRING() => LINESTRING()
 **
 **     MULTILINESTRING(with a single line) => LINESTRING()
@@ -43,41 +43,44 @@ lwgeom_homogenize(const LWGEOM *geom)
        if (lwgeom_is_empty(geom)) return lwgeom_clone(geom);
 
        /* Already a simple Geometry */
-       switch (type) {
-               case POINTTYPE:
-               case LINETYPE:
-               case POLYGONTYPE:
-                       return lwgeom_clone(geom);
+       switch (type)
+       {
+       case POINTTYPE:
+       case LINETYPE:
+       case POLYGONTYPE:
+               return lwgeom_clone(geom);
        }
 
        /* A MULTI */
-       switch (type) {
-               case MULTIPOINTTYPE:
-               case MULTILINETYPE:
-               case MULTIPOLYGONTYPE:
+       switch (type)
+       {
+       case MULTIPOINTTYPE:
+       case MULTILINETYPE:
+       case MULTIPOLYGONTYPE:
 
-                       /* A MULTI with a single geometry inside */
-                       if (((LWCOLLECTION *) geom)->ngeoms == 1) {
+               /* A MULTI with a single geometry inside */
+               if (((LWCOLLECTION *) geom)->ngeoms == 1)
+               {
 
-                               hgeom =lwgeom_clone((LWGEOM *)
-                                       ((LWCOLLECTION *)geom)->geoms[0]); 
+                       hgeom =lwgeom_clone((LWGEOM *)
+                                           ((LWCOLLECTION *)geom)->geoms[0]);
 
-                               hgeom->SRID = geom->SRID;
-                               if (geom->bbox)
-                                       hgeom->bbox = box2d_clone(geom->bbox);
+                       hgeom->SRID = geom->SRID;
+                       if (geom->bbox)
+                               hgeom->bbox = box2d_clone(geom->bbox);
 
-                               return hgeom;
-                       }
+                       return hgeom;
+               }
 
-                       /* A 'real' MULTI */
-                       return lwgeom_clone(geom);
+               /* A 'real' MULTI */
+               return lwgeom_clone(geom);
        }
 
        if (type == COLLECTIONTYPE)
                return lwcollection_homogenize((LWCOLLECTION *) geom);
 
        lwerror("lwgeom_homogenize: Geometry Type not supported (%i)",
-                       lwgeom_typename(type));
+               lwgeom_typename(type));
 
        return NULL; /*Never reach */
 }
@@ -100,61 +103,62 @@ LWGEOM *
 lwcollection_homogenize(const LWCOLLECTION *col)
 {
        unsigned int i;
-        uchar hasz, hasm;
+       uchar hasz, hasm;
        LWGEOM *res = NULL;
-        LWCOLLECTION *coll;
+       LWCOLLECTION *coll;
        LWGEOM_HOMOGENIZE *geoms;
 
-        if (!col) lwerror("lwcollection_homogenize: Null input geometry.");
+       if (!col) lwerror("lwcollection_homogenize: Null input geometry.");
 
        /* EMPTY Geometry case */
        if (col->ngeoms == 0)
-                       return (LWGEOM *) lwcollection_construct_empty(col->SRID, 0, 0);
+               return (LWGEOM *) lwcollection_construct_empty(col->SRID, 0, 0);
 
-        hasz = TYPE_HASZ(col->type);
-        hasm = TYPE_HASM(col->type);
+       hasz = TYPE_HASZ(col->type);
+       hasm = TYPE_HASM(col->type);
 
        /* LWGEOM_HOMOGENIZE struct setup */
        geoms = lwalloc(sizeof(LWGEOM_HOMOGENIZE));
-        geoms->points = (LWMPOINT *)
-               lwcollection_construct_empty(col->SRID, hasz, hasm);
-        geoms->lines  = (LWMLINE *)
-               lwcollection_construct_empty(col->SRID, hasz, hasm);
-        geoms->polys  = (LWMPOLY *)
-               lwcollection_construct_empty(col->SRID, hasz, hasm);
+       geoms->points = (LWMPOINT *)
+                       lwcollection_construct_empty(col->SRID, hasz, hasm);
+       geoms->lines  = (LWMLINE *)
+                       lwcollection_construct_empty(col->SRID, hasz, hasm);
+       geoms->polys  = (LWMPOLY *)
+                       lwcollection_construct_empty(col->SRID, hasz, hasm);
 
        /* Parse each sub geom and update LWGEOM_HOMOGENIZE struct */
-        for (i=0 ; i < col->ngeoms ; i++)
+       for (i=0 ; i < col->ngeoms ; i++)
                geoms = lwcollection_homogenize_subgeom(geoms, col->geoms[i]);
 
        /* Check if struct is mixed typed, and need a COLLECTION as output */
        if ((geoms->points->ngeoms && geoms->lines->ngeoms) ||
-           (geoms->points->ngeoms && geoms->polys->ngeoms) ||
-           (geoms->lines->ngeoms  && geoms->polys->ngeoms)) {
+               (geoms->points->ngeoms && geoms->polys->ngeoms) ||
+               (geoms->lines->ngeoms  && geoms->polys->ngeoms))
+       {
 
-               coll = lwcollection_construct_empty(col->SRID, hasz, hasm);
+               coll = lwcollection_construct_empty(col->SRID, hasz, hasm);
                if (col->bbox) coll->bbox = box2d_clone(col->bbox);
 
                if (geoms->points->ngeoms == 1)
                        coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                                       (LWGEOM *) geoms->points->geoms[0]);
+                               (LWGEOM *) geoms->points->geoms[0]);
                else if (geoms->points->ngeoms)
                        coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                                       (LWGEOM *) geoms->points);
+                               (LWGEOM *) geoms->points);
 
                if (geoms->lines->ngeoms == 1)
                        coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                                       (LWGEOM *) geoms->lines->geoms[0]);
+                               (LWGEOM *) geoms->lines->geoms[0]);
                else if (geoms->lines->ngeoms)
                        coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                                       (LWGEOM *) geoms->lines);
+                               (LWGEOM *) geoms->lines);
 
                if (geoms->polys->ngeoms == 1)
                        coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                                       (LWGEOM *) geoms->polys->geoms[0]);
+                               (LWGEOM *) geoms->polys->geoms[0]);
                else if (geoms->polys->ngeoms)
                        coll = (LWCOLLECTION *) lwcollection_add(coll, -1,
-                                       (LWGEOM *) geoms->polys);
+                               (LWGEOM *) geoms->polys);
 
                /* We could now free the struct */
                lwmpoint_release(geoms->points);
@@ -174,11 +178,11 @@ lwcollection_homogenize(const LWCOLLECTION *col)
                res = lwgeom_clone((LWGEOM *) geoms->polys->geoms[0]);
 
        /* We have to return a single MULTI */
-        if (geoms->points->ngeoms > 1)
+       if (geoms->points->ngeoms > 1)
                res = lwgeom_clone((LWGEOM *) geoms->points);
-        if (geoms->lines->ngeoms > 1)
+       if (geoms->lines->ngeoms > 1)
                res = lwgeom_clone((LWGEOM *) geoms->lines);
-        if (geoms->polys->ngeoms > 1)
+       if (geoms->polys->ngeoms > 1)
                res = lwgeom_clone((LWGEOM *) geoms->polys);
 
        /* We could now free the struct */
@@ -205,41 +209,55 @@ lwcollection_homogenize_subgeom(LWGEOM_HOMOGENIZE *hgeoms, LWGEOM *geom)
 
        if (!geom) lwerror("lwcollection_homogenize: Sub geometry is Null");
 
-        type = TYPE_GETTYPE(geom->type);
+       type = TYPE_GETTYPE(geom->type);
 
-       if (type == POINTTYPE) {
+       if (type == POINTTYPE)
+       {
                hgeoms->points = (LWMPOINT *) lwmpoint_add(hgeoms->points, -1, geom);
 
-       } else if (type == LINETYPE) {
+       }
+       else if (type == LINETYPE)
+       {
                hgeoms->lines = (LWMLINE *) lwmline_add(hgeoms->lines, -1, geom);
 
-       } else if (type == POLYGONTYPE) {
+       }
+       else if (type == POLYGONTYPE)
+       {
                hgeoms->polys = (LWMPOLY *) lwmpoly_add(hgeoms->polys, -1, geom);
 
-       } else if (type == MULTIPOINTTYPE) {
+       }
+       else if (type == MULTIPOINTTYPE)
+       {
                for (i=0 ; i < ((LWMPOINT *) geom)->ngeoms ; i++)
                        hgeoms->points = (LWMPOINT *) lwmpoint_add(
-                                       hgeoms->points, -1,
-                                       (LWGEOM *) ((LWMPOINT *)geom)->geoms[i]);
+                                            hgeoms->points, -1,
+                                            (LWGEOM *) ((LWMPOINT *)geom)->geoms[i]);
 
-       } else if (type == MULTILINETYPE) {
+       }
+       else if (type == MULTILINETYPE)
+       {
                for (i=0 ; i < ((LWMLINE *) geom)->ngeoms ; i++)
                        hgeoms->lines = (LWMLINE *) lwmline_add(
-                                       hgeoms->lines, -1,
-                                       (LWGEOM *) ((LWMLINE *)geom)->geoms[i]);
+                                           hgeoms->lines, -1,
+                                           (LWGEOM *) ((LWMLINE *)geom)->geoms[i]);
 
-       } else if (type == MULTIPOLYGONTYPE) {
+       }
+       else if (type == MULTIPOLYGONTYPE)
+       {
                for (i=0 ; i < ((LWMPOLY *) geom)->ngeoms ; i++)
                        hgeoms->polys = (LWMPOLY *) lwmpoly_add(
-                                       hgeoms->polys, -1,
-                                       (LWGEOM *) ((LWMPOLY *)geom)->geoms[i]);
+                                           hgeoms->polys, -1,
+                                           (LWGEOM *) ((LWMPOLY *)geom)->geoms[i]);
 
-       } else if (type == COLLECTIONTYPE) {
-               for (i=0; i < ((LWCOLLECTION *) geom)->ngeoms ; i++)
+       }
+       else if (type == COLLECTIONTYPE)
+       {
+               for (i=0; i < ((LWCOLLECTION *) geom)->ngeoms ; i++)
                        hgeoms = lwcollection_homogenize_subgeom(hgeoms,
-                               ((LWCOLLECTION *) geom)->geoms[i]);
+                                ((LWCOLLECTION *) geom)->geoms[i]);
 
-       } else lwerror("lwcollection_homogenize: Unsupported geometry type");
+       }
+       else lwerror("lwcollection_homogenize: Unsupported geometry type");
 
        return hgeoms;
 }
index 47a7728b25f00896e037a39de6c989d1b0ff23a0..8921b8d3f76fda7caf3a79dd28ff6ec295b1d4cf 100644 (file)
@@ -776,7 +776,7 @@ asgml3_poly_size(LWPOLY *poly, char *srs, int precision)
 
        size = sizeof("<gml:Polygon><gml:exterior><gml:LinearRing>///") * 2;
        size += sizeof("<gml:interior><gml:LinearRing>//") * 2 * (poly->nrings - 1);
-       size += sizeof("<gml:posList srsDimension='x'></gml:posList>") * poly->nrings; 
+       size += sizeof("<gml:posList srsDimension='x'></gml:posList>") * poly->nrings;
        if ( srs ) size += strlen(srs) + sizeof(" srsName=..");
 
        for (i=0; i<poly->nrings; i++)
index 76ca2826ffe444ad24f717f3d672b422bdc89cdf..6f68e5828feaeb6afcfe12a415585b54ea8e27bd 100644 (file)
@@ -91,7 +91,8 @@ Datum geom_from_kml(PG_FUNCTION_ARGS)
        lwgeom = parse_kml(xmlroot, &hasz);
 
        /* Homogenize geometry result if needed */
-       if (TYPE_GETTYPE(lwgeom->type) == COLLECTIONTYPE) {
+       if (TYPE_GETTYPE(lwgeom->type) == COLLECTIONTYPE)
+       {
                hlwgeom = lwgeom_homogenize(lwgeom);
                lwgeom_release(lwgeom);
                lwgeom = hlwgeom;