t-rex-tileserver / t-rex

t-rex is a vector tile server specialized on publishing MVT tiles from your own data
https://t-rex.tileserver.ch/
MIT License
545 stars 68 forks source link

corrupted polygon area with simplify #238

Closed gozell closed 2 years ago

gozell commented 3 years ago

hello, with T-Rex v0.12.0 and v.013.0 and simplify = true we get a corrupted area: Bildschirmfoto von 2021-03-09 15-29-42

With T-Rex v0.11.0 the area is not corrupted: Bildschirmfoto von 2021-03-09 15-32-58

With simplify = false the areas in all T-Rex versions are valid. In the changelog 0.12.0.0 there was a Bug Fix in polygon simplification - can this cause the problem ?

See here in the North of Germany (Zoom 7): https://adv-smart.de/map-editor/map

Here is a WKT of the area, which produced the error:

SELECT ST_GeomFromText('POLYGON((1376278.48 7231699.26,1375968.72 7231083.12,1375725.77 7230672.73,1375248.86 7229798.640000001,1374856.24 7229145.29,1374449.04 7228521.47,1374046.56 7227878.7,1373424.99 7226879.94,1373104.05 7226485.36,1372554.57 7225902.890000001,1371800.6500000001 7225205.61,1371399.86 7224893.53,1370174.55 7223920.13,1369766.53 7223656.16,1369197.29 7223296.8,1367858.6500000001 7222560.62,1367623.7 7222453.33,1367300.59 7222303.65,1366718.26 7222030.11,1366292.19 7221788.73,1365218.5 7221039.01,1364301.42 7220401.890000001,1362927.33 7219571.890000001,1362731.97 7219461.65,1361693.27 7218875.38,1360735.8900000001 7218391.3100000005,1360091.6500000001 7218004.23,1358722.91 7217074.41,1358288.85 7216761.08,1357698 7216309.350000001,1357412.51 7216069.5600000005,1356819.82 7215458.73,1355795.3800000001 7214248.8,1355367.8900000001 7213687.24,1354775.25 7212688.2,1354383.61 7211970.2700000005,1354060.24 7211326.07,1353751.22 7210710.66,1353546.51 7210332.29,1352930.1 7209241.75,1352348.74 7208338.5600000005,1351811.61 7207501.09,1351279.33 7206800.3,1350894.3 7206354.29,1349890.1 7205429.91,1349364.77 7205031.45,1348717.43 7204586.11,1348021.05 7204155.49,1347722.96 7204086.86,1347262.32 7204146.48,1347034.1400000001 7204235.18,1346752.09 7204434.390000001,1346552.6300000001 7204590.8,1346392.87 7204770.26,1346151.49 7204697.67,1346126.92 7204690.600000001,1346102.35 7204683.54,1345905.35 7204613.4,1345658.01 7204526.5,1345477.9000000001 7205186.51,1344732.72 7204700.25,1344271.47 7204414.59,1343865.32 7204233.67,1342492.02 7203938.38,1341069.97 7203751.53,1339556.8 7203687.63,1338968.07 7203735.8,1338440.91 7203794.600000001,1337756.99 7203938.61,1337378.3900000001 7204011.350000001,1337093.9000000001 7204018.93,1336758.03 7203931.88,1335684.8900000001 7203461.87,1335135.22 7203251.01,1332953.31 7202294.18,1331657.92 7201765.01,1331101.61 7201637.75,1330363.23 7201522.59,1330008.84 7201437.36,1329254.33 7201192.63,1328305.52 7200854.29,1327552.26 7200580.37,1326562.09 7200210.21,1324656.3900000001 7199348.66,1323806.78 7199009.69,1322709.54 7198632.640000001,1321195.57 7198188.140000001,1320132.42 7197866.83,1319587.96 7197736.57,1319186.62 7197675.69,1318792.56 7197640.26,1318139.96 7197623.2,1317575.26 7197662.5200000005,1316204.52 7197771.0200000005,1315437.1400000001 7197849.69,1314689.82 7197926.24,1312806.92 7198260.100000001,1312098.36 7198453.5200000005,1311597.36 7198634.72,1311191.46 7198800.57,1310789.59 7199003.9,1310343.61 7199218.22,1309870.35 7199433,1309441.91 7199580.390000001,1309171.6400000001 7199614.07,1308675.59 7199593.55,1307326.1300000001 7199372.390000001,1306429.3900000001 7199327.79,1305440.2 7199356.350000001,1303849.48 7199370.850000001,1302694.36 7199461.57,1301941.66 7199473.88,1300855.53 7199407.850000001,1300454.21 7199344.33,1300164.1 7199203.88,1299822.6400000001 7198941.32,1299079.36 7198149.15,1298399.72 7197388.41,1297338.93 7196201.890000001,1296571.06 7195329.94,1295328.83 7193934.74,1294755.56 7193293.57,1294235.8800000001 7192590.18,1293777.74 7192010.4,1293349.74 7191506.93,1292795.4000000001 7190971.2700000005,1292143.3900000001 7190385.93,1291496.1300000001 7189884.0600000005,1290914.07 7189527.850000001,1290451.1500000001 7189287.5,1290024.84 7189104.57,1289386.6500000001 7188972.48,1288280.42 7188941,1287902 7188888.55,1287584.44 7188809.62,1287146.31 7188626.72,1286849.3800000001 7188443.46,1286324.76 7188038.42,1286007.36 7187729.28,1285851.61 7187542.28,1285244.26 7186693.48,1285115.1300000001 7186461.79,1284977.36 7186219.99,1284793.69 7185978.86,1283962.73 7185053.2,1282973.37 7183848.600000001,1282927.19 7183706.11,1282934.17 7183596.95,1282941.04 7183479.28,1283048.56 7183387.47,1282802.5 7183174.51,1282658.79 7183231.04,1282551.21 7183196.75,1282451.27 7183099.32,1281504.86 7181028.83,1281428.11 7180760.75,1281398.1500000001 7180435.82,1281368.81 7179039.61,1281494.03 7177641.5,1281536.46 7177514.91,1281635.43 7177423.3,1281742.29 7177411.61,1281868.61 7177455.83,1282318.24 7176187.98,1282217.75 7176044.67,1282143.95 7175866.94,1282039.12 7175408.76,1282026.33 7175219.98,1282078.67 7175074.5600000005,1282202.81 7174963.9,1282400.86 7174916.890000001,1283217.56 7174905.49,1283782.58 7174870.32,1283917.53 7174805.44,1283997.43 7174690.2700000005,1284005.1300000001 7174513.140000001,1283972.26 7174227.65,1283896.3 7173896.83,1283812.9000000001 7173761.84,1283650.12 7173656.91,1283180.87 7173491.600000001,1282413.71 7173269.15,1282133.36 7173131.79,1281883.12 7172961.67,1281401.8900000001 7172536.07,1281225.76 7172320.68,1281106.46 7172162.37,1281022.75 7172000.17,1280921.29 7171780.350000001,1280834.01 7171356.17,1280788.42 7171125.41,1280702.67 7170936.0200000005,1280247.1400000001 7170265.13,1280161.44 7170079.17,1279911.43 7169414.03,1279822.71 7169253.640000001,1279691.03 7169178.88,1279393.22 7169118.28,1279264.57 7169016.26,1278939.6400000001 7169968.140000001,1279077.96 7170030.92,1279177.96 7170146.95,1279270.69 7170353.25,1279675.01 7172391.22,1279782.83 7173082.37,1279787.11 7173398.850000001,1279704.79 7173966.72,1279635.92 7174148.07,1279502.03 7174292.850000001,1279325.11 7174395.67,1278868.3800000001 7174527.79,1278177.45 7174671.54,1277210.09 7174846.140000001,1276850.49 7174878.140000001,1276500.49 7174865.73,1275833.6 7174774.07,1275321.24 7174682.04,1245040.3900000001 7172903.5200000005,1240772.3900000001 7187705.07,1240703.6400000001 7187943.23,1240634.82 7188181.68,1240566.1500000001 7188419.57,1240497.4000000001 7188657.75,1240428.6400000001 7188895.94,1239895.73 7190739.29,1234976.42 7207758.55,1235010.18 7207927.46,1235011.3900000001 7208077.84,1234922.31 7208449.41,1234753.74 7209327.55,1234701.62 7210695.45,1234578.24 7211900.0200000005,1234438.28 7212744.09,1234375.85 7213058.44,1234070.85 7214593.95,1233926.47 7215323.72,1233780.74 7216315.3,1233726.74 7216970.38,1233698.19 7217316.75,1233686.11 7218379.36,1233954.1500000001 7222685.16,1233969.01 7223051.41,1233953.09 7223412.79,1233893.44 7223861.86,1233796.6300000001 7224364.32,1233168.3 7227025.55,1233074.98 7227548.73,1232904.59 7228709.84,1232788.46 7232232.19,1232774.37 7232619.67,1232487.68 7234903.61,1232543.52 7235226.12,1232615.91 7235587.08,1232689.98 7235799.91,1232764.59 7235891.91,1232890.56 7235987.62,1232940.2 7236036.61,1232965.1500000001 7236137.21,1233185.98 7236206.86,1233270.76 7236458.79,1233468.75 7236911.93,1233640.96 7237289.51,1233971.74 7237669.890000001,1234122.07 7237825.09,1234494.99 7238207.7,1234967.75 7238645.3,1235167.1400000001 7238780.76,1235929.11 7239144.63,1236114.74 7239266.47,1236266.41 7239416.01,1236460.18 7239695.42,1236625.8800000001 7239885.97,1237149.3 7240327.16,1237472.61 7240550.66,1237637.31 7240617.82,1237877.25 7240684.350000001,1237980.24 7240731.46,1238069.72 7240799.25,1238421.54 7241152.74,1238532.1300000001 7241288.91,1238678.79 7241644.15,1238770.92 7242020.44,1238892.53 7242643.34,1238941.76 7242800.62,1239060.46 7243080.74,1239109.99 7243272.3100000005,1239146.42 7243532.57,1239150.41 7243882.58,1243547.6400000001 7246279.47,1243972.8800000001 7246512.51,1244229.32 7246642.350000001,1244463.91 7246817.03,1244609.09 7246956.48,1245285.33 7247827.640000001,1245325.3800000001 7247895.95,1246345.9000000001 7247829.67,1246472.54 7247814.73,1246616.91 7247861.44,1246860.28 7248049.73,1247011.91 7248139.3,1248004.9000000001 7248414.8100000005,1248684.33 7248507.8,1249600.1 7248586.390000001,1251231.78 7248630.2,1251951.12 7248597.15,1253376.76 7248266.5200000005,1254284.6 7247910.18,1254727.24 7247639.37,1255032.37 7247491.91,1257154.83 7246988.44,1259102.59 7246666.66,1259282.85 7246700.72,1259349.99 7246730.890000001,1282171.35 7249567.38,1284434.18 7247587.94,1290031.33 7241108.84,1296246.95 7233043.98,1298736.96 7233079.43,1308609.5 7233213.850000001,1309064.09 7233219.75,1309518.69 7233225.63,1309973.29 7233231.48,1310427.8800000001 7233237.3100000005,1330447.6500000001 7233468.78,1336280.54 7236051.140000001,1337635.67 7236650.37,1345865.5 7240283.82,1351003.31 7242547.12,1352804.74 7243339.76,1354227.19 7243339.79,1364617.08 7255935.07,1366011.75 7259425.41,1389790.43 7262043.53,1393281.54 7262422.2,1393015.71 7262307.32,1392726.67 7262096.71,1392431 7261831.22,1392054.72 7261378.65,1391713.74 7260833.94,1391257.6400000001 7259857.49,1390835.44 7258953.49,1390099.67 7257253.54,1389188.41 7254757.41,1388914.54 7253907.8,1388335.4000000001 7252110.86,1388096.77 7251266.58,1387851.9000000001 7250572.04,1387497.1500000001 7249741.32,1386741.06 7248253.12,1386231.58 7247395.79,1385798.23 7246821.61,1385459.96 7246406.37,1385264.86 7246155.65,1383830.3 7244311.48,1383716.42 7244214.890000001,1383379.02 7243955.92,1382897.96 7243573.65,1381359.04 7242290.26,1381107.94 7242051.33,1380874.67 7241772.45,1380714.6 7241476.23,1380431.7 7240865.68,1379873.7 7239610.17,1379308.86 7238348.13,1379021.87 7237770.48,1378710.42 7237164.99,1378370.32 7236454.29,1377313.34 7233922.43,1377024.6500000001 7233266.19,1376817.24 7232777.66,1376485.54 7232108.88,1376278.48 7231699.26),(1278685.48 7174945.58,1278786.95 7174913.57,1279196.79 7174955.71,1279469.86 7174929.88,1279565.08 7174938.8100000005,1279628.6 7174989.01,1279654.96 7175055.04,1279737.8800000001 7175535.66,1279788.16 7175611.58,1279851.61 7175656.68,1280048.23 7175752.74,1280105.09 7175813.25,1280116.11 7175874.390000001,1280076.4000000001 7175951.54,1279767.05 7176185.57,1279675.48 7176197.03,1279588.46 7176167.57,1279521.4000000001 7176107.19,1278684.91 7175156.66,1278648.21 7175078.850000001,1278645.44 7174998.890000001,1278685.48 7174945.58))')
pka commented 3 years ago

Simplification in 0.11 was more simple than in 0.13 :thinking:

0.11: SELECT COALESCE(ST_SnapToGrid(ST_Multi(geometry), $5::FLOAT8/2),ST_GeomFromText('MULTIPOLYGON EMPTY',3857))::geometry(MULTIPOLYGON,3857) AS geometry

0.13: SELECT ST_CollectionExtract(ST_MakeValid(ST_Multi(ST_Buffer(ST_SnapToGrid(ST_Multi(geometry), $5::FLOAT8/2), 0.0))),3)::geometry(MULTIPOLYGON,3857) AS geometry

Since 0.11 is a subset of 0.13, it should be possible to make the additional geometry fixing efforts optional.

pka commented 3 years ago

Looking at the whole simplified geometry, both queries look good.

0.11:

WITH t AS (
  SELECT ST_GeomFromEWKT('SRID=3857;POLYGON((1376278.48 7231699.26,1375968.72 7231083.12,1375725.77 7230672.73,1375248.86 7229798.640000001,1374856.24 7229145.29,1374449.04 7228521.47,1374046.56 7227878.7,1373424.99 7226879.94,1373104.05 7226485.36,1372554.57 7225902.890000001,1371800.6500000001 7225205.61,1371399.86 7224893.53,1370174.55 7223920.13,1369766.53 7223656.16,1369197.29 7223296.8,1367858.6500000001 7222560.62,1367623.7 7222453.33,1367300.59 7222303.65,1366718.26 7222030.11,1366292.19 7221788.73,1365218.5 7221039.01,1364301.42 7220401.890000001,1362927.33 7219571.890000001,1362731.97 7219461.65,1361693.27 7218875.38,1360735.8900000001 7218391.3100000005,1360091.6500000001 7218004.23,1358722.91 7217074.41,1358288.85 7216761.08,1357698 7216309.350000001,1357412.51 7216069.5600000005,1356819.82 7215458.73,1355795.3800000001 7214248.8,1355367.8900000001 7213687.24,1354775.25 7212688.2,1354383.61 7211970.2700000005,1354060.24 7211326.07,1353751.22 7210710.66,1353546.51 7210332.29,1352930.1 7209241.75,1352348.74 7208338.5600000005,1351811.61 7207501.09,1351279.33 7206800.3,1350894.3 7206354.29,1349890.1 7205429.91,1349364.77 7205031.45,1348717.43 7204586.11,1348021.05 7204155.49,1347722.96 7204086.86,1347262.32 7204146.48,1347034.1400000001 7204235.18,1346752.09 7204434.390000001,1346552.6300000001 7204590.8,1346392.87 7204770.26,1346151.49 7204697.67,1346126.92 7204690.600000001,1346102.35 7204683.54,1345905.35 7204613.4,1345658.01 7204526.5,1345477.9000000001 7205186.51,1344732.72 7204700.25,1344271.47 7204414.59,1343865.32 7204233.67,1342492.02 7203938.38,1341069.97 7203751.53,1339556.8 7203687.63,1338968.07 7203735.8,1338440.91 7203794.600000001,1337756.99 7203938.61,1337378.3900000001 7204011.350000001,1337093.9000000001 7204018.93,1336758.03 7203931.88,1335684.8900000001 7203461.87,1335135.22 7203251.01,1332953.31 7202294.18,1331657.92 7201765.01,1331101.61 7201637.75,1330363.23 7201522.59,1330008.84 7201437.36,1329254.33 7201192.63,1328305.52 7200854.29,1327552.26 7200580.37,1326562.09 7200210.21,1324656.3900000001 7199348.66,1323806.78 7199009.69,1322709.54 7198632.640000001,1321195.57 7198188.140000001,1320132.42 7197866.83,1319587.96 7197736.57,1319186.62 7197675.69,1318792.56 7197640.26,1318139.96 7197623.2,1317575.26 7197662.5200000005,1316204.52 7197771.0200000005,1315437.1400000001 7197849.69,1314689.82 7197926.24,1312806.92 7198260.100000001,1312098.36 7198453.5200000005,1311597.36 7198634.72,1311191.46 7198800.57,1310789.59 7199003.9,1310343.61 7199218.22,1309870.35 7199433,1309441.91 7199580.390000001,1309171.6400000001 7199614.07,1308675.59 7199593.55,1307326.1300000001 7199372.390000001,1306429.3900000001 7199327.79,1305440.2 7199356.350000001,1303849.48 7199370.850000001,1302694.36 7199461.57,1301941.66 7199473.88,1300855.53 7199407.850000001,1300454.21 7199344.33,1300164.1 7199203.88,1299822.6400000001 7198941.32,1299079.36 7198149.15,1298399.72 7197388.41,1297338.93 7196201.890000001,1296571.06 7195329.94,1295328.83 7193934.74,1294755.56 7193293.57,1294235.8800000001 7192590.18,1293777.74 7192010.4,1293349.74 7191506.93,1292795.4000000001 7190971.2700000005,1292143.3900000001 7190385.93,1291496.1300000001 7189884.0600000005,1290914.07 7189527.850000001,1290451.1500000001 7189287.5,1290024.84 7189104.57,1289386.6500000001 7188972.48,1288280.42 7188941,1287902 7188888.55,1287584.44 7188809.62,1287146.31 7188626.72,1286849.3800000001 7188443.46,1286324.76 7188038.42,1286007.36 7187729.28,1285851.61 7187542.28,1285244.26 7186693.48,1285115.1300000001 7186461.79,1284977.36 7186219.99,1284793.69 7185978.86,1283962.73 7185053.2,1282973.37 7183848.600000001,1282927.19 7183706.11,1282934.17 7183596.95,1282941.04 7183479.28,1283048.56 7183387.47,1282802.5 7183174.51,1282658.79 7183231.04,1282551.21 7183196.75,1282451.27 7183099.32,1281504.86 7181028.83,1281428.11 7180760.75,1281398.1500000001 7180435.82,1281368.81 7179039.61,1281494.03 7177641.5,1281536.46 7177514.91,1281635.43 7177423.3,1281742.29 7177411.61,1281868.61 7177455.83,1282318.24 7176187.98,1282217.75 7176044.67,1282143.95 7175866.94,1282039.12 7175408.76,1282026.33 7175219.98,1282078.67 7175074.5600000005,1282202.81 7174963.9,1282400.86 7174916.890000001,1283217.56 7174905.49,1283782.58 7174870.32,1283917.53 7174805.44,1283997.43 7174690.2700000005,1284005.1300000001 7174513.140000001,1283972.26 7174227.65,1283896.3 7173896.83,1283812.9000000001 7173761.84,1283650.12 7173656.91,1283180.87 7173491.600000001,1282413.71 7173269.15,1282133.36 7173131.79,1281883.12 7172961.67,1281401.8900000001 7172536.07,1281225.76 7172320.68,1281106.46 7172162.37,1281022.75 7172000.17,1280921.29 7171780.350000001,1280834.01 7171356.17,1280788.42 7171125.41,1280702.67 7170936.0200000005,1280247.1400000001 7170265.13,1280161.44 7170079.17,1279911.43 7169414.03,1279822.71 7169253.640000001,1279691.03 7169178.88,1279393.22 7169118.28,1279264.57 7169016.26,1278939.6400000001 7169968.140000001,1279077.96 7170030.92,1279177.96 7170146.95,1279270.69 7170353.25,1279675.01 7172391.22,1279782.83 7173082.37,1279787.11 7173398.850000001,1279704.79 7173966.72,1279635.92 7174148.07,1279502.03 7174292.850000001,1279325.11 7174395.67,1278868.3800000001 7174527.79,1278177.45 7174671.54,1277210.09 7174846.140000001,1276850.49 7174878.140000001,1276500.49 7174865.73,1275833.6 7174774.07,1275321.24 7174682.04,1245040.3900000001 7172903.5200000005,1240772.3900000001 7187705.07,1240703.6400000001 7187943.23,1240634.82 7188181.68,1240566.1500000001 7188419.57,1240497.4000000001 7188657.75,1240428.6400000001 7188895.94,1239895.73 7190739.29,1234976.42 7207758.55,1235010.18 7207927.46,1235011.3900000001 7208077.84,1234922.31 7208449.41,1234753.74 7209327.55,1234701.62 7210695.45,1234578.24 7211900.0200000005,1234438.28 7212744.09,1234375.85 7213058.44,1234070.85 7214593.95,1233926.47 7215323.72,1233780.74 7216315.3,1233726.74 7216970.38,1233698.19 7217316.75,1233686.11 7218379.36,1233954.1500000001 7222685.16,1233969.01 7223051.41,1233953.09 7223412.79,1233893.44 7223861.86,1233796.6300000001 7224364.32,1233168.3 7227025.55,1233074.98 7227548.73,1232904.59 7228709.84,1232788.46 7232232.19,1232774.37 7232619.67,1232487.68 7234903.61,1232543.52 7235226.12,1232615.91 7235587.08,1232689.98 7235799.91,1232764.59 7235891.91,1232890.56 7235987.62,1232940.2 7236036.61,1232965.1500000001 7236137.21,1233185.98 7236206.86,1233270.76 7236458.79,1233468.75 7236911.93,1233640.96 7237289.51,1233971.74 7237669.890000001,1234122.07 7237825.09,1234494.99 7238207.7,1234967.75 7238645.3,1235167.1400000001 7238780.76,1235929.11 7239144.63,1236114.74 7239266.47,1236266.41 7239416.01,1236460.18 7239695.42,1236625.8800000001 7239885.97,1237149.3 7240327.16,1237472.61 7240550.66,1237637.31 7240617.82,1237877.25 7240684.350000001,1237980.24 7240731.46,1238069.72 7240799.25,1238421.54 7241152.74,1238532.1300000001 7241288.91,1238678.79 7241644.15,1238770.92 7242020.44,1238892.53 7242643.34,1238941.76 7242800.62,1239060.46 7243080.74,1239109.99 7243272.3100000005,1239146.42 7243532.57,1239150.41 7243882.58,1243547.6400000001 7246279.47,1243972.8800000001 7246512.51,1244229.32 7246642.350000001,1244463.91 7246817.03,1244609.09 7246956.48,1245285.33 7247827.640000001,1245325.3800000001 7247895.95,1246345.9000000001 7247829.67,1246472.54 7247814.73,1246616.91 7247861.44,1246860.28 7248049.73,1247011.91 7248139.3,1248004.9000000001 7248414.8100000005,1248684.33 7248507.8,1249600.1 7248586.390000001,1251231.78 7248630.2,1251951.12 7248597.15,1253376.76 7248266.5200000005,1254284.6 7247910.18,1254727.24 7247639.37,1255032.37 7247491.91,1257154.83 7246988.44,1259102.59 7246666.66,1259282.85 7246700.72,1259349.99 7246730.890000001,1282171.35 7249567.38,1284434.18 7247587.94,1290031.33 7241108.84,1296246.95 7233043.98,1298736.96 7233079.43,1308609.5 7233213.850000001,1309064.09 7233219.75,1309518.69 7233225.63,1309973.29 7233231.48,1310427.8800000001 7233237.3100000005,1330447.6500000001 7233468.78,1336280.54 7236051.140000001,1337635.67 7236650.37,1345865.5 7240283.82,1351003.31 7242547.12,1352804.74 7243339.76,1354227.19 7243339.79,1364617.08 7255935.07,1366011.75 7259425.41,1389790.43 7262043.53,1393281.54 7262422.2,1393015.71 7262307.32,1392726.67 7262096.71,1392431 7261831.22,1392054.72 7261378.65,1391713.74 7260833.94,1391257.6400000001 7259857.49,1390835.44 7258953.49,1390099.67 7257253.54,1389188.41 7254757.41,1388914.54 7253907.8,1388335.4000000001 7252110.86,1388096.77 7251266.58,1387851.9000000001 7250572.04,1387497.1500000001 7249741.32,1386741.06 7248253.12,1386231.58 7247395.79,1385798.23 7246821.61,1385459.96 7246406.37,1385264.86 7246155.65,1383830.3 7244311.48,1383716.42 7244214.890000001,1383379.02 7243955.92,1382897.96 7243573.65,1381359.04 7242290.26,1381107.94 7242051.33,1380874.67 7241772.45,1380714.6 7241476.23,1380431.7 7240865.68,1379873.7 7239610.17,1379308.86 7238348.13,1379021.87 7237770.48,1378710.42 7237164.99,1378370.32 7236454.29,1377313.34 7233922.43,1377024.6500000001 7233266.19,1376817.24 7232777.66,1376485.54 7232108.88,1376278.48 7231699.26),(1278685.48 7174945.58,1278786.95 7174913.57,1279196.79 7174955.71,1279469.86 7174929.88,1279565.08 7174938.8100000005,1279628.6 7174989.01,1279654.96 7175055.04,1279737.8800000001 7175535.66,1279788.16 7175611.58,1279851.61 7175656.68,1280048.23 7175752.74,1280105.09 7175813.25,1280116.11 7175874.390000001,1280076.4000000001 7175951.54,1279767.05 7176185.57,1279675.48 7176197.03,1279588.46 7176167.57,1279521.4000000001 7176107.19,1278684.91 7175156.66,1278648.21 7175078.850000001,1278645.44 7174998.890000001,1278685.48 7174945.58))') AS geometry
)
SELECT COALESCE(ST_SnapToGrid(ST_Multi(geometry), 100/2),ST_GeomFromText('MULTIPOLYGON EMPTY',3857))::geometry(MULTIPOLYGON,3857) AS geometry
FROM t

