-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dimension handling with setPrecision / reducePrecision #1152
Comments
With case 2, I see GeometryTransformer::transformLinearRing switch to a LineString type to ensure a valid LinearRing, since it has three coordinates. |
mwtoews
changed the title
setPrecision with LinearRing
Dimension handling with setPrecision / reducePrecision
Aug 23, 2024
More generally, the issue is that setPrecision / reducePrecision doesn't properly handle dimensions. A few examples: for geom_type in POINT LINESTRING LINEARRING POLYGON; do
geom="$geom_type M EMPTY";
echo "$geom";
echo -n " reducePrecision: ";
./bin/geosop -a "$geom" reducePrecision 1;
echo -n " reducePrecisionKeepCollapsed: ";
./bin/geosop -a "$geom" reducePrecisionKeepCollapsed 1;
echo -n " reducePrecisionPointwise: ";
./bin/geosop -a "$geom" reducePrecisionPointwise 1;
done returns all wrong results
Or with non-empty inputs: for geom in "POINT M (1 2 3)" "LINESTRING M (0 0 1, 0.1 0 1, 0.1 0.1 1, 0 0.1 1, 0 0 1)" "LINEARRING M (0 0 1, 0.1 0 1, 0.1 0.1 1, 0 0.1 1, 0 0 1)" "POLYGON M ((0 0 1, 0.1 0 1, 0.1 0.1 1, 0 0.1 1, 0 0 1))"; do
echo "$geom";
echo -n " reducePrecision: ";
./bin/geosop -a "$geom" reducePrecision 1;
echo -n " reducePrecisionKeepCollapsed: ";
./bin/geosop -a "$geom" reducePrecisionKeepCollapsed 1;
echo -n " reducePrecisionPointwise: ";
./bin/geosop -a "$geom" reducePrecisionPointwise 1;
done the results have some OK and some with NaN and others with lost dims:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I see a few inconsistencies with
GEOSGeom_setPrecision
. For example:$ ./bin/geosop -a "LINEARRING (0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0)" reducePrecision 1 LINEARRING Z EMPTY
$ ./bin/geosop -a "LINEARRING (0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0)" reducePrecisionKeepCollapsed 1 LINESTRING (0 0, 0 0, 0 0)
$ ./bin/geosop -a "LINEARRING (0 0, 0.1 0, 0.1 0.1, 0 0.1, 0 0)" reducePrecisionPointwise 1 LINEARRING (0 0, 0 0, 0 0, 0 0, 0 0)
Here are my guesses for better answers:
LINEARRING EMPTY
(without Z dimension)LINEARRING (0 0, 0 0, 0 0)
More on case 1, GEOSGeom_setPrecision test<10> doesn't fail because
ensure_geometry_equals
ignores Z/M dims, thus LINEARRING Z EMPTY == LINEARRING EMPTY. There is a similar issue with GEOSGeom_transformXY test<10> wherePOINT Z EMPTY
is returned and compared equal toPOINT EMPTY
. I'd likeensure_geometry_equals
to check if(GEOSHasZ(g1) != GEOSHasZ(g2)) || (GEOSHasM(g1) != GEOSHasM(g2))
.The issue is probably related to GeometryTransformer / GeometryFactory::createLinearRing().
See also trac #1135
The text was updated successfully, but these errors were encountered: