Skip to content

Commit

Permalink
OGR: Support multiline WKT input
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed May 5, 2021
1 parent f6c8e7a commit c7311e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
17 changes: 14 additions & 3 deletions autotest/ogr/ogr_wkbwkt_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def test_ogr_wkbwkt_test_broken_geom():
gdal.PopErrorHandler()
assert geom is None, ('geom %s instantiated but not expected' % wkt)


###############################################################################
# Test importing WKT SF1.2

Expand Down Expand Up @@ -484,7 +484,7 @@ def test_ogr_wkbwkt_test_import_wkt_sf12():
('in=%s, out=%s, expected=%s.' % (wkt_tuple[0], out_wkt,
wkt_tuple[1]))


###############################################################################
# Test that importing the wkb that would be equivalent to MULTIPOINT(POLYGON((0 0))
# doesn't work
Expand Down Expand Up @@ -525,7 +525,7 @@ def test_ogr_wkbwkt_test_geometrycollection_wktwkb():
wkt2 = g.ExportToWkt()
assert wkt == wkt2, ('fail for %s' % wkt)


###############################################################################
# Test that importing too nested WKT doesn't cause stack overflows

Expand Down Expand Up @@ -608,6 +608,17 @@ def test_ogr_wkt_multipolygon_corrupted():
g = ogr.CreateGeometryFromWkt('MULTIPOLYGON(POLYGON((N')
assert g is None

###############################################################################
# Test multiline WKT


def test_ogr_wkt_multiline():
g = ogr.CreateGeometryFromWkt("""GEOMETRYCOLLECTION(
POINT (1 2),
LINESTRING (3 3, 4 4))
""")
assert g is not None

###############################################################################
# When imported build a list of units based on the files available.

Expand Down
4 changes: 2 additions & 2 deletions gdal/ogr/ogrutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ const char *OGRWktReadToken( const char * pszInput, char * pszToken )
/* -------------------------------------------------------------------- */
/* Swallow pre-white space. */
/* -------------------------------------------------------------------- */
while( *pszInput == ' ' || *pszInput == '\t' )
while( *pszInput == ' ' || *pszInput == '\t' || *pszInput == '\n' || *pszInput == '\r' )
++pszInput;

/* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -448,7 +448,7 @@ const char *OGRWktReadToken( const char * pszInput, char * pszToken )
/* -------------------------------------------------------------------- */
/* Eat any trailing white space. */
/* -------------------------------------------------------------------- */
while( *pszInput == ' ' || *pszInput == '\t' )
while( *pszInput == ' ' || *pszInput == '\t' || *pszInput == '\n' || *pszInput == '\r' )
++pszInput;

return pszInput;
Expand Down

0 comments on commit c7311e6

Please sign in to comment.