0.13:

WITH t AS (
  SELECT ST_GeomFromEWKT('SRID=3857;POLYGON((1376278.48 7231699.26,1375968.72 7231083.12,1375725.77 7230672.73,1375248.86 7229798.640000001,1374856.24 7229145.29,1374449.04 7228521.47,1374046.56 7227878.7,1373424.99 7226879.94,1373104.05 7226485.36,1372554.57 7225902.890000001,1371800.6500000001 7225205.61,1371399.86 7224893.53,1370174.55 7223920.13,1369766.53 7223656.16,1369197.29 7223296.8,1367858.6500000001 7222560.62,1367623.7 7222453.33,1367300.59 7222303.65,1366718.26 7222030.11,1366292.19 7221788.73,1365218.5 7221039.01,1364301.42 7220401.890000001,1362927.33 7219571.890000001,1362731.97 7219461.65,1361693.27 7218875.38,1360735.8900000001 7218391.3100000005,1360091.6500000001 7218004.23,1358722.91 7217074.41,1358288.85 7216761.08,1357698 7216309.350000001,1357412.51 7216069.5600000005,1356819.82 7215458.73,1355795.3800000001 7214248.8,1355367.8900000001 7213687.24,1354775.25 7212688.2,1354383.61 7211970.2700000005,1354060.24 7211326.07,1353751.22 7210710.66,1353546.51 7210332.29,1352930.1 7209241.75,1352348.74 7208338.5600000005,1351811.61 7207501.09,1351279.33 7206800.3,1350894.3 7206354.29,1349890.1 7205429.91,1349364.77 7205031.45,1348717.43 7204586.11,1348021.05 7204155.49,1347722.96 7204086.86,1347262.32 7204146.48,1347034.1400000001 7204235.18,1346752.09 7204434.390000001,1346552.6300000001 7204590.8,1346392.87 7204770.26,1346151.49 7204697.67,1346126.92 7204690.600000001,1346102.35 7204683.54,1345905.35 7204613.4,1345658.01 7204526.5,1345477.9000000001 7205186.51,1344732.72 7204700.25,1344271.47 7204414.59,1343865.32 7204233.67,1342492.02 7203938.38,1341069.97 7203751.53,1339556.8 7203687.63,1338968.07 7203735.8,1338440.91 7203794.600000001,1337756.99 7203938.61,1337378.3900000001 7204011.350000001,1337093.9000000001 7204018.93,1336758.03 7203931.88,1335684.8900000001 7203461.87,1335135.22 7203251.01,1332953.31 7202294.18,1331657.92 7201765.01,1331101.61 7201637.75,1330363.23 7201522.59,1330008.84 7201437.36,1329254.33 7201192.63,1328305.52 7200854.29,1327552.26 7200580.37,1326562.09 7200210.21,1324656.3900000001 7199348.66,1323806.78 7199009.69,1322709.54 7198632.640000001,1321195.57 7198188.140000001,1320132.42 7197866.83,1319587.96 7197736.57,1319186.62 7197675.69,1318792.56 7197640.26,1318139.96 7197623.2,1317575.26 7197662.5200000005,1316204.52 7197771.0200000005,1315437.1400000001 7197849.69,1314689.82 7197926.24,1312806.92 7198260.100000001,1312098.36 7198453.5200000005,1311597.36 7198634.72,1311191.46 7198800.57,1310789.59 7199003.9,1310343.61 7199218.22,1309870.35 7199433,1309441.91 7199580.390000001,1309171.6400000001 7199614.07,1308675.59 7199593.55,1307326.1300000001 7199372.390000001,1306429.3900000001 7199327.79,1305440.2 7199356.350000001,1303849.48 7199370.850000001,1302694.36 7199461.57,1301941.66 7199473.88,1300855.53 7199407.850000001,1300454.21 7199344.33,1300164.1 7199203.88,1299822.6400000001 7198941.32,1299079.36 7198149.15,1298399.72 7197388.41,1297338.93 7196201.890000001,1296571.06 7195329.94,1295328.83 7193934.74,1294755.56 7193293.57,1294235.8800000001 7192590.18,1293777.74 7192010.4,1293349.74 7191506.93,1292795.4000000001 7190971.2700000005,1292143.3900000001 7190385.93,1291496.1300000001 7189884.0600000005,1290914.07 7189527.850000001,1290451.1500000001 7189287.5,1290024.84 7189104.57,1289386.6500000001 7188972.48,1288280.42 7188941,1287902 7188888.55,1287584.44 7188809.62,1287146.31 7188626.72,1286849.3800000001 7188443.46,1286324.76 7188038.42,1286007.36 7187729.28,1285851.61 7187542.28,1285244.26 7186693.48,1285115.1300000001 7186461.79,1284977.36 7186219.99,1284793.69 7185978.86,1283962.73 7185053.2,1282973.37 7183848.600000001,1282927.19 7183706.11,1282934.17 7183596.95,1282941.04 7183479.28,1283048.56 7183387.47,1282802.5 7183174.51,1282658.79 7183231.04,1282551.21 7183196.75,1282451.27 7183099.32,1281504.86 7181028.83,1281428.11 7180760.75,1281398.1500000001 7180435.82,1281368.81 7179039.61,1281494.03 7177641.5,1281536.46 7177514.91,1281635.43 7177423.3,1281742.29 7177411.61,1281868.61 7177455.83,1282318.24 7176187.98,1282217.75 7176044.67,1282143.95 7175866.94,1282039.12 7175408.76,1282026.33 7175219.98,1282078.67 7175074.5600000005,1282202.81 7174963.9,1282400.86 7174916.890000001,1283217.56 7174905.49,1283782.58 7174870.32,1283917.53 7174805.44,1283997.43 7174690.2700000005,1284005.1300000001 7174513.140000001,1283972.26 7174227.65,1283896.3 7173896.83,1283812.9000000001 7173761.84,1283650.12 7173656.91,1283180.87 7173491.600000001,1282413.71 7173269.15,1282133.36 7173131.79,1281883.12 7172961.67,1281401.8900000001 7172536.07,1281225.76 7172320.68,1281106.46 7172162.37,1281022.75 7172000.17,1280921.29 7171780.350000001,1280834.01 7171356.17,1280788.42 7171125.41,1280702.67 7170936.0200000005,1280247.1400000001 7170265.13,1280161.44 7170079.17,1279911.43 7169414.03,1279822.71 7169253.640000001,1279691.03 7169178.88,1279393.22 7169118.28,1279264.57 7169016.26,1278939.6400000001 7169968.140000001,1279077.96 7170030.92,1279177.96 7170146.95,1279270.69 7170353.25,1279675.01 7172391.22,1279782.83 7173082.37,1279787.11 7173398.850000001,1279704.79 7173966.72,1279635.92 7174148.07,1279502.03 7174292.850000001,1279325.11 7174395.67,1278868.3800000001 7174527.79,1278177.45 7174671.54,1277210.09 7174846.140000001,1276850.49 7174878.140000001,1276500.49 7174865.73,1275833.6 7174774.07,1275321.24 7174682.04,1245040.3900000001 7172903.5200000005,1240772.3900000001 7187705.07,1240703.6400000001 7187943.23,1240634.82 7188181.68,1240566.1500000001 7188419.57,1240497.4000000001 7188657.75,1240428.6400000001 7188895.94,1239895.73 7190739.29,1234976.42 7207758.55,1235010.18 7207927.46,1235011.3900000001 7208077.84,1234922.31 7208449.41,1234753.74 7209327.55,1234701.62 7210695.45,1234578.24 7211900.0200000005,1234438.28 7212744.09,1234375.85 7213058.44,1234070.85 7214593.95,1233926.47 7215323.72,1233780.74 7216315.3,1233726.74 7216970.38,1233698.19 7217316.75,1233686.11 7218379.36,1233954.1500000001 7222685.16,1233969.01 7223051.41,1233953.09 7223412.79,1233893.44 7223861.86,1233796.6300000001 7224364.32,1233168.3 7227025.55,1233074.98 7227548.73,1232904.59 7228709.84,1232788.46 7232232.19,1232774.37 7232619.67,1232487.68 7234903.61,1232543.52 7235226.12,1232615.91 7235587.08,1232689.98 7235799.91,1232764.59 7235891.91,1232890.56 7235987.62,1232940.2 7236036.61,1232965.1500000001 7236137.21,1233185.98 7236206.86,1233270.76 7236458.79,1233468.75 7236911.93,1233640.96 7237289.51,1233971.74 7237669.890000001,1234122.07 7237825.09,1234494.99 7238207.7,1234967.75 7238645.3,1235167.1400000001 7238780.76,1235929.11 7239144.63,1236114.74 7239266.47,1236266.41 7239416.01,1236460.18 7239695.42,1236625.8800000001 7239885.97,1237149.3 7240327.16,1237472.61 7240550.66,1237637.31 7240617.82,1237877.25 7240684.350000001,1237980.24 7240731.46,1238069.72 7240799.25,1238421.54 7241152.74,1238532.1300000001 7241288.91,1238678.79 7241644.15,1238770.92 7242020.44,1238892.53 7242643.34,1238941.76 7242800.62,1239060.46 7243080.74,1239109.99 7243272.3100000005,1239146.42 7243532.57,1239150.41 7243882.58,1243547.6400000001 7246279.47,1243972.8800000001 7246512.51,1244229.32 7246642.350000001,1244463.91 7246817.03,1244609.09 7246956.48,1245285.33 7247827.640000001,1245325.3800000001 7247895.95,1246345.9000000001 7247829.67,1246472.54 7247814.73,1246616.91 7247861.44,1246860.28 7248049.73,1247011.91 7248139.3,1248004.9000000001 7248414.8100000005,1248684.33 7248507.8,1249600.1 7248586.390000001,1251231.78 7248630.2,1251951.12 7248597.15,1253376.76 7248266.5200000005,1254284.6 7247910.18,1254727.24 7247639.37,1255032.37 7247491.91,1257154.83 7246988.44,1259102.59 7246666.66,1259282.85 7246700.72,1259349.99 7246730.890000001,1282171.35 7249567.38,1284434.18 7247587.94,1290031.33 7241108.84,1296246.95 7233043.98,1298736.96 7233079.43,1308609.5 7233213.850000001,1309064.09 7233219.75,1309518.69 7233225.63,1309973.29 7233231.48,1310427.8800000001 7233237.3100000005,1330447.6500000001 7233468.78,1336280.54 7236051.140000001,1337635.67 7236650.37,1345865.5 7240283.82,1351003.31 7242547.12,1352804.74 7243339.76,1354227.19 7243339.79,1364617.08 7255935.07,1366011.75 7259425.41,1389790.43 7262043.53,1393281.54 7262422.2,1393015.71 7262307.32,1392726.67 7262096.71,1392431 7261831.22,1392054.72 7261378.65,1391713.74 7260833.94,1391257.6400000001 7259857.49,1390835.44 7258953.49,1390099.67 7257253.54,1389188.41 7254757.41,1388914.54 7253907.8,1388335.4000000001 7252110.86,1388096.77 7251266.58,1387851.9000000001 7250572.04,1387497.1500000001 7249741.32,1386741.06 7248253.12,1386231.58 7247395.79,1385798.23 7246821.61,1385459.96 7246406.37,1385264.86 7246155.65,1383830.3 7244311.48,1383716.42 7244214.890000001,1383379.02 7243955.92,1382897.96 7243573.65,1381359.04 7242290.26,1381107.94 7242051.33,1380874.67 7241772.45,1380714.6 7241476.23,1380431.7 7240865.68,1379873.7 7239610.17,1379308.86 7238348.13,1379021.87 7237770.48,1378710.42 7237164.99,1378370.32 7236454.29,1377313.34 7233922.43,1377024.6500000001 7233266.19,1376817.24 7232777.66,1376485.54 7232108.88,1376278.48 7231699.26),(1278685.48 7174945.58,1278786.95 7174913.57,1279196.79 7174955.71,1279469.86 7174929.88,1279565.08 7174938.8100000005,1279628.6 7174989.01,1279654.96 7175055.04,1279737.8800000001 7175535.66,1279788.16 7175611.58,1279851.61 7175656.68,1280048.23 7175752.74,1280105.09 7175813.25,1280116.11 7175874.390000001,1280076.4000000001 7175951.54,1279767.05 7176185.57,1279675.48 7176197.03,1279588.46 7176167.57,1279521.4000000001 7176107.19,1278684.91 7175156.66,1278648.21 7175078.850000001,1278645.44 7174998.890000001,1278685.48 7174945.58))') AS geometry
)
SELECT ST_CollectionExtract(ST_MakeValid(ST_Multi(ST_Buffer(ST_SnapToGrid(ST_Multi(geometry), 100/2), 0.0))),3)::geometry(MULTIPOLYGON,3857) AS geometry
FROM t

