Boost logo

Geometry :

Subject: [geometry] Issue with geometry::buffer / geometry::intersects
From: joan (joan.abadie_at_[hidden])
Date: 2014-12-05 11:15:44


Hello,

I have a workflow where I build a buffer from a non self intersecting
linestring.
The result polygon is self intersecting (geometry::intersects() returns
true).
How can this be possible ?!
When displayed, result polygon doesn't seem to self intersect.

I have joined the code to reproduce. (sorry the line string is a bit
long...)

Joan Abadie

  

        typedef double coordinate_type;
        typedef boost::geometry::model::d2::point_xy<coordinate_type> point_type;
        typedef boost::geometry::model::polygon<point_type> polygon;
        typedef boost::geometry::model::linestring<point_type> linestring;
        typedef boost::geometry::model::multi_polygon<polygon> multipolygon;

        linestring inputLineString, blue;
        std::string st1;
        st1 += "LINESTRING(5454.2947159936402 8811.0038968534172,
5455.0251336401552 8811.0389221560308, 5455.8162372512370
8811.0767871926600, 5456.5435363464940 8811.1111608986903,
5457.3369075296960 8811.1484206667483, 5458.0627579619795
8811.1825001456054, 5458.8567367055675 8811.2196905326000,
5459.5828286600254 8811.2532568662627, 5460.3758145640650
8811.2897020426572, 5461.1038106775522 8811.3231533560065,
5461.8941435859178 8811.3593648078295, 5462.6257457254769
8811.3924301125153, 5463.4118070037830 8811.4277585100263,
5464.1487111708821 8811.4606529118719, 5464.9288372267974
8811.4949997881940, 5465.6727746855004 8811.5276941869215,
5466.4452508330360 8811.5615164181982, 5467.2141063796007
8811.5946881487343, 5467.9614921071816 8811.6266512821858,
5468.7387224025706 8811.6593971887887, 5469.4784003686882
8811.6904114260487, 5470.2623128502746 8811.7229804602357,
5470.9960250078620 8811.7530406255028, 5471.7849594078125
8811.7850104827048, 5472.5144178787359 8811.8141633625291,
5473.3067217952548 8811.8454539443683, 5474.0336240265642
8811.8736171420860, 5474.8276711430226 8811.9038566647814,
5475.5536851933812 8811.9314051306228, 5476.3478099468057
8811.9614475695253, 5477.0746106454781 8811.9884787947904,
5477.8672167599043 8812.0173611439077, 5478.5964963366041
8812.0435964732369, 5479.3859208477843 8812.0719637920047,
5480.1193468379661 8812.0981072132763, 5480.9039493967657
8812.1255946365400, 5481.6432418153445 8812.1514291375843,
5482.4213274151098 8812.1786093849787, 5483.1682136780937
8812.2044631460249, 5483.9381108659591 8812.2306441586679,
5484.7101428299120 8812.2568508007134, 5485.4550548005409
8812.2821368539917, 5486.2348964592411 8812.3085633694973,
5486.9726561563248 8812.3332727934358, 5487.7586142318260
8812.3598318371951, 5488.4909291904642 8812.3846902846217,
5489.2813326453197 8812.4114536188918, 5490.0099352750476
8812.4357033903143, 5490.8031535490236 8812.4621303149852,
5491.5297175289634 8812.4862587259795, 5492.3241113212543
8812.5124396348583, 5493.0503200986914 8812.5363648497423,
5493.8442510227451 8812.5625211956194, 5494.5717748516454
8812.5865091398464, 5495.3635975536990 8812.6130089119924,
5496.0940972463604 8812.6377847560943, 5496.8821723447472
8812.6645359826980, 5497.6173669216705 8812.6894921788316,
5498.4000537975771 8812.7159438249273, 5499.1416814847516
8812.7405413318247, 5499.9173125769148 8812.7662209966493,
5500.6743718401349 8812.7917641592430, 5501.4340320111151
8812.8175499625722, 5502.2088087245047 8812.8438497752049,
5502.9511832325879 8812.8690496942600, 5503.7332098499837
8812.8955982336793, 5504.4689853232539 8812.9207239351217,
5505.2565551656508 8812.9481115382314, 5505.9874431328790
8812.9734929999595, 5506.7789374893991 8813.0004821296970,
5507.5066707388869 8813.0251850509085, 5508.3004308646487
8813.0522081489780, 5509.0266563875475 8813.0773717816010,
5509.8210246389490 8813.1051219961464, 5510.5474307286268
8813.1304877886851, 5511.3408159437349 8813.1578110231148,
5512.0691112726890 8813.1825552063601, 5512.8598798623352
8813.2093978635839, 5513.5917283644294 8813.2342404771334,
5514.3782219974892 8813.2609291709759, 5515.1153334815599
8813.2857225710104, 5515.8959112602606 8813.3115013155275,
5516.6400222752636 8813.3360163262041, 5517.4129712629856
8813.3614814144785, 5518.1819641341690 8813.3868153014264,
5518.9297861466948 8813.4113179927153, 5519.7071687063908
8813.4363403045154, 5520.4472265953909 8813.4604601300216,
5521.2312860286902 8813.4862780582644, 5521.9653076285622
8813.5104606694531, 5522.7543867781096 8813.5364571718364,
5523.4840933910045 8813.5604976241921, 5524.2765397935163
8813.5866050619588, 5525.0036245423798 8813.6105591360447,
5525.7978003192684 8813.6367235486869, 5526.5239444295757
8813.6606466330886, 5527.3182193879047 8813.6868143132979,
5528.0450998269525 8813.7107616563226, 5528.8378442140092
8813.7368789112988, 5529.5671412819220 8813.7609058710477,
5530.3567185447137 8813.7869187839533, 5531.0901235032334
8813.8110810796679, 5531.8748829722545 8813.8369352685859,
5532.6141057981968 8813.8612892360798, 5533.3923748860643
8813.8869394966150, 5534.1391440479856 8813.9117880229769,
5534.9092041269842 8813.9378806771783, 5535.6810808832824
8813.9640820507011, 5536.4261368452799 8813.9893729917712,
5537.2058522052557 8814.0158450081417, 5537.9437042535392
8814.0411589087144, 5538.7295406374533 8814.0685000676804,
5539.4619355924269 8814.0934227749258, 5540.2522718010541
8814.1202507549660, 5540.9809100719767 8814.1449843971477,
5541.7740733470073 8814.1719842914481, 5542.5006236864247
8814.1971553365584, 5543.2949577174049 8814.2249039458493,
5544.0211090086523 8814.2502792314917, 5544.8150086914866
8814.2780219780307, 5545.5424455743987 8814.3034421885477,
5546.3342801633871 8814.3311127705856, 5547.0646848414935
8814.3566574253127, 5547.8527992453937 8814.3846180724722,
5548.5878514162459 8814.4108186637568, 5549.3706005004606
8814.4386820210511, 5550.1120278655098 8814.4653147663357,
5550.8877245012200 8814.4931969582994, 5551.6442780723692
8814.5203910583223, 5552.4043342018604 8814.5477110567972,
5553.1789102620733 8814.5755935768593, 5553.9213493714688
8814.6027560777711, 5554.7031788147688 8814.6316269503277,
5555.4389839760970 8814.6588110628054, 5556.2264076597939
8814.6879058249178, 5556.9573038552717 8814.7150680267005,
5557.7486379492357 8814.7449732421355, 5558.4763086393104
8814.7725845688601, 5559.2699283565016 8814.8027771805737,
5559.9960594696931 8814.8308420343255, 5560.7903135243760
8814.8617653219590, 5561.5165929962441 8814.8900686443631,
5562.3098636447330 8814.9213637604298, 5563.0379512903637
8814.9504251801700, 5563.8286062416546 8814.9820081575490,
5564.5602135168147 8815.0112536843972, 5565.3466062106936
8815.0431004439943, 5566.0834088914053 8815.0732506510576,
5566.8638792709717 8815.1052076246833, 5567.6076305552851
8815.1356611060764, 5568.3805024079047 8815.1673172695864,
5569.1490964268623 8815.1990559161168, 5569.8968187797891
8815.2303839567139, 5570.6737855607707 8815.2629748535310,
5571.4137088400321 8815.2940244014990, 5572.1973859082027
8815.3272092257448, 5572.9312233546989 8815.3586937725995,
5573.7199283758455 8815.3925662367965, 5574.4494200714889
8815.4239105714787, 5575.2415051835105 8815.4582809601179,
5575.9683161720841 8815.4901952731452, 5576.7621399994687
8815.5250820669626, 5577.4879795663965 8815.5569811035512,
5578.2819316387631 8815.5918735334508, 5579.0084772502087
8815.6238035991282, 5579.8009285586277 8815.6586300737854,
5580.5298596788989 8815.6906649772773, 5581.3191741817154
8815.7253618916129, 5582.0521714005326 8815.7577945616031,
5582.8366684592484 8815.7929866839386, 5583.5754272136319
8815.8261929361543, 5584.3534642417162 8815.8611646960780,
5585.0997426839367 8815.8947089485755, 5585.8696269992042
8815.9293142545903, 5586.6410136238746 8815.9639870874762,
5587.3858912603200 8815.9974683755645, 5588.1651459388013
8816.0324476692458, 5588.9028221639956 8816.0651246638663,
5589.6882777924175 8816.0997138594594, 5590.4204509768524
8816.1323803366886, 5591.2103797767759 8816.1678749052244,
5591.9387546561948 8816.2006144156858, 5592.7315406726857
8816.2362491236072, 5593.4578159160583 8816.2688942581426,
5594.2518257130505 8816.3045839734132, 5594.9776796320466
8816.3372101699606, 5595.7712846855711 8816.3728816925395,
5596.4983936851095 8816.4055643033371, 5597.2899636745615
8816.4411443524095, 5598.0200098427749 8816.4739589851488,
5598.8079053990159 8816.5093738731921, 5599.5425841616698
8816.5423967350725, 5600.3251495142777 8816.5775720373422,
5601.0661774411255 8816.6108802859544, 5601.8417328818614
8816.6457405017391, 5602.5975641498080 8816.6797141414208,
5603.3577930291485 8816.7138854480581, 5604.1319433783583
8816.7486825067917, 5604.8742640950259 8816.7820488646357,
5605.6557220553186 8816.8171743910534, 5606.3913897119364
8816.8502417024374, 5607.1784705800883 8816.8856199713027,
5607.9092062769587 8816.9184655974641, 5608.7002506349954
8816.9540220200852, 5609.4277529366782 8816.9867223093079,
5610.2211190742619 8817.0223830929208, 5610.9470718518041
8817.0550137330320, 5611.7411283873307 8817.0907055491425,
5612.4672084929525 8817.1233419124874, 5613.2603313721102
8817.1588960359404, 5613.9882400638371 8817.1910779334012,
5614.7788231050017 8817.2258286259002, 5615.5102308049409
8817.2579723695908, 5616.2966000019387 8817.2925227197356,
5617.0332096669135 8817.3246674946276, 5617.8137322971197
8817.3582513214860, 5618.5572817137372 8817.3901844908414,
5619.3302400748216 8817.4233806842585, 5620.0986197860993
8817.4563802386983, 5620.8464643566203 8817.4884978717528,
5621.6232625899074 8817.5218589759133, 5622.3632790335023
8817.5536404149007, 5623.1468308074254 8817.5872886375182,
5623.8807665605254 8817.6186562814510, 5624.6694239396065
8817.6518654494466, 5625.3990099534130 8817.6824688974866,
5626.1910976263143 8817.7156940600908, 5626.9180023932850
8817.7461850396940, 5627.7118772242156 8817.7794851669969,
5628.4377816971246 8817.8099341879479, 5629.2318138921501
8817.8432409160978, 5629.9583944953210 8817.8737182982240,
5630.7509549589940 8817.9069632926603, 5631.4798911770049
8817.9375394841591, 5632.2693486856715 8817.9705481372348,
5633.0023536873523 8818.0007396409710, 5633.7870775427500
8818.0329892021218, 5634.5258209017875 8818.0638086588824,
5635.3040946754445 8818.0963300445928, 5636.0503447735127
8818.1270443439989, 5636.8205200456860 8818.1585918757501,
5637.5918714052732 8818.1904509465639, 5638.3369930665749
8818.2216590354437, 5639.1162337832538 8818.2540476580489,
5639.8541277615268 8818.2842943561409, 5640.6395907629822
8818.3164557566233, 5641.3719619296726 8818.3464432701658,
5642.1619597350036 8818.3787903517623, 5642.8905118468192
8818.4086367622349, 5643.6833825932863 8818.4414550179499,
5644.4097829416751 8818.4717383908082, 5645.2039014330112
8818.5047384528225, 5645.9298437193311 8818.5351642371497,
5646.7235736417915 8818.5684582860795, 5647.4507401367882
8818.5989602442096, 5648.2424639371229 8818.6321701436973,
5648.9725369447297 8818.6628147127194, 5649.7605971456142
8818.6962992677054, 5650.4952434253146 8818.7278306975386,
5651.2779874545349 8818.7614471554189, 5652.0189517069330
8818.7932692998911, 5652.7947101489399 8818.8267094480307,
5653.5501346411147 8818.8597531184278, 5654.3108465779060
8818.8931837582149, 5655.0848851375067 8818.9272010334880,
5655.8273735928842 8818.9598317517648, 5656.6087503711924
8818.9941741034054, 5657.3445478416625 8819.0266601255607,
5658.1315511753910 8819.0618473267732, 5658.8623748681957
8819.0943644582767, 5659.6533677631951 8819.1298077602150,
5660.3809130539366 8819.1625099817393, 5661.1742520263397
8819.1981695443137, 5661.9002177745278 8819.2308007674401,
5662.6942762607950 8819.2664926712314, 5663.4203393773396
8819.2991282709390, 5664.2134890695606 8819.3347793256125,
5664.9413269059914 8819.3674946966912, 5665.7319354610599
8819.4030315305263, 5666.4632334102216 8819.4359024292044,
5667.2496521467510 8819.4713621903229, 5667.9860856995210
8819.5050296276568, 5668.7666270297586 8819.5408918613812,
5669.5099384350297 8819.5750469101440, 5670.2829498388828
8819.6104407677740, 5671.0510940290706 8819.6451212672164,
5671.7990289182135 8819.6787399748646, 5672.5756228078426
8819.7136468675853, 5673.3156988322980 8819.7469123294140,
5674.0990758835505 8819.7821212038452, 5674.8330412008336
8819.8149594446750, 5675.6215544484558 8819.8497409727206,
5676.3511411518630 8819.8818046876568, 5677.1431140565328
8819.9166101375577, 5677.8699903130782 8819.9485385899134,
5678.6637955305932 8819.9830533796212, 5679.3896712967662
8820.0142529353343, 5680.1836815905817 8820.0483465978614,
5680.9102128537179 8820.0793541348630, 5681.7028104281208
8820.1126842136709, 5682.4316983031222 8820.1430519523401,
5683.2212510708860 8820.1754534074371, 5683.9541850007154
8820.2052454032382, 5684.7390422506633 8820.2366671599611,
5685.4777219622656 8820.2661506603381, 5686.2562018808894
8820.2967933487944, 5687.0023680903023 8820.3258693697644,
5687.7727694396808 8820.3557443265454, 5688.5440607668124
8820.3851607247034, 5689.2894454901070 8820.4134325176619,
5690.0686831379471 8820.4427034390374, 5690.8068064935596
8820.4700063705641, 5691.5922956457025 8820.4990227977705,
5692.3248701870361 8820.5259318203825, 5693.1149485645210
8820.5544561292681, 5693.8436945956328 8820.5806506953886,
5694.6366977820098 8820.6090744704215, 5695.3633073201845
8820.6345087518039, 5696.1576416166845 8820.6615890108151,
5696.8837963400892 8820.6862383490261, 5697.6777879558731
8820.7131904120524, 5698.4051382866410 8820.7378803351803,
5699.1971523849552 8820.7647652713313, 5699.9273808056896
8820.7895528912886, 5700.7157777564053 8820.8163150432865,
5701.4505798172504 8820.8412579155574, 5702.2337038475180
8820.8678410781522, 5702.9747959688921 8820.8929974666680,
5703.7509676313912 8820.9193446309855, 5704.5062321691430
8820.9449821024882, 5705.2676892762383 8820.9708407029339,
5706.0418725212367 8820.9974025371484, 5706.7847608769780
8821.0233280276625, 5707.5662985239633 8821.0506387841870,
5708.3024678815282 8821.0763641502763, 5709.0896903332150
8821.1038771081276, 5709.8208590431905 8821.1295863421128,
5710.6120820458636 8821.1579041681634, 5711.3399354476251
8821.1840666489825, 5712.1335325826085 8821.2126650943355,
5712.8597638133751 8821.2391008486902, 5713.6541090458595
8821.2677484494125, 5714.3804197323416 8821.2938554777757,
5715.1738881550500 8821.3223836636662, 5715.9019368261397
8821.3487553395826, 5716.6928670215111 8821.3778915073890,
5717.4243275202471 8821.4049151076542, 5718.2110979992513
8821.4339821194189, 5718.9476908211664 8821.4611953319054,
5719.7286421700001 8821.4900473575635, 5720.4720912216972
8821.5175380603141, 5721.2455174537727 8821.5465751891497,
5722.0137304612763 8821.5757092958975, 5722.7620387158768
8821.6041037112209, 5723.5387209588507 8821.6335747721714,
5724.2791366252195 8821.6616697047266, 5725.0626340927502
8821.6913993680882, 5725.7968996228692 8821.7192609348840,
5726.5855352973194 8821.7491855665339, 5727.3153648928328
8821.7768788126286, 5728.1074848131229 8821.8069356533288,
5728.8345724436222 8821.8345248560818, 5729.6285381922389
8821.8646517363868, 5730.3545647182118 8821.8922181149501,
5731.1487314388742 8821.9227348583045, 5731.8753554028108
8821.9508153956413, 5732.6681193549539 8821.9809954227912,
5733.3970507313234 8822.0088606883983, 5734.1867420900080
8822.0395340370123, 5734.9196397742389 8822.0680549996778,
5735.7046464031764 8822.0981975346640, 5736.4432556301872
8822.1264734273900, 5737.2218798147587 8822.1567374420229,
5737.9678979125238 8822.1857910904182, 5738.7384533292443
8822.2158003438326, 5739.5095633839337 8822.2458311976043,
5740.2550652680920 8822.2748647420794, 5741.0341350989183
8822.3052055890494, 5741.7723187247402 8822.3339541242131,
5742.5576515177536 8822.3645388820241, 5743.2902491213927
8822.3930698697532, 5744.0801763124991 8822.4238335562331,
5744.8088945369809 8822.4522134616782, 5745.6017681339290
8822.4830918958305, 5746.3282959610224 8822.5113864963259,
5747.1224808610550 8822.5423220419616, 5747.8484900025996
8822.5707833337019, 5748.6423336220832 8822.6023101788269,
5749.3695000131174 8822.6310238347633, 5750.1613917096329
8822.6625750418953, 5750.8913922196871 8822.6917351573848,
5751.6796937787094 8822.7232241278507, 5752.4142373328687
8822.7525435465122, 5753.1973144056838 8822.7833804872644,
5753.9381433326844 8822.8122498159282, 5754.7143125432685
8822.8424877923007, 5755.4689828465162 8822.8721331534780,
5756.2307284116660 8822.9023867501401, 5757.0046273850721
8822.9326736667899, 5757.7475408353830 8822.9616064048023,
5758.5288461837426 8822.9920368543935, 5759.2650059341295
8823.0208555371610, 5760.0519995522427 8823.0521609832958,
5760.7831120329465 8823.0813510832959, 5761.5741667381044
8823.1126093020393)";
        boost::geometry::read_wkt(st1, inputLineString);

        // Declare strategies
        const int points_per_circle = 36;
        boost::geometry::strategy::buffer::distance_symmetric<coordinate_type>
distance_strategy(1);
        boost::geometry::strategy::buffer::join_round
join_strategy(points_per_circle);
        boost::geometry::strategy::buffer::end_round
end_strategy(points_per_circle);
        boost::geometry::strategy::buffer::point_circle
circle_strategy(points_per_circle);
        boost::geometry::strategy::buffer::side_straight side_strategy;

        // Declare output
        boost::geometry::model::multi_polygon<polygon> result;

        // Do the buffer
        boost::geometry::buffer(inputLineString, result, distance_strategy,
side_strategy, join_strategy, end_strategy, circle_strategy);

        cout << "result polygon size : " << result.size() << endl;
        cout << "intersect : " << boost::geometry::intersects(result.front()) <<
endl;
        cout << "is_valid : " << boost::geometry::is_valid(result.front()) << endl;
        cout << "is_simple : " << boost::geometry::is_simple(result.front()) <<
endl;

--
View this message in context: http://boost-geometry.203548.n3.nabble.com/Issue-with-geometry-buffer-geometry-intersects-tp4026387.html
Sent from the Boost Geometry mailing list archive at Nabble.com.

Geometry list run by mateusz at loskot.net