Skip to content

Commit

Permalink
Merge branch 'fix_multipoint_wkt_iso_export' of https://github.com/ro…
Browse files Browse the repository at this point in the history
…uault/postgis into rouault-fix_multipoint_wkt_iso_export
  • Loading branch information
pramsey committed Apr 12, 2022
2 parents 5bb5a91 + a5609b6 commit f6f735b
Show file tree
Hide file tree
Showing 32 changed files with 310 additions and 306 deletions.
12 changes: 6 additions & 6 deletions doc/reference_accessor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
FROM (SELECT 'LINESTRING(100 150,50 60, 70 80, 160 170)'::geometry As geom) As f;
</programlisting>
<screen>-- ST_AsText output
MULTIPOINT(100 150,160 170)
MULTIPOINT((100 150),(160 170))
</screen>
</para></entry>

Expand Down Expand Up @@ -175,7 +175,7 @@ MULTILINESTRING((10 130,50 190,110 190,140 150,150 80,100 10,20 40,10 130),
<programlisting>SELECT ST_AsText(ST_Boundary(ST_GeomFromText('LINESTRING(1 1,0 0, -1 1)')));
st_astext
-----------
MULTIPOINT(1 1,-1 1)
MULTIPOINT((1 1),(-1 1))

SELECT ST_AsText(ST_Boundary(ST_GeomFromText('POLYGON((1 1,0 0, -1 1, 1 1))')));
st_astext
Expand All @@ -194,7 +194,7 @@ SELECT ST_AsEWKT(ST_Boundary(ST_GeomFromEWKT('MULTILINESTRING((1 1 1,0 0 0.5, -1

st_asewkt
----------
MULTIPOINT(-1 1 1,1 1 0.75)
MULTIPOINT((-1 1 1),(1 1 0.75))
</programlisting>
</refsection>
<refsection>
Expand Down Expand Up @@ -1243,7 +1243,7 @@ LINESTRING(0 0 1,1 1 1,1 2 1,1 1 1,0 0 1)
<programlisting>--Extracting a subset of points from a 3d multipoint
SELECT n, ST_AsEWKT(ST_GeometryN(geom, n)) As geomewkt
FROM (
VALUES (ST_GeomFromEWKT('MULTIPOINT(1 2 7, 3 4 7, 5 6 7, 8 9 10)') ),
VALUES (ST_GeomFromEWKT('MULTIPOINT((1 2 7), (3 4 7), (5 6 7), (8 9 10))') ),
( ST_GeomFromEWKT('MULTICURVE(CIRCULARSTRING(2.5 2.5,4.5 2.5, 3.5 3.5), (10 11, 12 11))') )
)As foo(geom)
CROSS JOIN generate_series(1,100) n
Expand Down Expand Up @@ -2319,7 +2319,7 @@ SELECT ST_NumGeometries(ST_GeomFromText('LINESTRING(77.29 29.07,77.42 29.26,77.2
1

--Geometry Collection Example - multis count as one geom in a collection
SELECT ST_NumGeometries(ST_GeomFromEWKT('GEOMETRYCOLLECTION(MULTIPOINT(-2 3 , -2 2),
SELECT ST_NumGeometries(ST_GeomFromEWKT('GEOMETRYCOLLECTION(MULTIPOINT((-2 3),(-2 2)),
LINESTRING(5 5 ,10 10),
POLYGON((-7 4.2,-7.1 5,-7.1 4.3,-7 4.2)))'));
--result
Expand Down Expand Up @@ -2709,7 +2709,7 @@ FROM ST_GeomFromText('LINESTRING(0 0 0, 1 1 1, 2 2 2)') AS g
<programlisting>SELECT ST_AsText(ST_Points('POLYGON Z ((30 10 4,10 30 5,40 40 6, 30 10))'));

--result
MULTIPOINT Z (30 10 4,10 30 5,40 40 6, 30 10 4)
MULTIPOINT Z ((30 10 4),(10 30 5),(40 40 6),(30 10 4))
</programlisting>
</refsection>

Expand Down
2 changes: 1 addition & 1 deletion doc/reference_constructor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SELECT ST_AsText( ST_Collect( ST_GeomFromText('POINT(1 2)'),

st_astext
----------
MULTIPOINT(1 2,-2 3)
MULTIPOINT((1 2),(-2 3))
</programlisting>

<para>Collect 3D points.</para>
Expand Down
4 changes: 2 additions & 2 deletions doc/reference_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ SELECT ST_AsText(ST_CollectionExtract(
1 ));
st_astext
---------------
MULTIPOINT(0 0)
MULTIPOINT((0 0))
</programlisting>

<para>Extract lines (type 2 == LINESTRING):</para>
Expand Down Expand Up @@ -245,7 +245,7 @@ SELECT ST_AsText(ST_CollectionHomogenize('GEOMETRYCOLLECTION(POINT(0 0),POINT(1

st_astext
---------------------
MULTIPOINT(0 0,1 1)
MULTIPOINT((0 0),(1 1))
</programlisting>

<para>Nested heterogeneous collection flattened to a GeometryCollection:</para>
Expand Down
4 changes: 2 additions & 2 deletions doc/reference_input.xml
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,8 @@ aline | null_return
<refsection>
<title>Examples</title>

<programlisting>SELECT ST_MPointFromText('MULTIPOINT(1 2, 3 4)');
SELECT ST_MPointFromText('MULTIPOINT(-70.9590 42.1180, -70.9611 42.1223)', 4326);</programlisting>
<programlisting>SELECT ST_MPointFromText('MULTIPOINT((1 2),(3 4))');
SELECT ST_MPointFromText('MULTIPOINT((-70.9590 42.1180),(-70.9611 42.1223))', 4326);</programlisting>
</refsection>

<!-- Optionally add a "See Also" section -->
Expand Down
4 changes: 2 additions & 2 deletions doc/reference_lrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ SELECT ST_AsText(
<programlisting>--Return points each 20% along a 2D line
SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(25 50, 100 125, 150 190)', 0.20))
----------------
MULTIPOINT(51.5974135047432 76.5974135047432,78.1948270094864 103.194827009486,104.132163186446 130.37181214238,127.066081593223 160.18590607119,150 190)
MULTIPOINT((51.5974135047432 76.5974135047432),(78.1948270094864 103.194827009486),(104.132163186446 130.37181214238),(127.066081593223 160.18590607119),(150 190))
</programlisting>
</refsection>

Expand Down Expand Up @@ -485,7 +485,7 @@ SELECT ST_AsText(

st_astext
----------------------------------
MULTIPOINT M (1 2 3,9 4 3,1 2 3)
MULTIPOINT M ((1 2 3),(9 4 3),(1 2 3))
</programlisting>
</refsection>

Expand Down
4 changes: 2 additions & 2 deletions liblwgeom/cunit/cu_measures.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ test_lwgeom_locate_along(void)
str = lwgeom_to_wkt(out, WKT_ISO, 6, NULL);
lwgeom_free(geom);
lwgeom_free(out);
ASSERT_STRING_EQUAL(str, "MULTIPOINT M (55.226131 55.226131 105)");
ASSERT_STRING_EQUAL(str, "MULTIPOINT M ((55.226131 55.226131 105))");
lwfree(str);

/* ST_Locatealong(ST_GeomFromText('MULTILINESTRING M ((1 2 3, 5 4 5), (50 50 1, 60 60 200))'), 105) */
Expand All @@ -734,7 +734,7 @@ test_lwgeom_locate_along(void)
str = lwgeom_to_wkt(out, WKT_ISO, 6, NULL);
lwgeom_free(geom);
lwgeom_free(out);
ASSERT_STRING_EQUAL(str, "MULTIPOINT M (55.226131 55.226131 105)");
ASSERT_STRING_EQUAL(str, "MULTIPOINT M ((55.226131 55.226131 105))");
lwfree(str);
}

Expand Down
8 changes: 4 additions & 4 deletions liblwgeom/cunit/cu_out_wkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ static void test_wkt_out_polygon(void)
}
static void test_wkt_out_multipoint(void)
{
CU_ASSERT_STRING_EQUAL(cu_wkt("MULTIPOINT(1 2 3 4,5 6 7 8)",WKT_ISO), "MULTIPOINT ZM (1 2 3 4,5 6 7 8)");
CU_ASSERT_STRING_EQUAL(cu_wkt("MULTIPOINT(1 2 3,5 6 7)",WKT_ISO), "MULTIPOINT Z (1 2 3,5 6 7)");
CU_ASSERT_STRING_EQUAL(cu_wkt("MULTIPOINTM(1 2 3,5 6 7)",WKT_ISO), "MULTIPOINT M (1 2 3,5 6 7)");
CU_ASSERT_STRING_EQUAL(cu_wkt("MULTIPOINT(1 2 3 4,5 6 7 8)",WKT_ISO), "MULTIPOINT ZM ((1 2 3 4),(5 6 7 8))");
CU_ASSERT_STRING_EQUAL(cu_wkt("MULTIPOINT(1 2 3,5 6 7)",WKT_ISO), "MULTIPOINT Z ((1 2 3),(5 6 7))");
CU_ASSERT_STRING_EQUAL(cu_wkt("MULTIPOINTM(1 2 3,5 6 7)",WKT_ISO), "MULTIPOINT M ((1 2 3),(5 6 7))");

}

Expand Down Expand Up @@ -153,7 +153,7 @@ static void test_wkt_out_collection(void)
);
CU_ASSERT_STRING_EQUAL(
cu_wkt("GEOMETRYCOLLECTION(MULTIPOLYGON(((100 100 2, 100 200 2, 200 200 2, 200 100 2, 100 100 2))),MULTIPOINT(.5 .5 .5,1 1 1),CURVEPOLYGON((.8 .8 .8,.8 .8 .8,.8 .8 .8)))",WKT_ISO),
"GEOMETRYCOLLECTION Z (MULTIPOLYGON Z (((100 100 2,100 200 2,200 200 2,200 100 2,100 100 2))),MULTIPOINT Z (0.5 0.5 0.5,1 1 1),CURVEPOLYGON Z ((0.8 0.8 0.8,0.8 0.8 0.8,0.8 0.8 0.8)))"
"GEOMETRYCOLLECTION Z (MULTIPOLYGON Z (((100 100 2,100 200 2,200 200 2,200 100 2,100 100 2))),MULTIPOINT Z ((0.5 0.5 0.5),(1 1 1)),CURVEPOLYGON Z ((0.8 0.8 0.8,0.8 0.8 0.8,0.8 0.8 0.8)))"
);

/* See http://trac.osgeo.org/postgis/ticket/724 */
Expand Down
10 changes: 7 additions & 3 deletions liblwgeom/lwout_wkt.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,10 @@ static void lwcircstring_to_wkt_sb(const LWCIRCSTRING *circ, stringbuffer_t *sb,


/*
* Multi-points do not wrap their sub-members in parens, unlike other multi-geometries.
* Multi-points, in non-ISO format, do not wrap their sub-members in parens, unlike other multi-geometries.
* MULTPOINT(0 0, 1 1) instead of MULTIPOINT((0 0),(1 1))
* Strictly speaking, the SFA spec also mandates use of parens in sub-members, but
* use the old non-parens interpretation for WKT_SFSQL
*/
static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int precision, uint8_t variant)
{
Expand All @@ -239,13 +241,15 @@ static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int p
return;
}
stringbuffer_append_len(sb, "(", 1);
variant = variant | WKT_IS_CHILD; /* Inform the sub-geometries they are childre */
variant = variant | WKT_IS_CHILD | WKT_NO_TYPE; /* Inform the sub-geometries they are children */
if ( !(variant & WKT_ISO) )
variant = variant | WKT_NO_PARENS;
for ( i = 0; i < mpoint->ngeoms; i++ )
{
if ( i > 0 )
stringbuffer_append_len(sb, ",", 1);
/* We don't want type strings or parens on our subgeoms */
lwpoint_to_wkt_sb(mpoint->geoms[i], sb, precision, variant | WKT_NO_PARENS | WKT_NO_TYPE );
lwpoint_to_wkt_sb(mpoint->geoms[i], sb, precision, variant);
}
stringbuffer_append_len(sb, ")", 1);
}
Expand Down
2 changes: 1 addition & 1 deletion regress/core/boundary_expected
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
boundary01|POINT EMPTY
boundary02|MULTIPOINT EMPTY
boundary03|MULTIPOINT(1 1,-1 1)
boundary03|MULTIPOINT((1 1),(-1 1))
boundary04|MULTIPOINT EMPTY
boundary05|LINESTRING(1 1,0 0,-1 1,1 1)
boundary06|LINESTRING(1 1 1,0 0 1,-1 1 1,1 1 1)
Expand Down
2 changes: 1 addition & 1 deletion regress/core/flatgeobuf_expected
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ L2|0|LINESTRING Z (1 2 3,3 4 5)
L3|0|LINESTRING ZM (1 2 3 5,3 4 5 6)
P1|0|POLYGON((75 29,77 29,77 29,75 29))
P2|0|POLYGON((35 10,45 45,15 40,10 20,35 10),(20 30,35 35,30 20,20 30))
MP1|0|MULTIPOINT(10 40,40 30,20 20,30 10)
MP1|0|MULTIPOINT((10 40),(40 30),(20 20),(30 10))
ML1|0|MULTILINESTRING((10 10,20 20,10 40),(40 40,30 30,40 20,30 10))
MP1|0|MULTIPOLYGON(((40 40,20 45,45 30,40 40)),((20 35,10 30,10 10,30 5,45 20,20 35),(30 20,20 15,20 25,30 20)))
GC1|0|GEOMETRYCOLLECTION(POINT(40 10),LINESTRING(10 10,20 20,10 40),POLYGON((40 40,20 45,45 30,40 40)))
Expand Down
2 changes: 1 addition & 1 deletion regress/core/forcecurve_expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1|POINT(0 0)
2|MULTIPOINT(0 0)
2|MULTIPOINT((0 0))
3|COMPOUNDCURVE((0 0,10 0))
4|MULTICURVE((0 0,10 0),(30 0,30 2))
5|CURVEPOLYGON((0 0,10 0,10 10,0 10,0 0))
Expand Down
2 changes: 1 addition & 1 deletion regress/core/in_geojson_expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
geomfromgeojson_01|SRID=3005;MULTIPOINT(1 1,1 1)
geomfromgeojson_02|MULTIPOINT(1 1,1 1)
geomfromgeojson_02|MULTIPOINT((1 1),(1 1))
geomfromgeojson_03|POINT(1 1)
geomfromgeojson_04|LINESTRING(0 0,1 1)
geomfromgeojson_05|POLYGON((0 0,1 1,1 0,0 0))
Expand Down
2 changes: 1 addition & 1 deletion regress/core/in_gml_expected
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ mpoint_3|SRID=4326;MULTIPOINT(1 2)
mpoint_4|MULTIPOINT EMPTY
mpoint_5|MULTIPOINT EMPTY
mpoint_6|MULTIPOINT(1 2,3 4)
mpoint_7|27582|MULTIPOINT(1 2,400000 7000000)
mpoint_7|27582|MULTIPOINT((1 2),(400000 7000000))
mpoint_8|MULTIPOINT(1 2)
mpoint_9|MULTIPOINT(1 2,3 4)
mpoint_10|MULTIPOINT EMPTY
Expand Down
2 changes: 1 addition & 1 deletion regress/core/in_marc21_expected
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ point_1|POINT(13.41667 52.5)
point_2|POINT(13.69445 52.83333)
point_3|POINT(13.70186 52.83333)
multipolygon_1|MULTIPOLYGON(((7.55 52.01667,7.71667 52.01667,7.71667 51.95,7.55 51.95,7.55 52.01667)),((-58.79583 -51.57111,-58.41417 -51.57111,-58.41417 -51.74722,-58.79583 -51.74722,-58.79583 -51.57111)))
multipoint_1|MULTIPOINT(13.41667 52.5,-0.12574 51.50853)
multipoint_1|MULTIPOINT((13.41667 52.5),(-0.12574 51.50853))
geocollection_1|GEOMETRYCOLLECTION(POINT(13.41667 52.5),POLYGON((-58.79583 -51.57111,-58.41417 -51.57111,-58.41417 -51.74722,-58.79583 -51.74722,-58.79583 -51.57111)))
4 changes: 2 additions & 2 deletions regress/core/mvt_expected
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ PG14|POLYGON((10 0,10 10,0 10,0 0,10 0),(1 9,9 9,9 1,1 1,1 9))
PG15|POLYGON((0 10,0 0,10 0,10 10,0 10),(9 1,1 1,1 9,9 9,9 1))
PG16|POLYGON((0 10,0 0,10 0,10 10,0 10),(9 1,1 1,1 9,9 9,9 1))
PG17|56
PG18|MULTIPOINT(1 9,3 8)
PG19|MULTIPOINT(25 4079,26 4078)
PG18|MULTIPOINT((1 9),(3 8))
PG19|MULTIPOINT((25 4079),(26 4078))
PG20|POINT(10 4086)
PG21|LINESTRING(1 9,5 5)
PG22|
Expand Down

0 comments on commit f6f735b

Please sign in to comment.