Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:codeofsumit/leaflet.pm into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
codeofsumit committed Jun 22, 2018
2 parents 054767a + 43ea547 commit e035406
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/js/Draw/L.PM.Draw.Cut.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Draw.Cut = Draw.Poly.extend({
// only layers with intersections
.filter((l) => {
try {
return !!intersect(layer.toGeoJSON(), l.toGeoJSON());
return !!intersect(layer.toGeoJSON(15), l.toGeoJSON(15));
} catch (e) {
console.error('You cant cut polygons with self-intersections');
return false;
Expand All @@ -37,7 +37,7 @@ Draw.Cut = Draw.Poly.extend({
// the resulting layers after the cut
const resultingLayers = [];
// find layer difference
const diff = difference(l.toGeoJSON(), layer.toGeoJSON());
const diff = difference(l.toGeoJSON(15), layer.toGeoJSON(15));

// add new layer to map
const newL = L.geoJSON(diff, l.options).addTo(this._map);
Expand Down
4 changes: 2 additions & 2 deletions src/js/Draw/L.PM.Draw.Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Draw.Line = Draw.extend({
},
hasSelfIntersection() {
// check for self intersection of the layer and return true/false
const selfIntersection = kinks(this._layer.toGeoJSON());
const selfIntersection = kinks(this._layer.toGeoJSON(15));
return selfIntersection.features.length > 0;
},
_syncHintLine() {
Expand Down Expand Up @@ -177,7 +177,7 @@ Draw.Line = Draw.extend({
clone.addLatLng(this._hintMarker.getLatLng());

// check the self intersection
const selfIntersection = kinks(clone.toGeoJSON());
const selfIntersection = kinks(clone.toGeoJSON(15));
this._doesSelfIntersect = selfIntersection.features.length > 0;

// change the style based on self intersection
Expand Down
4 changes: 2 additions & 2 deletions src/js/Edit/L.PM.Edit.Line.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Edit.Line = Edit.extend({

hasSelfIntersection() {
// check for self intersection of the layer and return true/false
const selfIntersection = kinks(this._layer.toGeoJSON());
const selfIntersection = kinks(this._layer.toGeoJSON(15));
return selfIntersection.features.length > 0;
},

Expand Down Expand Up @@ -151,7 +151,7 @@ Edit.Line = Edit.extend({

// fire intersect event
this._layer.fire('pm:intersect', {
intersection: kinks(this._layer.toGeoJSON()),
intersection: kinks(this._layer.toGeoJSON(15)),
});
} else {
// if not, reset the style to the default color
Expand Down
6 changes: 3 additions & 3 deletions src/js/Mixins/Overlap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var OverlapMixin = {
const mainPoly = this._poly;
const layers = this._layerGroup.getLayers();
let changed = false;
let resultingGeoJson = this._poly.toGeoJSON();
let resultingGeoJson = this._poly.toGeoJSON(15);

layers
.filter(layer => !Object.is(layer, mainPoly))
Expand All @@ -44,13 +44,13 @@ var OverlapMixin = {
// this needs to be in a try catch block because turf isn't reliable
// it throws self-intersection errors even if there are none
try {
intersect = turf.intersect(resultingGeoJson, layer.toGeoJSON());
intersect = turf.intersect(resultingGeoJson, layer.toGeoJSON(15));
} catch(e) {
console.warn('Turf Error.');
}

if(intersect) {
resultingGeoJson = turf.difference(resultingGeoJson, layer.toGeoJSON());
resultingGeoJson = turf.difference(resultingGeoJson, layer.toGeoJSON(15));

// if the resulting polygon is a MultiPolygon, don't handle it.
if(resultingGeoJson.geometry.type !== 'MultiPolygon') {
Expand Down

0 comments on commit e035406

Please sign in to comment.