Add intersection function

This commit is contained in:
Pieter Vander Vennet 2021-12-19 02:11:22 +01:00
parent be9784e047
commit 99a38f2b10
5 changed files with 75 additions and 8 deletions

View file

@ -356,7 +356,7 @@ export class GeoOperations {
* Returns 0 if both are linestrings
* Returns null if the features are not intersecting
*/
static calculateInstersection(feature, otherFeature, featureBBox: BBox, otherFeatureBBox?: BBox): number {
private static calculateInstersection(feature, otherFeature, featureBBox: BBox, otherFeatureBBox?: BBox): number {
try {
if (feature.geometry.type === "LineString") {
@ -442,6 +442,13 @@ export class GeoOperations {
return undefined;
}
/**
* Calculates line intersection between two features.
*/
public static LineIntersections(feature, otherFeature): [number,number][]{
return turf.lineIntersect(feature, otherFeature).features.map(p =><[number,number]> p.geometry.coordinates)
}
public static AsGpx(feature, generatedWithLayer?: LayerConfig){
const metadata = {}