image

So the problem maybe arises when a part of the polygon is clipped. Can you find out in which tile the corrupted polygon lies?

pka commented 3 years ago

After checking your map link, https://adv-smart.de/tiles/smarttiles_de_public_v1/7/68/40.pbf seems to be the broken tile.

image

pka commented 3 years ago

The query for tile 7/68/40 is

WITH t AS (
  SELECT ST_GeomFromEWKT('SRID=3857;POLYGON((1376278.48 7231699.26,1375968.72 7231083.12,1375725.77 7230672.73,1375248.86 7229798.640000001,1374856.24 7229145.29,1374449.04 7228521.47,1374046.56 7227878.7,1373424.99 7226879.94,1373104.05 7226485.36,1372554.57 7225902.890000001,1371800.6500000001 7225205.61,1371399.86 7224893.53,1370174.55 7223920.13,1369766.53 7223656.16,1369197.29 7223296.8,1367858.6500000001 7222560.62,1367623.7 7222453.33,1367300.59 7222303.65,1366718.26 7222030.11,1366292.19 7221788.73,1365218.5 7221039.01,1364301.42 7220401.890000001,1362927.33 7219571.890000001,1362731.97 7219461.65,1361693.27 7218875.38,1360735.8900000001 7218391.3100000005,1360091.6500000001 7218004.23,1358722.91 7217074.41,1358288.85 7216761.08,1357698 7216309.350000001,1357412.51 7216069.5600000005,1356819.82 7215458.73,1355795.3800000001 7214248.8,1355367.8900000001 7213687.24,1354775.25 7212688.2,1354383.61 7211970.2700000005,1354060.24 7211326.07,1353751.22 7210710.66,1353546.51 7210332.29,1352930.1 7209241.75,1352348.74 7208338.5600000005,1351811.61 7207501.09,1351279.33 7206800.3,1350894.3 7206354.29,1349890.1 7205429.91,1349364.77 7205031.45,1348717.43 7204586.11,1348021.05 7204155.49,1347722.96 7204086.86,1347262.32 7204146.48,1347034.1400000001 7204235.18,1346752.09 7204434.390000001,1346552.6300000001 7204590.8,1346392.87 7204770.26,1346151.49 7204697.67,1346126.92 7204690.600000001,1346102.35 7204683.54,1345905.35 7204613.4,1345658.01 7204526.5,1345477.9000000001 7205186.51,1344732.72 7204700.25,1344271.47 7204414.59,1343865.32 7204233.67,1342492.02 7203938.38,1341069.97 7203751.53,1339556.8 7203687.63,1338968.07 7203735.8,1338440.91 7203794.600000001,1337756.99 7203938.61,1337378.3900000001 7204011.350000001,1337093.9000000001 7204018.93,1336758.03 7203931.88,1335684.8900000001 7203461.87,1335135.22 7203251.01,1332953.31 7202294.18,1331657.92 7201765.01,1331101.61 7201637.75,1330363.23 7201522.59,1330008.84 7201437.36,1329254.33 7201192.63,1328305.52 7200854.29,1327552.26 7200580.37,1326562.09 7200210.21,1324656.3900000001 7199348.66,1323806.78 7199009.69,1322709.54 7198632.640000001,1321195.57 7198188.140000001,1320132.42 7197866.83,1319587.96 7197736.57,1319186.62 7197675.69,1318792.56 7197640.26,1318139.96 7197623.2,1317575.26 7197662.5200000005,1316204.52 7197771.0200000005,1315437.1400000001 7197849.69,1314689.82 7197926.24,1312806.92 7198260.100000001,1312098.36 7198453.5200000005,1311597.36 7198634.72,1311191.46 7198800.57,1310789.59 7199003.9,1310343.61 7199218.22,1309870.35 7199433,1309441.91 7199580.390000001,1309171.6400000001 7199614.07,1308675.59 7199593.55,1307326.1300000001 7199372.390000001,1306429.3900000001 7199327.79,1305440.2 7199356.350000001,1303849.48 7199370.850000001,1302694.36 7199461.57,1301941.66 7199473.88,1300855.53 7199407.850000001,1300454.21 7199344.33,1300164.1 7199203.88,1299822.6400000001 7198941.32,1299079.36 7198149.15,1298399.72 7197388.41,1297338.93 7196201.890000001,1296571.06 7195329.94,1295328.83 7193934.74,1294755.56 7193293.57,1294235.8800000001 7192590.18,1293777.74 7192010.4,1293349.74 7191506.93,1292795.4000000001 7190971.2700000005,1292143.3900000001 7190385.93,1291496.1300000001 7189884.0600000005,1290914.07 7189527.850000001,1290451.1500000001 7189287.5,1290024.84 7189104.57,1289386.6500000001 7188972.48,1288280.42 7188941,1287902 7188888.55,1287584.44 7188809.62,1287146.31 7188626.72,1286849.3800000001 7188443.46,1286324.76 7188038.42,1286007.36 7187729.28,1285851.61 7187542.28,1285244.26 7186693.48,1285115.1300000001 7186461.79,1284977.36 7186219.99,1284793.69 7185978.86,1283962.73 7185053.2,1282973.37 7183848.600000001,1282927.19 7183706.11,1282934.17 7183596.95,1282941.04 7183479.28,1283048.56 7183387.47,1282802.5 7183174.51,1282658.79 7183231.04,1282551.21 7183196.75,1282451.27 7183099.32,1281504.86 7181028.83,1281428.11 7180760.75,1281398.1500000001 7180435.82,1281368.81 7179039.61,1281494.03 7177641.5,1281536.46 7177514.91,1281635.43 7177423.3,1281742.29 7177411.61,1281868.61 7177455.83,1282318.24 7176187.98,1282217.75 7176044.67,1282143.95 7175866.94,1282039.12 7175408.76,1282026.33 7175219.98,1282078.67 7175074.5600000005,1282202.81 7174963.9,1282400.86 7174916.890000001,1283217.56 7174905.49,1283782.58 7174870.32,1283917.53 7174805.44,1283997.43 7174690.2700000005,1284005.1300000001 7174513.140000001,1283972.26 7174227.65,1283896.3 7173896.83,1283812.9000000001 7173761.84,1283650.12 7173656.91,1283180.87 7173491.600000001,1282413.71 7173269.15,1282133.36 7173131.79,1281883.12 7172961.67,1281401.8900000001 7172536.07,1281225.76 7172320.68,1281106.46 7172162.37,1281022.75 7172000.17,1280921.29 7171780.350000001,1280834.01 7171356.17,1280788.42 7171125.41,1280702.67 7170936.0200000005,1280247.1400000001 7170265.13,1280161.44 7170079.17,1279911.43 7169414.03,1279822.71 7169253.640000001,1279691.03 7169178.88,1279393.22 7169118.28,1279264.57 7169016.26,1278939.6400000001 7169968.140000001,1279077.96 7170030.92,1279177.96 7170146.95,1279270.69 7170353.25,1279675.01 7172391.22,1279782.83 7173082.37,1279787.11 7173398.850000001,1279704.79 7173966.72,1279635.92 7174148.07,1279502.03 7174292.850000001,1279325.11 7174395.67,1278868.3800000001 7174527.79,1278177.45 7174671.54,1277210.09 7174846.140000001,1276850.49 7174878.140000001,1276500.49 7174865.73,1275833.6 7174774.07,1275321.24 7174682.04,1245040.3900000001 7172903.5200000005,1240772.3900000001 7187705.07,1240703.6400000001 7187943.23,1240634.82 7188181.68,1240566.1500000001 7188419.57,1240497.4000000001 7188657.75,1240428.6400000001 7188895.94,1239895.73 7190739.29,1234976.42 7207758.55,1235010.18 7207927.46,1235011.3900000001 7208077.84,1234922.31 7208449.41,1234753.74 7209327.55,1234701.62 7210695.45,1234578.24 7211900.0200000005,1234438.28 7212744.09,1234375.85 7213058.44,1234070.85 7214593.95,1233926.47 7215323.72,1233780.74 7216315.3,1233726.74 7216970.38,1233698.19 7217316.75,1233686.11 7218379.36,1233954.1500000001 7222685.16,1233969.01 7223051.41,1233953.09 7223412.79,1233893.44 7223861.86,1233796.6300000001 7224364.32,1233168.3 7227025.55,1233074.98 7227548.73,1232904.59 7228709.84,1232788.46 7232232.19,1232774.37 7232619.67,1232487.68 7234903.61,1232543.52 7235226.12,1232615.91 7235587.08,1232689.98 7235799.91,1232764.59 7235891.91,1232890.56 7235987.62,1232940.2 7236036.61,1232965.1500000001 7236137.21,1233185.98 7236206.86,1233270.76 7236458.79,1233468.75 7236911.93,1233640.96 7237289.51,1233971.74 7237669.890000001,1234122.07 7237825.09,1234494.99 7238207.7,1234967.75 7238645.3,1235167.1400000001 7238780.76,1235929.11 7239144.63,1236114.74 7239266.47,1236266.41 7239416.01,1236460.18 7239695.42,1236625.8800000001 7239885.97,1237149.3 7240327.16,1237472.61 7240550.66,1237637.31 7240617.82,1237877.25 7240684.350000001,1237980.24 7240731.46,1238069.72 7240799.25,1238421.54 7241152.74,1238532.1300000001 7241288.91,1238678.79 7241644.15,1238770.92 7242020.44,1238892.53 7242643.34,1238941.76 7242800.62,1239060.46 7243080.74,1239109.99 7243272.3100000005,1239146.42 7243532.57,1239150.41 7243882.58,1243547.6400000001 7246279.47,1243972.8800000001 7246512.51,1244229.32 7246642.350000001,1244463.91 7246817.03,1244609.09 7246956.48,1245285.33 7247827.640000001,1245325.3800000001 7247895.95,1246345.9000000001 7247829.67,1246472.54 7247814.73,1246616.91 7247861.44,1246860.28 7248049.73,1247011.91 7248139.3,1248004.9000000001 7248414.8100000005,1248684.33 7248507.8,1249600.1 7248586.390000001,1251231.78 7248630.2,1251951.12 7248597.15,1253376.76 7248266.5200000005,1254284.6 7247910.18,1254727.24 7247639.37,1255032.37 7247491.91,1257154.83 7246988.44,1259102.59 7246666.66,1259282.85 7246700.72,1259349.99 7246730.890000001,1282171.35 7249567.38,1284434.18 7247587.94,1290031.33 7241108.84,1296246.95 7233043.98,1298736.96 7233079.43,1308609.5 7233213.850000001,1309064.09 7233219.75,1309518.69 7233225.63,1309973.29 7233231.48,1310427.8800000001 7233237.3100000005,1330447.6500000001 7233468.78,1336280.54 7236051.140000001,1337635.67 7236650.37,1345865.5 7240283.82,1351003.31 7242547.12,1352804.74 7243339.76,1354227.19 7243339.79,1364617.08 7255935.07,1366011.75 7259425.41,1389790.43 7262043.53,1393281.54 7262422.2,1393015.71 7262307.32,1392726.67 7262096.71,1392431 7261831.22,1392054.72 7261378.65,1391713.74 7260833.94,1391257.6400000001 7259857.49,1390835.44 7258953.49,1390099.67 7257253.54,1389188.41 7254757.41,1388914.54 7253907.8,1388335.4000000001 7252110.86,1388096.77 7251266.58,1387851.9000000001 7250572.04,1387497.1500000001 7249741.32,1386741.06 7248253.12,1386231.58 7247395.79,1385798.23 7246821.61,1385459.96 7246406.37,1385264.86 7246155.65,1383830.3 7244311.48,1383716.42 7244214.890000001,1383379.02 7243955.92,1382897.96 7243573.65,1381359.04 7242290.26,1381107.94 7242051.33,1380874.67 7241772.45,1380714.6 7241476.23,1380431.7 7240865.68,1379873.7 7239610.17,1379308.86 7238348.13,1379021.87 7237770.48,1378710.42 7237164.99,1378370.32 7236454.29,1377313.34 7233922.43,1377024.6500000001 7233266.19,1376817.24 7232777.66,1376485.54 7232108.88,1376278.48 7231699.26),(1278685.48 7174945.58,1278786.95 7174913.57,1279196.79 7174955.71,1279469.86 7174929.88,1279565.08 7174938.8100000005,1279628.6 7174989.01,1279654.96 7175055.04,1279737.8800000001 7175535.66,1279788.16 7175611.58,1279851.61 7175656.68,1280048.23 7175752.74,1280105.09 7175813.25,1280116.11 7175874.390000001,1280076.4000000001 7175951.54,1279767.05 7176185.57,1279675.48 7176197.03,1279588.46 7176167.57,1279521.4000000001 7176107.19,1278684.91 7175156.66,1278648.21 7175078.850000001,1278645.44 7174998.890000001,1278685.48 7174945.58))') AS wkb_geometry
)
SELECT ST_CollectionExtract(ST_MakeValid(ST_Multi(ST_Buffer(ST_SnapToGrid(ST_Multi(ST_Buffer(ST_Intersection(wkb_geometry,ST_Buffer(ST_MakeEnvelope(939258.2035682462, 7200979.560689885, 1252344.271424327, 7514065.62854597,3857),1*1222.9924525628203)), 0.0)), 1222.9924525628203/2), 0.0))),3)::geometry(MULTIPOLYGON,3857) AS wkb_geometry
FROM t
WHERE wkb_geometry && ST_Buffer(ST_MakeEnvelope(939258.2035682462, 7200979.560689885, 1252344.271424327, 7514065.62854597,3857),1*1222.9924525628203)

