Opened 10 years ago

Closed 10 years ago

#2786 closed defect (wontfix)

st_buildArea returns null geom

Reported by: mjurce Owned by: pramsey
Priority: medium Milestone:
Component: postgis Version: 2.0.x
Keywords: Cc:

Description

select st_asText(st_buildArea( st_curvetoline(st_GeomFromText('MULTICURVE((715537.187 91770.539,715541.774 91782.060,715552.413 91787.648,715554.587 91795.922,715557.280 91801.092,715557.152 91795.643,715559.827 91794.284,715580.191 91814.057,715584.102 91815.280,715607.318 91826.989,715609.459 91829.830,715609.588 91839.660,715606.190 91837.710,715603.506 91837.322,715599.678 91834.403,715593.014 91831.325,715592.151 91830.889,715588.161 91831.919,715584.211 91834.084,715580.055 91837.074,715575.738 91839.398,715571.882 91841.719,715569.010 91842.588,715562.923 91844.881,715551.009 91847.220,715541.481 91845.339,715538.953 91842.280,715528.604 91842.106,715527.956 91846.181,715525.549 91849.393,715525.717 91849.515,715516.818 91860.240,715505.961 91849.502,715501.797 91845.422,715491.018 91834.644,715479.196 91810.681,715477.609 91812.014,715446.445 91826.586,715445.016 91827.461,715443.889 91828.677,715443.198 91830.216,715443.020 91831.896,715443.345 91833.529,715438.564 91830.984,715437.963 91829.340,715432.470 91814.247,715423.645 91818.572,715416.744 91810.214,715417.434 91810.007,715412.152 91802.380,715411.587 91794.394,715411.386 91791.554,715411.378 91783.632,715411.425 91782.252,715411.638 91777.893,715413.585 91771.282,715408.214 91770.716,715406.827 91770.484,715401.043 91769.483,715391.406 91767.254,715378.023 91762.959,715377.340 91762.528,715376.939 91761.826,715369.312 91760.180,715370.885 91759.433,715372.130 91757.782,715372.655 91755.781,715373.354 91720.501,715370.178 91721.285,715368.303 91705.398,715365.812 91705.458,715365.203 91699.854,715377.986 91699.243,715379.798 91688.574,715382.266 91682.528,715382.283 91684.028,715382.403 91688.324,715384.534 91695.865,715388.055 91701.887,715395.704 91714.939),CIRCULARSTRING(715395.704 91714.939,715395.742 91715.167,715395.679 91715.389),(715395.679 91715.389,715395.186 91716.412),CIRCULARSTRING(715395.186 91716.412,715394.911 91716.841,715394.579 91717.227),CIRCULARSTRING(715394.579 91717.227,715394.199 91717.561,715393.776 91717.838),CIRCULARSTRING(715393.776 91717.838,715393.310 91718.057,715392.808 91718.172),CIRCULARSTRING(715392.808 91718.172,715392.532 91718.189,715392.255 91718.174),(715392.255 91718.174,715405.385 91719.053,715417.385 91719.739,715436.177 91720.812,715440.093 91720.705,715444.376 91719.881,715446.928 91718.899,715448.936 91718.127,715453.889 91715.987),CIRCULARSTRING(715453.889 91715.987,715453.301 91717.020,715452.497 91717.896),(715452.497 91717.896,715453.751 91717.354,715460.889 91714.267,715464.984 91712.969,715469.019 91712.225,715473.079 91711.950,715488.666 91711.014,715488.704 91715.333,715472.950 91716.313,715475.197 91719.457,715480.797 91727.668,715484.038 91732.282,715485.594 91731.384,715488.190 91729.587,715486.780 91726.930,715495.235 91720.858,715508.002 91712.134,715514.139 91709.249,715521.129 91710.293,715521.337 91711.690,715524.085 91719.505,715525.492 91722.476,715531.480 91720.161,715536.262 91728.232,715527.955 91736.355,715533.632 91752.179,715536.527 91767.968,715537.187 91770.539))') ) ))

