-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[+] keep old id for rest from diffential; trigger draw.create onStop;…
… [*] import module;
- Loading branch information
Showing
5 changed files
with
114 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
import * as turf from '@turf/turf'; | ||
import _ from 'lodash'; | ||
import { polygon } from '@turf/helpers'; | ||
import { getType } from '@turf/invariant'; | ||
import difference from '@turf/difference'; | ||
import booleanPointInPolygon from '@turf/boolean-point-in-polygon'; | ||
import _assign from 'lodash/assign'; | ||
import _find from 'lodash/find'; | ||
import _map from 'lodash/map'; | ||
import _get from 'lodash/get'; | ||
|
||
export default function (PolyA, PolyB, point) { | ||
let feature = turf.difference(PolyA, PolyB); | ||
if (turf.getType(feature) === 'MultiPolygon') { | ||
feature = _.chain(feature).get('geometry.coordinates') | ||
.map(function (v) { | ||
const properties = _(feature).get('properties'); | ||
return turf.polygon(v, properties); | ||
}) | ||
.filter(function (v) { | ||
return turf.booleanPointInPolygon(point, v); | ||
}).get('[0]').value(); | ||
let feature = difference(PolyA, PolyB); | ||
if (getType(feature) === 'MultiPolygon') { | ||
feature = _get(feature, 'geometry.coordinates'); | ||
feature = _map(feature, function (v) { | ||
const properties = _get(feature, 'properties'); | ||
return polygon(v, properties); | ||
}); | ||
feature = _find(feature, function (v) { | ||
return booleanPointInPolygon(point, v); | ||
}); | ||
} | ||
return _.create(feature); | ||
return _assign({}, feature); | ||
} |
This file was deleted.
Oops, something went wrong.