1

I am giving this for intersection of a polyline using Leaflet draw plugin with polygons feature class. Here is my code

function intersectPolyByPolyFC(poly,fcPoly){
        var fgp=[];//variable for feature group
        var bbPoly=turf.bboxPolygon(turf.bbox(poly));//polygon representation of the bounding box of a reference polygon
        for(var i=0;i<fcPoly.features.length;i++){//loop through the feature collection of polygons
            var bb=turf.bboxPolygon(turf.bbox(fcPoly.features[i]));//variable bb represents each polygon for feature collection
            if(turf.intersect(bbPoly,bb)){//condition to check if the two bounding boxes intersect
                var int= turf.intersect(poly,fcPoly.features[i]);
                if(int){
                    int.properties=fcPoly.features[i].properties;
                    fgp.push(int);
                }
            }
        }
        return turf.featureCollection(fgp);
    }


**Function Definition**
var bufLine= turf.buffer(line,5,{units:"kilometers"});
                        var intBUOWL = intersectPolyByPolyFC(bufLine,
                        lyrBUOWL.toGeoJSON());
                        L.geoJSON(intBUOWL,{style:{color:'black', width:5}}).addTo(mymap);

I am not getting any error on console and moreover my intersection is not performed on the map. What is could the problem be with my code?

5
  • 4
    Please don't post the same question again. If you have additional info, edit the original question. Polygon intersection using turf js
    – TomazicM
    Mar 27, 2021 at 14:13
  • ok sir but did u found any problem with my code Mar 27, 2021 at 14:48
  • May I remind you of your last comment in the previous question: "ok sir i will provide more of the code". You never provided one.
    – TomazicM
    Mar 27, 2021 at 16:32
  • sir this is the full code i have provided sir Mar 28, 2021 at 4:56
  • Then edit the original question and put the code there. This question is now closed as duplicate.
    – TomazicM
    Mar 28, 2021 at 7:19

0

Browse other questions tagged or ask your own question.