Change History (5)

comment:1 by robe, 10 years ago

Priority: blockermedium

I'm not sure there is an issue here. Result seems to be a cause of rounding effects which makes the generated polygon invalid. Just to get to the point, your example can be reduced to:

SELECT ST_LineMerge(st_curvetoline(st_GeomFromText('MULTICURVE((715537.187 91770.539,715541.774 91782.060,715552.413 91787.648,715554.587 91795.922,715557.280 91801.092,715557.152 91795.643,715559.827 91794.284,715580.191 91814.057,715584.102 91815.280,715607.318 91826.989,715609.459 91829.830,715609.588 91839.660,715606.190 91837.710,715603.506 91837.322,715599.678 91834.403,715593.014 91831.325,715592.151 91830.889,715588.161 91831.919,715584.211 91834.084,715580.055 91837.074,715575.738 91839.398,715571.882 91841.719,715569.010 91842.588,715562.923 91844.881,715551.009 91847.220,715541.481 91845.339,715538.953 91842.280,715528.604 91842.106,715527.956 91846.181,715525.549 91849.393,715525.717 91849.515,715516.818 91860.240,715505.961 91849.502,715501.797 91845.422,715491.018 91834.644,715479.196 91810.681,715477.609 91812.014,715446.445 91826.586,715445.016 91827.461,715443.889 91828.677,715443.198 91830.216,715443.020 91831.896,715443.345 91833.529,715438.564 91830.984,715437.963 91829.340,715432.470 91814.247,715423.645 91818.572,715416.744 91810.214,715417.434 91810.007,715412.152 91802.380,715411.587 91794.394,715411.386 91791.554,715411.378 91783.632,715411.425 91782.252,715411.638 91777.893,715413.585 91771.282,715408.214 91770.716,715406.827 91770.484,715401.043 91769.483,715391.406 91767.254,715378.023 91762.959,715377.340 91762.528,715376.939 91761.826,715369.312 91760.180,715370.885 91759.433,715372.130 91757.782,715372.655 91755.781,715373.354 91720.501,715370.178 91721.285,715368.303 91705.398,715365.812 91705.458,715365.203 91699.854,715377.986 91699.243,715379.798 91688.574,715382.266 91682.528,715382.283 91684.028,715382.403 91688.324,715384.534 91695.865,715388.055 91701.887,715395.704 91714.939),CIRCULARSTRING(715395.704 91714.939,715395.742 91715.167,715395.679 91715.389),(715395.679 91715.389,715395.186 91716.412),CIRCULARSTRING(715395.186 91716.412,715394.911 91716.841,715394.579 91717.227),CIRCULARSTRING(715394.579 91717.227,715394.199 91717.561,715393.776 91717.838),CIRCULARSTRING(715393.776 91717.838,715393.310 91718.057,715392.808 91718.172),CIRCULARSTRING(715392.808 91718.172,715392.532 91718.189,715392.255 91718.174),(715392.255 91718.174,715405.385 91719.053,715417.385 91719.739,715436.177 91720.812,715440.093 91720.705,715444.376 91719.881,715446.928 91718.899,715448.936 91718.127,715453.889 91715.987),CIRCULARSTRING(715453.889 91715.987,715453.301 91717.020,715452.497 91717.896),(715452.497 91717.896,715453.751 91717.354,715460.889 91714.267,715464.984 91712.969,715469.019 91712.225,715473.079 91711.950,715488.666 91711.014,715488.704 91715.333,715472.950 91716.313,715475.197 91719.457,715480.797 91727.668,715484.038 91732.282,715485.594 91731.384,715488.190 91729.587,715486.780 91726.930,715495.235 91720.858,715508.002 91712.134,715514.139 91709.249,715521.129 91710.293,715521.337 91711.690,715524.085 91719.505,715525.492 91722.476,715531.480 91720.161,715536.262 91728.232,715527.955 91736.355,715533.632 91752.179,715536.527 91767.968,715537.187 91770.539))')) );

