Skip to content

Commit

Permalink
Improve buffer segment removal heuristic
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-jts committed Nov 21, 2024
1 parent 9f0d228 commit da0bb91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class OffsetSegmentGenerator
/**
* Factor which controls how close curve vertices can be to be snapped
*/
private static final double CURVE_VERTEX_SNAP_DISTANCE_FACTOR = 1.0E-6;
private static final double CURVE_VERTEX_SNAP_DISTANCE_FACTOR = 1.0E-4;

/**
* Factor which determines how short closing segs can be for round buffers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,14 @@ public void testRingEndSimplified() {
);
}

//See https://github.com/libgeos/geos/issues/1125
public void testPolygonQS_1KeepHoles() {
String wkt = "POLYGON ((-148960.40471687025 6579513.659178475, -148928.0396648308 6581180.350337651, -148245.02968781325 6581451.972854649, -147792.6996258908 6581746.752358279, -147401.9935929195 6581835.62069549, -147210.88713646092 6581715.340847257, -147165.89525315163 6581718.457436403, -147051.42047418532 6581994.824000333, -146383.20456596403 6582271.6080921125, -145714.98865774274 6581994.824000333, -145614.3328386122 6581751.819356657, -145289.96567509088 6581774.313783639, -145251.8481557473 6581761.53544856, -144930.85553391272 6582023.429998221, -144801.3009350866 6582062.324487534, -144649.32383366008 6582200.989144345, -144370.39842075115 6582625.956584843, -144433.62830795025 6582865.17530117, -144245.21925823047 6582676.803607282, -144190.80928273257 6582650.46537934, -143612.84111259945 6583156.449299466, -142975.83638477212 6583147.740058781, -141662.4868972855 6583201.722177097, -141223.96080593477 6583368.877966974, -140134.42107956257 6583317.889953656, -137814.4023306831 6583217.287998203, -136584.74750088027 6583197.764287264, -135440.77723176708 6583205.617216827, -135255.13229718836 6583263.689916569, -135023.58923930765 6582294.773113748, -135333.8024011954 6581864.155949903, -135352.36464941013 6581737.1950687375, -134265.49708919087 6581601.806132041, -134171.3524065637 6581457.461614907, -135439.24541688355 6581616.609798272, -135680.42426915234 6581646.652426795, -136232.904152299 6581417.807766258, -136858.69365364907 6581677.018264907, -136920.3618201151 6581825.898388756, -138060.72504741614 6581967.966335978, -138065.18112161517 6581962.887387468, -138068.72528765528 6581957.509991399, -137927.47673898126 6581707.240832043, -137979.72909569443 6581677.750304447, -138121.13852736415 6581928.304521968, -138125.10691505377 6581928.045287478, -138155.67610065715 6581921.763837175, -138161.590592191 6581925.661995275, -138170.6137036581 6581926.915151091, -138241.9787318571 6581930.376680339, -138796.47362927152 6581702.315792638, -138854.79457708073 6581727.268957612, -138922.92404225498 6581954.795898342, -138946.8159847242 6581964.41530986, -139938.37021221558 6581949.812286194, -139952.45944417492 6581955.406612265, -140868.0275192552 6581942.000814841, -140881.49168103898 6581925.799237404, -141370.63532938264 6581378.75940714, -140611.15578408277 6581049.475858836, -139690.6039836331 6580651.2692048885, -140701.38102529195 6580840.959081494, -141466.3464917169 6581171.3088895, -141779.4716755202 6581271.496093299, -142011.00981524787 6581635.151657183, -142357.03529671414 6581674.463083764, -142838.53214884375 6581404.193874537, -142879.22310559888 6581262.5084437225, -142930.87216570028 6580987.212411177, -143534.5331121017 6580882.981201922, -143430.70803588207 6581258.626695622, -143473.24118656976 6581352.886717385, -143492.18998812925 6581960.431922508, -144142.78527346236 6582035.092768761, -144146.60338361078 6581637.428135656, -144191.08020551776 6581601.260220021, -144537.44044373164 6581705.61685815, -144590.74628867855 6581606.573066762, -144763.58673427685 6581465.554340523, -144954.41934581465 6580944.824934003, -145151.23516586225 6581077.603417352, -145568.85455018 6581011.191128295, -145714.98865774274 6580658.3921838915, -146383.20456596403 6580381.6080921125, -147120.06182660736 6580824.107067849, -148440.1510719309 6579967.272995219, -148960.40471687025 6579513.659178475), (-143109.908378959 6582619.958897926, -142984.1537920762 6583123.483449154, -143587.23572115527 6583134.1575482, -143327.76122149464 6582574.317202426, -143109.908378959 6582619.958897926), (-141937.54728911287 6582399.340431561, -141701.905174685 6583118.585429914, -142423.06886593942 6583134.765523819, -142134.0212542649 6582436.348369016, -141937.54728911287 6582399.340431561), (-136955.57202899482 6581910.903352568, -137006.19392140477 6582033.115411777, -137716.5705505733 6582951.997047175, -138024.97013314272 6582044.130371629, -136955.57202899482 6581910.903352568))";
Polygon geom = (Polygon) read(wkt);
Polygon buf = (Polygon) geom.buffer(0.00001, 1);
assertEquals(geom.getNumInteriorRing(), buf.getNumInteriorRing());
}

//===================================================

private static BufferParameters bufParamRoundMitre(double mitreLimit) {
Expand Down

0 comments on commit da0bb91

Please sign in to comment.