I am using OL3 and I try to inspect whether two lines are intersecting or not using turf. I used GeoJSON in OL3 and fed the lines into the intersect() in turf but I get Unknown GeoJSON type. here is my code:
lineStringdraw.on('drawend', function(e2) {var featureEnd = e2.feature;checkIntersection(featureEnd);});function checkIntersection(currentFeature){var features = vectorLayer.getSource().getFeatures();var geoJSON = new ol.format.GeoJSON();geoJSON = geoJSON.writeFeature(currentFeature);for (i=0; (features.length)>i;i++){var feature = features;geoJSON_i = geoJSON.writeFeature(feature);var intersectionStatus = turf.intersect(geoJSON,geoJSON_i);$('#infoList').append(intersectionStatus);}}here is piece of the OL3 GeoJSON:
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-8236104.129670544,4977029.890789877],[-8236634.411554272,4974407.145256842]]},"properties":null}Does anyone know why it is not working or what I am missing?
أكثر...
lineStringdraw.on('drawend', function(e2) {var featureEnd = e2.feature;checkIntersection(featureEnd);});function checkIntersection(currentFeature){var features = vectorLayer.getSource().getFeatures();var geoJSON = new ol.format.GeoJSON();geoJSON = geoJSON.writeFeature(currentFeature);for (i=0; (features.length)>i;i++){var feature = features;geoJSON_i = geoJSON.writeFeature(feature);var intersectionStatus = turf.intersect(geoJSON,geoJSON_i);$('#infoList').append(intersectionStatus);}}here is piece of the OL3 GeoJSON:
{"type":"Feature","geometry":{"type":"LineString","coordinates":[[-8236104.129670544,4977029.890789877],[-8236634.411554272,4974407.145256842]]},"properties":null}Does anyone know why it is not working or what I am missing?
أكثر...