which gives you a seemingly nice looking closed linestring which we can use our lazy ST_MakePolygon to build a polygon out of:

SELECT ST_MakePolygon('LINESTRING(715392.255 91718.174,715405.385 91719.053,715417.385 91719.739,715436.177 91720.812,715440.093 91720.705,715444.376 91719.881,715446.928 91718.899,715448.936 91718.127,715453.889 91715.987,715453.780829874 91716.2231798697,715453.661201247 91716.4537675939,715453.530402315 91716.6782076665,715453.388748183 91716.8959593919,715453.236580109 91717.1064981869,715453.074264679 91717.3093168453,715452.902192926 91717.503926759,715452.720779384 91717.6898590959,715452.530461096 91717.8666659285,715452.497 91717.896,715453.751 91717.354,715460.889 91714.267,715464.984 91712.969,715469.019 91712.225,715473.079 91711.95,715488.666 91711.014,715488.704 91715.333,715472.95 91716.313,715475.197 91719.457,715480.797 91727.668,715484.038 91732.282,715485.594 91731.384,715488.19 91729.587,715486.78 91726.93,715495.235 91720.858,715508.002 91712.134,715514.139 91709.249,715521.129 91710.293,715521.337 91711.69,715524.085 91719.505,715525.492 91722.476,715531.48 91720.161,715536.262 91728.232,715527.955 91736.355,715533.632 91752.179,715536.527 91767.968,715537.187 91770.539,715541.774 91782.06,715552.413 91787.648,715554.587 91795.922,715557.28 91801.092,715557.152 91795.643,715559.827 91794.284,715580.191 91814.057,715584.102 91815.28,715607.318 91826.989,715609.459 91829.83,715609.588 91839.66,715606.19 91837.71,715603.506 91837.322,715599.678 91834.403,715593.014 91831.325,715592.151 91830.889,715588.161 91831.919,715584.211 91834.084,715580.055 91837.074,715575.738 91839.398,715571.882 91841.719,715569.01 91842.588,715562.923 91844.881,715551.009 91847.22,715541.481 91845.339,715538.953 91842.28,715528.604 91842.106,715527.956 91846.181,715525.549 91849.393,715525.717 91849.515,715516.818 91860.24,715505.961 91849.502,715501.797 91845.422,715491.018 91834.644,715479.196 91810.681,715477.609 91812.014,715446.445 91826.586,715445.016 91827.461,715443.889 91828.677,715443.198 91830.216,715443.02 91831.896,715443.345 91833.529,715438.564 91830.984,715437.963 91829.34,715432.47 91814.247,715423.645 91818.572,715416.744 91810.214,715417.434 91810.007,715412.152 91802.38,715411.587 91794.394,715411.386 91791.554,715411.378 91783.632,715411.425 91782.252,715411.638 91777.893,715413.585 91771.282,715408.214 91770.716,715406.827 91770.484,715401.043 91769.483,715391.406 91767.254,715378.023 91762.959,715377.34 91762.528,715376.939 91761.826,715369.312 91760.18,715370.885 91759.433,715372.13 91757.782,715372.655 91755.781,715373.354 91720.501,715370.178 91721.285,715368.303 91705.398,715365.812 91705.458,715365.203 91699.854,715377.986 91699.243,715379.798 91688.574,715382.266 91682.528,715382.283 91684.028,715382.403 91688.324,715384.534 91695.865,715388.055 91701.887,715395.704 91714.939,715395.713154168 91714.9631954524,715395.721110095 91714.987810934,715395.727848615 91715.0127871441,715395.733353493 91715.0380639127,715395.737611468 91715.0635803459,715395.740612282 91715.0892749724,715395.742348705 91715.1150858915,715395.742816556 91715.1409509225,715395.742014706 91715.1668077543,715395.739945087 91715.1925940954,715395.736612685 91715.2182478244,715395.732025529 91715.2437071392,715395.726194669 91715.268910706,715395.719134151 91715.2937978073,715395.710860987 91715.3183084878,715395.701395105 91715.3423836991,715395.690759311 91715.3659654421,715395.679 91715.389,715395.186 91716.412,715395.096710392 91716.5663712404,715394.9999537 91716.7161753005,715394.895963018 91716.8610512891,715394.78498887 91717.0006501874,715394.667298602 91717.1346356893,715394.579 91717.227,715394.452401023 91717.3490657436,715394.319965057 91717.4647725363,715394.182011154 91717.5738416303,715394.038871655 91717.6760102686,715393.890891396 91717.7710323179,715393.776 91717.838,715393.673467977 91717.8969548753,715393.568166681 91717.9508077291,715393.460349789 91717.9994288249,715393.350277044 91718.0427010304,715393.23821362 91718.0805200991,715393.124429488 91718.1127949214,715393.009198763 91718.1394477445,715392.892799046 91718.1604143594,715392.808 91718.172,715392.690809803 91718.1831208597,715392.573215092 91718.1884780735,715392.455499164 91718.1880587352,715392.337945605 91718.1818638553,715392.255 91718.174)'::geometry);