but the resulting geometry (green) looks correct:

image

pka commented 3 years ago

Oh, this polygon lies in the water!?

image

pka commented 3 years ago

I looked at 7/67/40 - here's 7/68/40:

WITH t AS (
  SELECT ST_GeomFromEWKT('SRID=3857;POLYGON((1376278.48 7231699.26,1375968.72 7231083.12,1375725.77 7230672.73,1375248.86 7229798.640000001,1374856.24 7229145.29,1374449.04 7228521.47,1374046.56 7227878.7,1373424.99 7226879.94,1373104.05 7226485.36,1372554.57 7225902.890000001,1371800.6500000001 7225205.61,1371399.86 7224893.53,1370174.55 7223920.13,1369766.53 7223656.16,1369197.29 7223296.8,1367858.6500000001 7222560.62,1367623.7 7222453.33,1367300.59 7222303.65,1366718.26 7222030.11,1366292.19 7221788.73,1365218.5 7221039.01,1364301.42 7220401.890000001,1362927.33 7219571.890000001,1362731.97 7219461.65,1361693.27 7218875.38,1360735.8900000001 7218391.3100000005,1360091.6500000001 7218004.23,1358722.91 7217074.41,1358288.85 7216761.08,1357698 7216309.350000001,1357412.51 7216069.5600000005,1356819.82 7215458.73,1355795.3800000001 7214248.8,1355367.8900000001 7213687.24,1354775.25 7212688.2,1354383.61 7211970.2700000005,1354060.24 7211326.07,1353751.22 7210710.66,1353546.51 7210332.29,1352930.1 7209241.75,1352348.74 7208338.5600000005,1351811.61 7207501.09,1351279.33 7206800.3,1350894.3 7206354.29,1349890.1 7205429.91,1349364.77 7205031.45,1348717.43 7204586.11,1348021.05 7204155.49,1347722.96 7204086.86,1347262.32 7204146.48,1347034.1400000001 7204235.18,1346752.09 7204434.390000001,1346552.6300000001 7204590.8,1346392.87 7204770.26,1346151.49 7204697.67,1346126.92 7204690.600000001,1346102.35 7204683.54,1345905.35 7204613.4,1345658.01 7204526.5,1345477.9000000001 7205186.51,1344732.72 7204700.25,1344271.47 7204414.59,1343865.32 7204233.67,1342492.02 7203938.38,1341069.97 7203751.53,1339556.8 7203687.63,1338968.07 7203735.8,1338440.91 7203794.600000001,1337756.99 7203938.61,1337378.3900000001 7204011.350000001,1337093.9000000001 7204018.93,1336758.03 7203931.88,1335684.8900000001 7203461.87,1335135.22 7203251.01,1332953.31 7202294.18,1331657.92 7201765.01,1331101.61 7201637.75,1330363.23 7201522.59,1330008.84 7201437.36,1329254.33 7201192.63,1328305.52 7200854.29,1327552.26 7200580.37,1326562.09 7200210.21,1324656.3900000001 7199348.66,1323806.78 7199009.69,1322709.54 7198632.640000001,1321195.57 7198188.140000001,1320132.42 7197866.83,1319587.96 7197736.57,1319186.62 7197675.69,1318792.56 7197640.26,1318139.96 7197623.2,1317575.26 7197662.5200000005,1316204.52 7197771.0200000005,1315437.1400000001 7197849.69,1314689.82 7197926.24,1312806.92 7198260.100000001,1312098.36 7198453.5200000005,1311597.36 7198634.72,1311191.46 7198800.57,1310789.59 7199003.9,1310343.61 7199218.22,1309870.35 7199433,1309441.91 7199580.390000001,1309171.6400000001 7199614.07,1308675.59 7199593.55,1307326.1300000001 7199372.390000001,1306429.3900000001 7199327.79,1305440.2 7199356.350000001,1303849.48 7199370.850000001,1302694.36 7199461.57,1301941.66 7199473.88,1300855.53 7199407.850000001,1300454.21 7199344.33,1300164.1 7199203.88,1299822.6400000001 7198941.32,1299079.36 7198149.15,1298399.72 7197388.41,1297338.93 7196201.890000001,1296571.06 7195329.94,1295328.83 7193934.74,1294755.56 7193293.57,1294235.8800000001 7192590.18,1293777.74 7192010.4,1293349.74 7191506.93,1292795.4000000001 7190971.2700000005,1292143.3900000001 7190385.93,1291496.1300000001 7189884.0600000005,1290914.07 7189527.850000001,1290451.1500000001 7189287.5,1290024.84 7189104.57,1289386.6500000001 7188972.48,1288280.42 7188941,1287902 7188888.55,1287584.44 7188809.62,1287146.31 7188626.72,1286849.3800000001 7188443.46,1286324.76 7188038.42,1286007.36 7187729.28,1285851.61 7187542.28,1285244.26 7186693.48,1285115.1300000001 7186461.79,1284977.36 7186219.99,1284793.69 7185978.86,1283962.73 7185053.2,1282973.37 7183848.600000001,1282927.19 7183706.11,1282934.17 7183596.95,1282941.04 7183479.28,1283048.56 7183387.47,1282802.5 7183174.51,1282658.79 7183231.04,1282551.21 7183196.75,1282451.27 7183099.32,1281504.86 7181028.83,1281428.11 7180760.75,1281398.1500000001 7180435.82,1281368.81 7179039.61,1281494.03 7177641.5,1281536.46 7177514.91,1281635.43 7177423.3,1281742.29 7177411.61,1281868.61 7177455.83,1282318.24 7176187.98,1282217.75 7176044.67,1282143.95 7175866.94,1282039.12 7175408.76,1282026.33 7175219.98,1282078.67 7175074.5600000005,1282202.81 7174963.9,1282400.86 7174916.890000001,1283217.56 7174905.49,1283782.58 7174870.32,1283917.53 7174805.44,1283997.43 7174690.2700000005,1284005.1300000001 7174513.140000001,1283972.26 7174227.65,1283896.3 7173896.83,1283812.9000000001 7173761.84,1283650.12 7173656.91,1283180.87 7173491.600000001,1282413.71 7173269.15,1282133.36 7173131.79,1281883.12 7172961.67,1281401.8900000001 7172536.07,1281225.76 7172320.68,1281106.46 7172162.37,1281022.75 7172000.17,1280921.29 7171780.350000001,1280834.01 7171356.17,1280788.42 7171125.41,1280702.67 7170936.0200000005,1280247.1400000001 7170265.13,1280161.44 7170079.17,1279911.43 7169414.03,1279822.71 7169253.640000001,1279691.03 7169178.88,1279393.22 7169118.28,1279264.57 7169016.26,1278939.6400000001 7169968.140000001,1279077.96 7170030.92,1279177.96 7170146.95,1279270.69 7170353.25,1279675.01 7172391.22,1279782.83 7173082.37,1279787.11 7173398.850000001,1279704.79 7173966.72,1279635.92 7174148.07,1279502.03 7174292.850000001,1279325.11 7174395.67,1278868.3800000001 7174527.79,1278177.45 7174671.54,1277210.09 7174846.140000001,1276850.49 7174878.140000001,1276500.49 7174865.73,1275833.6 7174774.07,1275321.24 7174682.04,1245040.3900000001 7172903.5200000005,1240772.3900000001 7187705.07,1240703.6400000001 7187943.23,1240634.82 7188181.68,1240566.1500000001 7188419.57,1240497.4000000001 7188657.75,1240428.6400000001 7188895.94,1239895.73 7190739.29,1234976.42 7207758.55,1235010.18 7207927.46,1235011.3900000001 7208077.84,1234922.31 7208449.41,1234753.74 7209327.55,1234701.62 7210695.45,1234578.24 7211900.0200000005,1234438.28 7212744.09,1234375.85 7213058.44,1234070.85 7214593.95,1233926.47 7215323.72,1233780.74 7216315.3,1233726.74 7216970.38,1233698.19 7217316.75,1233686.11 7218379.36,1233954.1500000001 7222685.16,1233969.01 7223051.41,1233953.09 7223412.79,1233893.44 7223861.86,1233796.6300000001 7224364.32,1233168.3 7227025.55,1233074.98 7227548.73,1232904.59 7228709.84,1232788.46 7232232.19,1232774.37 7232619.67,1232487.68 7234903.61,1232543.52 7235226.12,1232615.91 7235587.08,1232689.98 7235799.91,1232764.59 7235891.91,1232890.56 7235987.62,1232940.2 7236036.61,1232965.1500000001 7236137.21,1233185.98 7236206.86,1233270.76 7236458.79,1233468.75 7236911.93,1233640.96 7237289.51,1233971.74 7237669.890000001,1234122.07 7237825.09,1234494.99 7238207.7,1234967.75 7238645.3,1235167.1400000001 7238780.76,1235929.11 7239144.63,1236114.74 7239266.47,1236266.41 7239416.01,1236460.18 7239695.42,1236625.8800000001 7239885.97,1237149.3 7240327.16,1237472.61 7240550.66,1237637.31 7240617.82,1237877.25 7240684.350000001,1237980.24 7240731.46,1238069.72 7240799.25,1238421.54 7241152.74,1238532.1300000001 7241288.91,1238678.79 7241644.15,1238770.92 7242020.44,1238892.53 7242643.34,1238941.76 7242800.62,1239060.46 7243080.74,1239109.99 7243272.3100000005,1239146.42 7243532.57,1239150.41 7243882.58,1243547.6400000001 7246279.47,1243972.8800000001 7246512.51,1244229.32 7246642.350000001,1244463.91 7246817.03,1244609.09 7246956.48,1245285.33 7247827.640000001,1245325.3800000001 7247895.95,1246345.9000000001 7247829.67,1246472.54 7247814.73,1246616.91 7247861.44,1246860.28 7248049.73,1247011.91 7248139.3,1248004.9000000001 7248414.8100000005,1248684.33 7248507.8,1249600.1 7248586.390000001,1251231.78 7248630.2,1251951.12 7248597.15,1253376.76 7248266.5200000005,1254284.6 7247910.18,1254727.24 7247639.37,1255032.37 7247491.91,1257154.83 7246988.44,1259102.59 7246666.66,1259282.85 7246700.72,1259349.99 7246730.890000001,1282171.35 7249567.38,1284434.18 7247587.94,1290031.33 7241108.84,1296246.95 7233043.98,1298736.96 7233079.43,1308609.5 7233213.850000001,1309064.09 7233219.75,1309518.69 7233225.63,1309973.29 7233231.48,1310427.8800000001 7233237.3100000005,1330447.6500000001 7233468.78,1336280.54 7236051.140000001,1337635.67 7236650.37,1345865.5 7240283.82,1351003.31 7242547.12,1352804.74 7243339.76,1354227.19 7243339.79,1364617.08 7255935.07,1366011.75 7259425.41,1389790.43 7262043.53,1393281.54 7262422.2,1393015.71 7262307.32,1392726.67 7262096.71,1392431 7261831.22,1392054.72 7261378.65,1391713.74 7260833.94,1391257.6400000001 7259857.49,1390835.44 7258953.49,1390099.67 7257253.54,1389188.41 7254757.41,1388914.54 7253907.8,1388335.4000000001 7252110.86,1388096.77 7251266.58,1387851.9000000001 7250572.04,1387497.1500000001 7249741.32,1386741.06 7248253.12,1386231.58 7247395.79,1385798.23 7246821.61,1385459.96 7246406.37,1385264.86 7246155.65,1383830.3 7244311.48,1383716.42 7244214.890000001,1383379.02 7243955.92,1382897.96 7243573.65,1381359.04 7242290.26,1381107.94 7242051.33,1380874.67 7241772.45,1380714.6 7241476.23,1380431.7 7240865.68,1379873.7 7239610.17,1379308.86 7238348.13,1379021.87 7237770.48,1378710.42 7237164.99,1378370.32 7236454.29,1377313.34 7233922.43,1377024.6500000001 7233266.19,1376817.24 7232777.66,1376485.54 7232108.88,1376278.48 7231699.26),(1278685.48 7174945.58,1278786.95 7174913.57,1279196.79 7174955.71,1279469.86 7174929.88,1279565.08 7174938.8100000005,1279628.6 7174989.01,1279654.96 7175055.04,1279737.8800000001 7175535.66,1279788.16 7175611.58,1279851.61 7175656.68,1280048.23 7175752.74,1280105.09 7175813.25,1280116.11 7175874.390000001,1280076.4000000001 7175951.54,1279767.05 7176185.57,1279675.48 7176197.03,1279588.46 7176167.57,1279521.4000000001 7176107.19,1278684.91 7175156.66,1278648.21 7175078.850000001,1278645.44 7174998.890000001,1278685.48 7174945.58))') AS wkb_geometry
)
SELECT ST_CollectionExtract(ST_MakeValid(ST_Multi(ST_Buffer(ST_SnapToGrid(ST_Multi(ST_Buffer(ST_Intersection(wkb_geometry,ST_Buffer(ST_MakeEnvelope(1252344.271424327, 7200979.560689885, 1565430.3392804116, 7514065.62854597,3857),1*1222.9924525628203)), 0.0)), 1222.9924525628203/2), 0.0))),3)::geometry(MULTIPOLYGON,3857) AS wkb_geometry
FROM t
WHERE wkb_geometry && ST_Buffer(ST_MakeEnvelope(1252344.271424327, 7200979.560689885, 1565430.3392804116, 7514065.62854597,3857),1*1222.9924525628203)

