Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#4156 closed defect (fixed)

ST_ChaikinSmoothing not treating inner and outer rings the same

Reported by: komzpa Owned by: nicklas
Priority: medium Milestone: PostGIS 3.0.0
Component: postgis Version: master
Keywords: Cc:

Description

I'm calculating aligning isochrones and expect them to align after smoothing. However without passing the 'true' as last argument they don't align.

Change History (10)

comment:1 by nicklas, 6 years ago

Sounds strange

Do you have some data showing the issue, that you can share?

comment:2 by robe, 6 years ago

Milestone: PostGIS 2.5.0PostGIS 3.0.0

comment:3 by robe, 6 years ago

Owner: changed from pramsey to nicklas

comment:4 by nicklas, 6 years ago

I looked at this again and tried to figure out the issue. But what you write doesn't really make sense. Last argument is true by default. If the third argument is true by default or by setting it you will not get aligned lines in your polygones. That is because then the function will not touch the first and last vertex. That is default since it otherwilse will break any network of linestrings. But if you set the last parameter to false it will not preserve the first and last vertex and it should give you what you probably expect.

Please recheck and see if there is an issue and I will look into it, or set this as invalid.

comment:5 by komzpa, 6 years ago

Original report has a mistake, last parameter on polygons is expected to be "false".

Here are two inputs:

2-minute isochrone: 01030000A0110F0000020000003D000000A02DE8778A6A4741DCF43DC49B455B410000000000005E408C1ABB03856A4741889B33AA9D455B410000000000005E40435E0DCC846A4741A9A5ABBC9D455B410000000000005E40038240A0846A474179FF5DCC9D455B410000000000005E40514CC7DB706A4741CE3E2FACA4455B410000000000005E40C17DE14A6F6A47415539803CA5455B410000000000005E4028120FC95C6A4741839773AFAB455B410000000000005E4000850B985C6A4741A17564BEAB455B410000000000005E40E9FDC79C596A4741229DA6A9AC455B410000000000005E40C9DCA23E486A47410B3049ABB2455B410000000000005E409E53C11A456A47410017D69AB3455B410000000000005E40D7A4D524356A47411AEEC418B9455B410000000000005E40765EA0D6316A47410E4F132FBA455B41FFFFFFFFFFFF5D40952910412D6A4741B5A05199BB455B410000000000005E407796663D1E6A474198F289B9C0455B410100000000005E403517FF711C6A4741C1DEA34CC1455B410000000000005E405808A840176A47410871868DC2455B410000000000005E4063D7CD56096A47411E7A3B7BC7455B410000000000005E40D6087ADE056A47412A9FE63DC8455B410000000000005E40ADD066CBF66947413D2182A9CD455B410000000000005E404F6F14B5F4694741A91F1801CE455B410000000000005E40307120E7F169474125689C7ECE455B410000000000005E4054C60496E369474140D84BD8D3455B410000000000005E402D58EDE3E0694741CFD21844D4455B410000000000005E4049056B3FDB69474134DA8C25D5455B410000000000005E4031850713CC69474179E4D596DB455B410000000000005E40706778DBCB69474181A47E9DDB455B410000000000005E4050B4CFD7C46947412DE45E9EDE455B410000000000005E402E14C6A2C1694741F49E69F8DE455B410000000000005E4011974A83B8694741D47B040DE3455B410000000000005E4009D0841FB76947415BFD40C3E4455B410000000000005E406969C1CEAE6947413D67B8A3E7455B410000000000005E40D1DB0D1EAE694741F28845E1E7455B410000000000005E40D46842B9AE694741E1BDBD1FE8455B410000000000005E406EB69889B6694741E42C4C98E9455B410000000000005E401D9135CCB8694741A27A1100EA455B410000000000005E4029C648E3BC69474183612C57EA455B410000000000005E4020781B94BD694741E7462766EA455B410000000000005E40E0BF288FBE6947419CD77086EA455B410000000000005E408CC32E05D2694741125CB007EE455B410000000000005E404F412275EB6947412A2F2560E0455B410000000000005E40E5E85FC8EA69474176E9ADF1DD455B410000000000005E4030BF5ABBF9694741DDA74B75D5455B410000000000005E40765F887CFB694741BC573BFCD4455B410000000000005E407CA9082B0F6A474143415833D0455B410000000000005E40A9F4822B116A47411D9461A6CF455B410000000000005E409F28237E276A4741B02F2C7FCD455B410000000000005E40EF7EF23C2B6A4741DD83E36CCC455B410000000000005E408E161E382D6A47415986BEDFCB455B410000000000005E40F14AC36F2B6A4741A146E1AAC8455B410000000000005E408021F4EB3A6A4741443BC459C1455B410000000000005E406BAD98A53F6A4741305D1B29C1455B410000000000005E405C200F3A4F6A4741BE8C9B60B9455B410000000000005E4005B85664506A4741490AEABEB8455B410000000000005E40A8263EC2606A474110913894B0455B410000000000005E400808B147726A474196450ED6A7455B410000000000005E400CB1C75D746A474170129696A7455B410000000000005E40EF85FD18756A47413FFE0451A7455B410000000000005E40E5DFB1BD856A47416E434E529E455B410000000000005E402A7BAFE8856A47411E6884429E455B410000000000005E40A02DE8778A6A4741DCF43DC49B455B410000000000005E401D000000BB146AE4EC694741D2ABF568D7455B410000000000004E40E0614A10F86947413873323CD3455B410000000000004E406B061E87F8694741B94F6C27D3455B410000000000004E40A5378DDFF8694741C74CED18D3455B410000000000004E40EC4DD00A0C6A47419B466C34CC455B410000000000004E405668A4460D6A4741824D36EFCB455B410000000000004E40EA790FCA1E6A47419E870FBBC5455B410100000000004E40168F9541216A4741A5849E22C5455B410000000000004E40D204C47C236A47418715BA6BC4455B410000000000004E401432A027366A47413C613B0CBE455B410000000000004E402AD422B3376A474197602692BD455B410000000000004E40267C52D0386A4741B32A5B34BD455B410000000000004E400574993B4C6A47417E69C785B6455B410000000000004E406F817BA84C6A474147285565B6455B410000000000004E40372DBFA0556A4741AAE9334BB3455B410000000000004E40BDE3FBC24D6A47419C8F0938B7455B410000000000004E40633C959A4D6A4741B72CF04DB7455B410000000000004E4083C17A5A3C6A4741537612ECBF455B410000000000004E40B652CFC23A6A47410EA278FCBF455B410000000000004E40F91F6E98296A4741C740DA18C8455B410000000000004E4082D04E922B6A4741DDC2CBA6CB455B410000000000004E407E2292952A6A474151D521EDCB455B410000000000004E4034EDC4B7286A4741EBBFD075CC455B410000000000004E405A16610F106A4741E589AED6CE455B410000000000004E40DE5B2D590F6A4741DD7ECC08CF455B410000000000004E40601759A6F96947418141354FD4455B410000000000004E40B86D015CF969474183B83E63D4455B410000000000004E40B17D3963F26947414D166058D8455B410000000000004E40BB146AE4EC694741D2ABF568D7455B410000000000004E40

1-minute isochrone: 01030000A0110F0000010000001D000000372DBFA0556A4741AAE9334BB3455B410000000000004E406F817BA84C6A474147285565B6455B410000000000004E400574993B4C6A47417E69C785B6455B410000000000004E40267C52D0386A4741B32A5B34BD455B410000000000004E402AD422B3376A474197602692BD455B410000000000004E401432A027366A47413C613B0CBE455B410000000000004E40D204C47C236A47418715BA6BC4455B410000000000004E40168F9541216A4741A5849E22C5455B410000000000004E40EA790FCA1E6A47419E870FBBC5455B410000000000004E405668A4460D6A4741824D36EFCB455B410000000000004E40EC4DD00A0C6A47419B466C34CC455B410000000000004E40A5378DDFF8694741C74CED18D3455B410000000000004E406B061E87F8694741B94F6C27D3455B410000000000004E40E0614A10F86947413873323CD3455B410000000000004E40BB146AE4EC694741D2ABF568D7455B410000000000004E40B17D3963F26947414D166058D8455B410000000000004E40B86D015CF969474183B83E63D4455B410000000000004E40601759A6F96947418141354FD4455B410000000000004E40DE5B2D590F6A4741DD7ECC08CF455B410000000000004E405A16610F106A4741E589AED6CE455B410000000000004E4034EDC4B7286A4741EBBFD075CC455B410000000000004E407E2292952A6A474151D521EDCB455B410000000000004E4082D04E922B6A4741DDC2CBA6CB455B410000000000004E40F91F6E98296A4741C740DA18C8455B410000000000004E40B652CFC23A6A47410EA278FCBF455B410000000000004E4083C17A5A3C6A4741537612ECBF455B410000000000004E40633C959A4D6A4741B72CF04DB7455B410000000000004E40BDE3FBC24D6A47419C8F0938B7455B410000000000004E40372DBFA0556A4741AAE9334BB3455B410000000000004E40

They are nested and match inner-to-outer: https://ibb.co/h8g4Uz

I pass them through ST_ChaikinSmoothing:

update eventspace_isochrones set geom = ST_ChaikinSmoothing(geom, 2);

They don't match:

https://ibb.co/jVk9we

This is seen on all isochrones.

comment:6 by nicklas, 6 years ago

Then I agree with you about the results. But I don't see why you expect something else. If the last parameter is true (as default or explicit) then the start point and end point of each ring is preserved (not moved). As mentioned above, that is to not break networks.

So, what you see is that in your small polygon the start and end point is in the lower right corner. So, that is not moved (still sharp), but the inner ring of the large polygon have the start and end point in the upper left corner so that is not moved. This gives a mismatch both in the upper left corner and in the lower right corner. You see the same thing in the lower right corner of the large polygon. That is still sharp after smoothing, so it seems like that is the start and end of the outer ring.

If you set the last parameter to false, those start and end points will not be preserved and the rings align.

Maybe this is unclear in the doc?

comment:7 by komzpa, 6 years ago

Why don't we change default to false, to have less surprise?

What is "network" that true will preserve, for polygon input? I can only see the use for it with LINESTRING input.

comment:8 by nicklas, 6 years ago

Yes, that is valid points.

But I think it is different what different people find as surprise?

I agree that this default behavior not is very useful for polygons. The networks I mentioned is linestrings.

The reason for this behavior anyway is that I wanted the same default behavior for all geometry types. I thought that would give less surprises.

This is also the behavior for ST_Simplify and ST_SimplifyVW, which I think people might relate this function to.

select st_simplify(geom, 2) geom from 
(
  select 'polygon((10 10, 11 15, 15 15, 16 10, 15 5, 11 5, 10 10))'::geometry geom 
)a

I don't have any strong personal feelings about this, so if people wants this changed I have no problem with that.

But now it is also too late for 2.5 so it will be a breaking change in PostGIS 3.0 which is a good place to put breaking changes of course).

comment:9 by komzpa, 6 years ago

Resolution: fixed
Status: newclosed

In 16827:

ST_ChaikinSmoothing: also smooth start/end point of polygon by default

Closes #4156
Closes https://github.com/postgis/postgis/pull/305

comment:10 by komzpa, 6 years ago

In 16828:

ST_ChaikinSmoothing: also smooth start/end point of polygon by default

Closes #4156
Closes https://github.com/postgis/postgis/pull/305

Note: See TracTickets for help on using tickets.