Except for the tincy littly problem that the generated polygon is invalid even though it passes the quick spot check of being closed.

SELECT ST_IsValidReason(ST_MakePolygon('LINESTRING(715392.255 91718.174,715405.385 91719.053,715417.385 91719.739,715436.177 91720.812,715440.093 91720.705,715444.376 91719.881,715446.928 91718.899,715448.936 91718.127,715453.889 91715.987,715453.780829874 91716.2231798697,715453.661201247 91716.4537675939,715453.530402315 91716.6782076665,715453.388748183 91716.8959593919,715453.236580109 91717.1064981869,715453.074264679 91717.3093168453,715452.902192926 91717.503926759,715452.720779384 91717.6898590959,715452.530461096 91717.8666659285,715452.497 91717.896,715453.751 91717.354,715460.889 91714.267,715464.984 91712.969,715469.019 91712.225,715473.079 91711.95,715488.666 91711.014,715488.704 91715.333,715472.95 91716.313,715475.197 91719.457,715480.797 91727.668,715484.038 91732.282,715485.594 91731.384,715488.19 91729.587,715486.78 91726.93,715495.235 91720.858,715508.002 91712.134,715514.139 91709.249,715521.129 91710.293,715521.337 91711.69,715524.085 91719.505,715525.492 91722.476,715531.48 91720.161,715536.262 91728.232,715527.955 91736.355,715533.632 91752.179,715536.527 91767.968,715537.187 91770.539,715541.774 91782.06,715552.413 91787.648,715554.587 91795.922,715557.28 91801.092,715557.152 91795.643,715559.827 91794.284,715580.191 91814.057,715584.102 91815.28,715607.318 91826.989,715609.459 91829.83,715609.588 91839.66,715606.19 91837.71,715603.506 91837.322,715599.678 91834.403,715593.014 91831.325,715592.151 91830.889,715588.161 91831.919,715584.211 91834.084,715580.055 91837.074,715575.738 91839.398,715571.882 91841.719,715569.01 91842.588,715562.923 91844.881,715551.009 91847.22,715541.481 91845.339,715538.953 91842.28,715528.604 91842.106,715527.956 91846.181,715525.549 91849.393,715525.717 91849.515,715516.818 91860.24,715505.961 91849.502,715501.797 91845.422,715491.018 91834.644,715479.196 91810.681,715477.609 91812.014,715446.445 91826.586,715445.016 91827.461,715443.889 91828.677,715443.198 91830.216,715443.02 91831.896,715443.345 91833.529,715438.564 91830.984,715437.963 91829.34,715432.47 91814.247,715423.645 91818.572,715416.744 91810.214,715417.434 91810.007,715412.152 91802.38,715411.587 91794.394,715411.386 91791.554,715411.378 91783.632,715411.425 91782.252,715411.638 91777.893,715413.585 91771.282,715408.214 91770.716,715406.827 91770.484,715401.043 91769.483,715391.406 91767.254,715378.023 91762.959,715377.34 91762.528,715376.939 91761.826,715369.312 91760.18,715370.885 91759.433,715372.13 91757.782,715372.655 91755.781,715373.354 91720.501,715370.178 91721.285,715368.303 91705.398,715365.812 91705.458,715365.203 91699.854,715377.986 91699.243,715379.798 91688.574,715382.266 91682.528,715382.283 91684.028,715382.403 91688.324,715384.534 91695.865,715388.055 91701.887,715395.704 91714.939,715395.713154168 91714.9631954524,715395.721110095 91714.987810934,715395.727848615 91715.0127871441,715395.733353493 91715.0380639127,715395.737611468 91715.0635803459,715395.740612282 91715.0892749724,715395.742348705 91715.1150858915,715395.742816556 91715.1409509225,715395.742014706 91715.1668077543,715395.739945087 91715.1925940954,715395.736612685 91715.2182478244,715395.732025529 91715.2437071392,715395.726194669 91715.268910706,715395.719134151 91715.2937978073,715395.710860987 91715.3183084878,715395.701395105 91715.3423836991,715395.690759311 91715.3659654421,715395.679 91715.389,715395.186 91716.412,715395.096710392 91716.5663712404,715394.9999537 91716.7161753005,715394.895963018 91716.8610512891,715394.78498887 91717.0006501874,715394.667298602 91717.1346356893,715394.579 91717.227,715394.452401023 91717.3490657436,715394.319965057 91717.4647725363,715394.182011154 91717.5738416303,715394.038871655 91717.6760102686,715393.890891396 91717.7710323179,715393.776 91717.838,715393.673467977 91717.8969548753,715393.568166681 91717.9508077291,715393.460349789 91717.9994288249,715393.350277044 91718.0427010304,715393.23821362 91718.0805200991,715393.124429488 91718.1127949214,715393.009198763 91718.1394477445,715392.892799046 91718.1604143594,715392.808 91718.172,715392.690809803 91718.1831208597,715392.573215092 91718.1884780735,715392.455499164 91718.1880587352,715392.337945605 91718.1818638553,715392.255 91718.174)'::geometry));

Yields:

Self-intersection[715392.4655354 91718.1880944872]

So build area is fine, it will return NULL if the resulting polygon is invalid. We can argue if ST_CurveToLine is at fault here and if anything can be done about it or if that's just what you get with floating precision issues.

I think this might end up being a won't fix (I've downgrade from blocker to medium) but will leave that for others more knowledgeable to judge.

comment:2 by mjurce, 10 years ago

With ST_SimplifyPreserveTopology(geom,0.005) build area works. Why not pass to st_makeValid() the result of st_buildArea() before return?

ST_CurveToLine() definitely has to be improved as stated here #2464.

comment:3 by robe, 10 years ago

mjurce,

That would just cover under the blankets any issues. That's more like a workaround or something that should be done by the user.

For example with ST_SimplifyPreserveTopology the tolerance you would want depends on spatial ref so we can't hard code something there. Nor do I think we should cause you might not want any simplification.

As far as ST_MakeValid that does have the issue of giving you something you don't want. So I think those types of solutions should be left up to the discretion of the user.

comment:4 by mjurce, 10 years ago

Sure. But I need the work to be done. ST_SimplifyPreserveTopology was a workaround for precision issue of st_curvetoline.

For me fixed with a better hack: commented out in geos the part that discards not valid rings. Let the user decide about the result of st_buildArea().

comment:5 by robe, 10 years ago

Resolution: wontfix
Status: newclosed

Great. I'll close this out.

Note: See TracTickets for help on using tickets.