So this is the yellow geometry in your original screenshot:

image

The geometry itself looks ok. But this polygon should be rendered as water?

gozell commented 3 years ago

Yes, the area should be rendered as water. We found some areas which are not filled with the correct color for the layer. The incorrect areas are always limited by the edge of a tile. Here is another example with tile 5/16/11 in the south-west part of Germany: the area is white instead of yellow. The section is the upper right part of the tile 5/16/11: Bildschirmfoto von 2021-03-13 12-30-52

The correct tile rendered with TRex 0.11: https://dev.adv-smart.de/tiles/smarttiles_de_dev/5/16/11.pbf Bildschirmfoto von 2021-03-13 12-58-23

The tile rendered with TRex 0.13: https://adv-smart.de/tiles/smarttiles_de_public_v1/5/16/11.pbf Bildschirmfoto von 2021-03-13 12-58-36

I have checked the PBFs in https://observablehq.com/@henrythasler/mapbox-vector-tile-dissector The area rendered with TRex 0.13 is not closed at the edge of the tile.

pka commented 3 years ago

This lets me assume that the clipped polygon border is outside the tile border which causes the wrong rendering. What's your buffer_size configuration and which thickness has your polygon outline style?

gozell commented 3 years ago

The yellow area is the background color of Germany. buffer_size for all LINESTRING and for all POLYGON in the Toml is 10 buffer_size for POINT is always 0 The corrupted areas do not have an outline style - thickness is 0

pka commented 3 years ago

I've added a test comparing the Rostock polygon with simplification of v0.13 and v0.11 (buffer: 10, tilesize: 512).

image

The difference of the MVT encoded geometry is one additional point in v0.11 in the top right corner, which could indeed be cleaned up by ST_MakeVaild in v0.13. But I doubt, that this causes the rendering error.

As a workaround, I made the ST_MakeVaild method optional in simplification which should make it also easier to find a reproducable faulty geometry.

pka commented 3 years ago

I think I found the reason for the broken geometries. The buffer size was only correct for tile size 256. In the discussed polygons the clipped polygon border had an offset of -20 instead of -10 within the 512x512 tile. This probably caused the wrong polygon fill. Buffer size is fixed in f2433f6.