Opened 12 years ago
Last modified 7 years ago
#2179 new defect
ST_MakeValid support for NaN values.
Reported by: | strk | Owned by: | strk |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS Fund Me |
Component: | postgis | Version: | 2.0.x |
Keywords: | Cc: |
Description
It's not easy to obtain a polygon with NaN ordinate values so here is one:
01060000000100000001030000000100000007000000010000000000F87F9CDFD01E32095341010000000000F87F193B6F0A30095341010000000000F87FA10FBF4C1D095341010000000000F87F38E258111C095341010000000000F87F5196BAFF17095341010000000000F87F4F0550911B095341010000000000F87F9CDFD01E32095341
The above geometry was found in a shapefile, and can be imported successfully by both shp2pgsql and ogr2ogr.
ST_MakeValid not only fails at turning it into a valid, but also throws an exception.
Possible better things to do:
- Pretend all NaN values are an arbitrary value (0.0) ?
- Drop all Coordinates with any NaN ordinate value (including Z and M?)
- Return null
- Return the input untouched
Change History (7)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Owner: | changed from | to
---|
comment:3 by , 12 years ago
Simpler input, with no magic numbers:
WITH points AS ( SELECT ST_MakePoint('nan'::float8, 0) as p1, ST_MakePoint('nan'::float8, 2) as p2, ST_MakePoint('nan'::float8, 5) as p3 ) SELECT '#2179', ST_MakeValid(ST_MakePolygon( ST_MakeLine(ST_MakeLine(p1, p2), ST_MakeLine(p3, p1))) ) FROM points;
Cast your vote for a meaningful behavior ? Should it return NULL ? Empty ? Arbitrary ordinates ?
comment:4 by , 12 years ago
I prefer the current behavior. The thing is that Nans causes all sorts of problems when passed to other functions and all your other options silently ignore the problem or assume too much passing the buck to some other sap function.
However I always thought ST_MakeValid should take options (similar to GML funcs) as to what it should do anyway -- not just for this but in general. For example I don't use it a lot because when trying to make something valid like a polygon it turns it into a linestring or some other thing like a geometry collection which does me no good. It would be nice to say only do something if you are going to give me back the same geometry type as I input otherwise do nothing.
Part of the flag would be behavior: throw error, show notice, ignore
comment:5 by , 11 years ago
Milestone: | PostGIS 2.0.4 → PostGIS 2.2.0 |
---|
comment:6 by , 10 years ago
Milestone: | PostGIS 2.2.0 → PostGIS Future |
---|
For comparison: NULL is returned in this case: