Opened 8 years ago
Closed 7 years ago
#3685 closed defect (worksforme)
Topolgy error after ST_AsGeoJSON
Reported by: | JJTl | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.4.0 |
Component: | postgis | Version: | 2.3.x |
Keywords: | ST_AsGeoJSON, topology error | Cc: |
Description
ST_AsGeoJSON() in some cases transforms valid geometry to not valid.
Control example:
SELECT ST_IsValidDetail(taste.geom) As before_ST_AsGeoJSON, ST_IsValidDetail(ST_SetSRID(ST_GeomFromGeoJSON(ST_AsGeoJSON(taste.geom)), 4326)) As after_ST_AsGeoJSON FROM (SELECT '0106000020E610000002000000010300000002000000920000001166BA9C73793E40F787971FD62F4940DD5BEDB356793E4019AFC002CE2F494076A7DCC10D793E40FAAF8DCFB92F4940893F7793C3783E403D15C088A52F494052A76C2D78783E40D98D9F2F912F4940711180942B783E403BF474C57C2F4940BD1288CDDD773E4085398A4B682F4940F5536EDD8E773E40A5502AC3532F4940D5422FC93E773E40A219A12D3F2F4940D1C0D995ED763E40B04C3B8C2A2F4940B8D18E489B763E400F6546E0152F4940D8345A0167763E4070739BE4082F49405D8CDF207E753E40422C52AD772F4940B1F603740C733E400FAF8F1CB82E494096AE517BCA713E40989F98A9462E4940FD097D676E713E401A9C1628452E4940F2FD46CF02703E401B8907A5242E4940455F6D00D56F3E40845273F6DD2D494013B1B282666F3E40AADAF3E0E02D4940FD8850F7206F3E405B35E72C6E2E4940FEB2FC112A6F3E40A2F507D39B2E4940C86270EACC703E403F373C5DBC2E4940A1A8D968DA703E40A93EA452292F494016648565CE713E40D9AEF2482F2F4940E042971F01723E40AB1AA9DB112F4940EF897F25D0723E402FA976005D2F494068E41B7578723E40781EAA8CA92F4940F787744D27733E4078B2D506E32F4940139C1A42C8733E40562021E03C3049405FF3281720723E40D0DBB294E43049405E4C7BCEAC713E40A478116109314940CFD5724F55713E40004773580931494012041134D4703E403816049F48314940C186E53EF4703E4089CA84E18A314940C04C8BB61B703E4028BC3E3C8F314940FB7D0BF0676F3E404F9A46C4BF3149403DEDA57C8A6E3E40DCCC5D611F3249405CBA4600616E3E40693C83252B32494006A69792BF6D3E40B57182926132494025A37B155D6D3E40FFFBAFFE823249403A3A4800B76D3E402148EA7C8E3249401B3A6C3D1D6E3E408051015E9B324940BFF71FEF826E3E409A0CF7FCA73249404F0DF70EE86E3E40ECCEFF58B4324940D94B8E964C6F3E4045275471C03249401C228C7FB06F3E4013EA3045CC3249407603A1C313703E40B63DD7D3D7324940CBCD875C76703E407DA68C1CE3324940072F0644D8703E4049129B1EEE324940ED09ED7339713E40E9E350D9F832494099D918E699713E4054FE004C0333494076157294F9713E4078CF02760D3349401393ED7858723E409C5AB2561733494092E88C8DB6723E40F84270ED203349409ECC5ECC13733E404BD5A1392A3349406E17A1E26F733E40B532333333334940217171F78B763E40B53233333333494017F2BC599E763E40AF36582C2033494017923486A7763E40D50D5D2C20334940E3B0D400BA763E403CA5911F23334940118E5B2DC3763E4018A56B2C20334940CF88797EFA763E400BD5882C203349401574E0BB03773E40B2DD62391D334940311458E80C773E40D9B467391D334940EDD3BE2516773E40B4C5B14E1A33494023228E8F28773E40DA7CBB4E1A334940690DF5CC31773E408185955B17334940A2AD6CF93A773E40A85C9A5B1733494087860A774D773E40726F4E7511334940B5E9DBB456773E400B9ED4E5F93249406555BCF25F773E40ABFE076DDF324940EC51E3997B773E40C395166DDF324940E98D1CD784773E402C230952E5324940F3A1AC4397773E401AB33D45E8324940E87E3370A0773E40CBB21752E5324940F026D9FBE0773E40EEC03952E5324940D3D8073C18783E40FEBE8145E8324940834A507921783E405776B138EB32494037AEB8A52A783E40D724E12BEE324940F5C108E333783E40D86FC7A4EF324940032841123D783E40D31FF797F2324940AEE858B958783E40458E308BF532494008FB18236B783E40B61C657EF8324940450DD98C7D783E4036AB9971FB324940554212CA86783E40043AF45701334940A4AF4AF98F783E40A8E8BB490433494098E4833699783E40777716300A3349401F80AF62A2783E40897B81E718334940C6597A62A2783E40B6647331233349401DBEE52499783E4017E1B1FC2E3349405C0F8EE78F783E401701ADFC2E3349408CD28E988C783E40B53233333333494005FEFFFFFF7F3E40B532333333334940E7FEFFFFFF7F3E404432333333334940895B238F0E803E40A82AE4312A334940005DB4701B803E40304A73E52033494099B9E2A326803E409A94764E17334940C756F92730803E4002C1886D0D3349401A555EFC37803E403E30494303334940461993203E803E40D4E25BD0F8324940D554349442803E40AF6E6915EE324940D90BFA5645803E40BEF41E13E3324940E399B76846803E40F2152ECAD73249406EB45BC945803E4032E84C3BCC324940656CF07843803E40DFEA3567C03249402C2D9B773F803E403AFBA74EB432494084BA9CC539803E40844866F2A73249400C2C516332803E408E4738539B32494013E82F5129803E4062A6E9718E324940799BCB8F1E803E407A3F4A4F813249408C30D21F12803E40AF0C2EEC733249405DC40C0204803E40E9196D4966324940B0995F37F47F3E40D477E367583249408B0ACAC0E27F3E40BA2D71484A324940A378669FCF7F3E40AF2BFAEB3B324940DD3A6AD4BA7F3E40233C66532D324940D9892561A47F3E40ACF5A07F1E3249402E6B03478C7F3E40D1AB99710F324940309A8987727F3E405660432A00324940006F5824577F3E40C6B394AAF031494008C52A1F3A7F3E4055D687F3E031494011DED5791B7F3E40B5771A06D131494071454936FB7E3E408AB74DE3C0314940A7F121B0F57E3E408E4D2139BE314940F9DC05F7E57E3E40F2F835AFBA3149409C36032D7A7D3E409423CF0C713149403FE45752D67D3E40975B93985331494066BBB452D67D3E40B86B2D9B41314940FB60D4E3BF7D3E40D64740C8383149407C971D78917D3E407FE262F426314940B4351287617D3E409519E0F5143149403573B913307D3E40E584DACD0231494005EE3221FD7C3E40235D777DF0304940E877B6B2C87C3E409B69DE05DE30494023E393CB927C3E408FED3968CB304940DCCB326F5B7C3E408495B6A5B8304940FC6112A1227C3E403E6483BFA53049400230C964E87B3E40C89FD1B69230494050E104BEAC7B3E4061BED48C7F304940C4068AB06F7B3E40BD52C2426C30494046D93340317B3E4012F9D1D95830494034FCF370F17A3E4013433D5345304940D63CD246B07A3E4076A43FB031304940931265C9C57A3E40FF38992B383049402865A229D8793E401FFF432F3D3049401166BA9C73793E40F787971FD62F49401C000000B1A5B9D889773E40F849D239FB31494019C7E75029773E40B021EB789B31494022D30A33DB763E40EEA81E6B3431494020BAC3ADA8763E40A8D2E85BE63049407876FEFC83763E4033FBA0DDAF3049407A89B6C9FB763E409180A8AD863049407FD5E7A88A773E406D151D1D56304940659C070DD9773E4092D3D5433430494055D8DF4A10783E40291C9FA71F304940EA7835F342783E400F9D46ED2C304940BD82960AE4783E404752B32E563049404CCCE38DBA783E405E5E202372304940529D15E69E783E404EFFA88A923049408FF1D52B6C783E40B81C73D1B8304940ABC3281A6C783E40B15D3991E030494004E2EF83AC783E4056054976E63049407D05A6031B793E406236D8C50C314940B97C12AC4D793E4023740B9E15314940627768303B793E40577DD82E46314940C1DB6D14E8783E40BE3E6257A7314940128AC551F1783E40861E6757A7314940748D3500BA783E40C7357F6CBD31494037E2B359E3783E4008936798E9314940F7D4A8B1C7783E40FE882BC415324940525BF047B5783E40C48F155811324940EFBAE76179783E40BC3802C415324940F5A9B92A06783E40FF16ABA11B324940B1A5B9D889773E40F849D239FB31494001030000000100000004000000A7F121B0F57E3E408E4D2139BE314940C7F121B0F57E3E40954D2139BE31494067B08E56D97E3E402115268CB0314940A7F121B0F57E3E408E4D2139BE314940'::geometry As geom) As taste;
Result:
before_ST_AsGeoJSON | (t,,) |
---|---|
after_ST_AsGeoJSON | (f,Selfintersection,0101000000A9F121B0F57E3E40874D2139BE314940) |
I see this bug in 2.2.x too.
Attachments (1)
Change History (7)
by , 8 years ago
comment:1 by , 8 years ago
Making a round-trip transformation between binary floating point numbers and text is a recipe for trouble, unfortunately. ST_AsGeoJSON produces output with a maximum of 15 digits, which is not enough to use it as a lossless serialization format. Maybe the docs should note this, or use more digits like pg_dump?
If you run this geometry through ST_MinimumClearance, you'll see that it returns an exceedingly low value of 2.2e-14. That means that, you have a vertex somewhere that, if moved by 2e-14, will cause the geometry to be invalid. In other words, not a very robust geometry.
comment:2 by , 8 years ago
Milestone: | PostGIS PostgreSQL → PostGIS 2.4.0 |
---|
comment:3 by , 8 years ago
Well. Geometry is not a very robust. What I can do with this by PostGIS? Geometry is in degrees with CRS 4326.
comment:4 by , 8 years ago
You could ST_MakeValid(ST_SnapToGrid()) it to the grid size you agree on tollerating.
comment:6 by , 7 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
control example