This repository has been archived by the owner on Oct 1, 2024. It is now read-only.
Fixes MultiPoint::fromWKT() so it works with alternate no nested parenthesis wkt #153
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry for not discussing this problem before doing the PR :(
WKT officially supports two syntaxes for MultiPoint, one with nested parenthesis and one without:
MULTIPOINT ((10 40), (40 30), (20 20), (30 10))
MULTIPOINT (10 40, 40 30, 20 20, 30 10)
https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry
laravel-postgis only supports the nested parenthesis syntax.
Postgis st_astext unfortunately uses the version without nested parenthesis:
select st_astext(st_geomfromtext('MULTIPOINT((1 1),(2 1),(2 2))'))
would return
MULTIPOINT(1 1,2 1,2 2)
This PR fixes the problem by checking if no nested parenthesis syntax is used, and if so, adding the parenthesis and go on with the rest of the function. This could probably be done in a more elegant way but I'm not that good at regex :( There is a test proving this problem in the PR.
The PR also updates the regex to support floating point values, it replaces \d by [+-]?([0-9]+([.][0-9]*)?|[.][0-9]+) as explained here: https://stackoverflow.com/questions/12643009/regular-expression-for-floating-point-numbers but yet again, I'm far from an expert with regular expressions. There is also a test proving the problem.
Thanks for maintaining this great package!