-
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.
Admin/Subsection: transform multilinestring from felt api response
- Loading branch information
1 parent
1961b49
commit 7333f3e
Showing
3 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/subsections/components/utils/multilinestringToLinestring.ts
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const multilinestringToLinestring = (multi: Array<Array<[number, number]>>) => { | ||
let linestring = multi[0] | ||
if (multi.length < 2) { | ||
return linestring | ||
} | ||
for (let i = 1; i < multi.length; i++) { | ||
{ | ||
if ( | ||
// @ts-expect-error | ||
multi[i][0][0] === multi[i - 1][multi[i - 1].length - 1][0] && | ||
// @ts-expect-error | ||
multi[i][0][1] === multi[i - 1][multi[i - 1].length - 1][1] | ||
) { | ||
linestring?.pop() | ||
// @ts-expect-error | ||
linestring = linestring?.concat(multi[i]) | ||
} | ||
} | ||
return linestring | ||
} | ||
} |
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