terra-draw-route-snap-mode 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/package.json +1 -1
  2. package/.github/FUNDING.yml +0 -4
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -30
  4. package/.github/ISSUE_TEMPLATE/chore.md +0 -11
  5. package/.github/ISSUE_TEMPLATE/documentation-improvement.md +0 -14
  6. package/.github/ISSUE_TEMPLATE/feature-request.md +0 -20
  7. package/.github/pull_request_template.md +0 -14
  8. package/.github/workflows/ci.yml +0 -67
  9. package/.github/workflows/conventional-commit-prs.yml +0 -18
  10. package/.vscode/settings.json +0 -3
  11. package/CNAME +0 -1
  12. package/demo/assets/favicon.ico +0 -0
  13. package/demo/assets/icons/android-chrome-192x192.png +0 -0
  14. package/demo/assets/icons/android-chrome-512x512.png +0 -0
  15. package/demo/assets/icons/apple-touch-icon.png +0 -0
  16. package/demo/assets/icons/favicon-16x16.png +0 -0
  17. package/demo/assets/icons/favicon-32x32.png +0 -0
  18. package/demo/assets/icons/mstile-150x150.png +0 -0
  19. package/demo/assets/imgs/geolocation.png +0 -0
  20. package/demo/assets/imgs/github.png +0 -0
  21. package/demo/assets/imgs/logo.png +0 -0
  22. package/demo/components/app.tsx +0 -18
  23. package/demo/components/geojson-tab/GeoJSONTab.tsx +0 -42
  24. package/demo/components/geojson-tab/style.module.css +0 -30
  25. package/demo/components/geojson-tab/useDownloadJSON.ts +0 -34
  26. package/demo/components/header/Header.tsx +0 -25
  27. package/demo/components/header/style.module.css +0 -78
  28. package/demo/components/info-tab/InfoTab.tsx +0 -101
  29. package/demo/components/info-tab/style.module.css +0 -42
  30. package/demo/components/map-button/ClearButton.tsx +0 -24
  31. package/demo/components/map-button/MapButton.tsx +0 -41
  32. package/demo/components/map-button/style.module.css +0 -42
  33. package/demo/components/map-buttons/MapButtons.tsx +0 -28
  34. package/demo/components/map-buttons/style.module.css +0 -17
  35. package/demo/declaration.d.ts +0 -9
  36. package/demo/index.html +0 -23
  37. package/demo/index.tsx +0 -12
  38. package/demo/manifest.json +0 -21
  39. package/demo/package-lock.json +0 -9231
  40. package/demo/package.json +0 -55
  41. package/demo/public/network.json +0 -432012
  42. package/demo/routes/home/colors.ts +0 -31
  43. package/demo/routes/home/index.tsx +0 -183
  44. package/demo/routes/home/setup-draw.ts +0 -58
  45. package/demo/routes/home/setup-leaflet.ts +0 -41
  46. package/demo/routes/home/setup-routing.ts +0 -67
  47. package/demo/routes/home/style.module.css +0 -119
  48. package/demo/size-plugin.json +0 -1
  49. package/demo/style/index.css +0 -20
  50. package/demo/sw.js +0 -4
  51. package/demo/template.html +0 -30
  52. package/demo/tsconfig.json +0 -7
  53. package/demo/utils/casing.ts +0 -7
  54. package/demo/utils/dates.ts +0 -10
  55. package/demo/utils/geo.ts +0 -4
  56. package/demo/vite.config.js +0 -10
  57. package/docs/api/.nojekyll +0 -1
  58. package/docs/api/assets/highlight.css +0 -92
  59. package/docs/api/assets/icons.js +0 -18
  60. package/docs/api/assets/icons.svg +0 -1
  61. package/docs/api/assets/main.js +0 -60
  62. package/docs/api/assets/navigation.js +0 -1
  63. package/docs/api/assets/search.js +0 -1
  64. package/docs/api/assets/style.css +0 -1493
  65. package/docs/api/classes/Routing.html +0 -14
  66. package/docs/api/classes/TerraDrawRouteSnapMode.html +0 -18
  67. package/docs/api/hierarchy.html +0 -1
  68. package/docs/api/index.html +0 -23
  69. package/docs/api/interfaces/RoutingInterface.html +0 -3
  70. package/docs/api/modules.html +0 -4
  71. package/docs/assets/favicon-r77Z2In5.ico +0 -0
  72. package/docs/assets/index-5ax2eNro.js +0 -4
  73. package/docs/assets/index-CEAM8jr3.css +0 -1
  74. package/docs/assets/index-Cfqr5nmq.js +0 -4
  75. package/docs/assets/index-CkS4Enan.css +0 -1
  76. package/docs/assets/index-CpmDVghy.css +0 -1
  77. package/docs/assets/index-D8NK55L4.js +0 -4
  78. package/docs/assets/index-DJYewHY6.js +0 -4
  79. package/docs/assets/index-DT3pkFX6.js +0 -4
  80. package/docs/assets/index-DZ8OkOfD.js +0 -4
  81. package/docs/assets/index-DjN8PkFw.js +0 -4
  82. package/docs/assets/index-d_nDkStf.js +0 -4
  83. package/docs/assets/index-iILsBcOs.js +0 -4
  84. package/docs/assets/logo-DQvm3LRv.png +0 -0
  85. package/docs/index.html +0 -24
  86. package/docs/network.json +0 -432012
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "terra-draw-route-snap-mode",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A mode for Terra Draw to provide snapping to a route network",
5
5
  "scripts": {
6
6
  "docs": "typedoc",
@@ -1,4 +0,0 @@
1
- # These are supported funding model platforms
2
-
3
- github: [JamesLMilner]
4
-
@@ -1,30 +0,0 @@
1
- ---
2
- name: Bug report
3
- about: Create a report to help us improve Terra Route Snap Mode
4
- title: "[Bug]"
5
- labels: bug
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Describe the bug**
11
- A clear and concise description of what the bug is.
12
-
13
- **Terra Route Snap Mode npm version**
14
- Please tell us exactly which version of Terra Route Snap Mode you are using
15
-
16
- **To Reproduce**
17
- Steps to reproduce the behavior:
18
- 1. Go to '...'
19
- 2. Click on '....'
20
- 3. Scroll down to '....'
21
- 4. See error
22
-
23
- **Expected behavior**
24
- A clear and concise description of what you expected to happen.
25
-
26
- **Screenshots**
27
- If applicable, add screenshots to help explain your problem.
28
-
29
- **Additional context**
30
- Add any other context about the problem here.
@@ -1,11 +0,0 @@
1
- ---
2
- name: Chore
3
- about: Technical improvement tasks like updating a dependency etc
4
- title: '[Chore]'
5
- labels: chore
6
- assignees: ''
7
-
8
- ---
9
-
10
- **What technical task needs doing?**
11
- A clear and concise description of what technical task requires doing, such as updating a dependency, fixing a GitHub action, making a change to GitHub repo settings etc
@@ -1,14 +0,0 @@
1
- ---
2
- name: Documentation improvement
3
- about: Suggest an improvement to the project documentation
4
- title: ''
5
- labels: documentation
6
- assignees: ''
7
-
8
- ---
9
-
10
- **What area of the project documentation is missing, lacking or could be clearer?**
11
- Please write clearly and concisely to explain what problems you hit with the documentation
12
-
13
- **How could this documentation be improved? What would you like to see here?**
14
- Suggestions help guide documentation going forward into the future
@@ -1,20 +0,0 @@
1
- ---
2
- name: Feature request
3
- about: Suggest an idea for Terra Route Snap Mode
4
- title: "[Feature Request]"
5
- labels: enhancement
6
- assignees: ''
7
-
8
- ---
9
-
10
- **Is your feature request related to a problem? Please describe.**
11
- A clear and concise description of what the problem is.
12
-
13
- **Describe your proposed idea for the solution to this problem**
14
- A clear and concise description of what you want to happen.
15
-
16
- **Describe alternatives you've considered**
17
- A clear and concise description of any alternative solutions or features you've considered. For example would this be possible with a custom mode or adapter?
18
-
19
- **Additional context**
20
- Add any other context or screenshots about the feature request here.
@@ -1,14 +0,0 @@
1
- ## Description of Changes
2
-
3
- <!--- Please provide a summary of the changes you have made -->
4
-
5
- ## Link to Issue
6
-
7
- <!--- Please provide a link to the issue for reference. If you have not created an issue, please do so before raising a PR so that it is possible to discuss the changes in advance -->
8
-
9
- ## PR Checklist
10
-
11
- - [ ] The PR title follows the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/#summary) standard
12
- - [ ] There is a associated GitHub issue
13
- - [ ] If I have added significant code changes, there are relevant tests
14
- - [ ] If there are behaviour changes these are documented
@@ -1,67 +0,0 @@
1
- name: CI
2
-
3
- permissions:
4
- contents: read
5
-
6
- on:
7
- push:
8
- branches: [main]
9
- pull_request:
10
- types: [opened, synchronize, reopened, ready_for_review]
11
-
12
- jobs:
13
- lint:
14
- runs-on: ubuntu-latest
15
- steps:
16
- - uses: actions/checkout@v4
17
- - name: Use Node
18
- uses: actions/setup-node@v4
19
- with:
20
- node-version: "22.x"
21
- - name: Install Parent Folder
22
- run: npm install
23
- - name: Run linting
24
- run: npm run lint
25
-
26
- unused:
27
- runs-on: ubuntu-latest
28
- steps:
29
- - uses: actions/checkout@v4
30
- - name: Use Node
31
- uses: actions/setup-node@v4
32
- with:
33
- node-version: "22.x"
34
- - name: Install Parent Folder
35
- run: npm install
36
- - name: Run unused code checking
37
- run: npm run unused
38
-
39
- build:
40
- runs-on: ubuntu-latest
41
- steps:
42
- - uses: actions/checkout@v4
43
- - name: Use Node
44
- uses: actions/setup-node@v4
45
- with:
46
- node-version: "22.x"
47
- - name: Install Parent Folder
48
- run: npm install
49
- - name: Ensure no package-lock.json changes
50
- run: git diff --exit-code
51
- - name: Build
52
- run: npm run build
53
-
54
- unit-tests:
55
- runs-on: ubuntu-latest
56
- steps:
57
- - uses: actions/checkout@v4
58
- - name: Use Node
59
- uses: actions/setup-node@v4
60
- with:
61
- node-version: "22.x"
62
- - name: Install Parent Folder
63
- run: npm install
64
- - name: Test
65
- run: npm run test
66
- env:
67
- CI: true
@@ -1,18 +0,0 @@
1
- name: PR Conventional Commit Validation
2
-
3
- permissions:
4
- pull-requests: read
5
-
6
- on:
7
- pull_request:
8
- types: [opened, synchronize, reopened, edited]
9
-
10
- jobs:
11
- validate-pr-title:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - name: PR Conventional Commit Validation
15
- uses: ytanikin/PRConventionalCommits@1.1.0
16
- with:
17
- task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert"]'
18
- add_label: 'false'
@@ -1,3 +0,0 @@
1
- {
2
- "typescript.tsdk": "node_modules/typescript/lib"
3
- }
package/CNAME DELETED
@@ -1 +0,0 @@
1
- terradraw.io
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,18 +0,0 @@
1
- import { h } from "preact";
2
- // import { Route, Router, CustomHistory } from "preact-router";
3
- // import { createHashHistory } from "history";
4
- import Header from "./header/Header";
5
-
6
- // Code-splitting is automated for `routes` directory
7
- import Home from "../routes/home";
8
-
9
- console.log('App.tsx');
10
-
11
- const App = () => (
12
- <div id="app">
13
- <Header />
14
- <Home />
15
- </div>
16
- );
17
-
18
- export default App;
@@ -1,42 +0,0 @@
1
- import { h } from "preact";
2
- import style from "./style.module.css";
3
- import { useMemo } from "preact/hooks";
4
- import { GeoJSONStoreFeatures } from "../../node_modules/terra-draw/dist/store/store";
5
- import { useDownloadJSON } from "./useDownloadJSON";
6
- import { fileDate } from "../../utils/dates";
7
-
8
- const GeoJSONTab = ({ features }: { features: GeoJSONStoreFeatures[] }) => {
9
- // Create a FeatureCollection when features changes
10
- const featureCollection = useMemo(
11
- () => ({
12
- type: "FeatureCollection",
13
- features,
14
- }),
15
- [features]
16
- );
17
-
18
- // Turn it into a string so it can be rendered,
19
- // again only when features change
20
- const featureCollectionString = useMemo(() => {
21
- return JSON.stringify(featureCollection, null, 4);
22
- }, [featureCollection]);
23
-
24
- const downloadJSON = useDownloadJSON();
25
-
26
- // Download to a file called terradraw.geojson
27
- const downloadGeoJSON = () =>
28
- downloadJSON(featureCollection, `terradraw_${fileDate()}.geojson`);
29
-
30
- return (
31
- <div class={style.container}>
32
- <textarea class={style.geojson} readonly>
33
- {featureCollectionString}
34
- </textarea>
35
- <button class={style.download} onClick={downloadGeoJSON}>
36
- Download GeoJSON
37
- </button>
38
- </div>
39
- );
40
- };
41
-
42
- export default GeoJSONTab;
@@ -1,30 +0,0 @@
1
- .geojson {
2
- resize: none;
3
- width: 100%;
4
- flex-grow: 1;
5
- height: calc(100vh - 193px);
6
- /** accomidate the 3px margin top for the download button **/
7
- }
8
-
9
- .container {
10
- padding: 20px;
11
- display: flex;
12
- flex-grow: 1;
13
- flex-direction: column;
14
- }
15
-
16
- .download {
17
- padding: 10px;
18
- font-weight: bold;
19
- background: #00d088;
20
- color: white;
21
- border: 0;
22
- border: 2px solid rgba(0, 0, 0, 0.2);
23
- margin-top: 3px;
24
- }
25
-
26
- .download:hover {
27
- background: #00d088c4;
28
- border: 2px solid rgba(0, 0, 0, 0.2);
29
- cursor: pointer;
30
- }
@@ -1,34 +0,0 @@
1
- import { useCallback } from "preact/hooks";
2
-
3
- export function useDownloadJSON() {
4
- const downloadJSON = useCallback(
5
- (json: Record<string, any>, filename: string) => {
6
- // Turn the JSON object into a string
7
- const data = JSON.stringify(json, null, 4);
8
-
9
- // Pass the string to a Blob and turn it
10
- // into an ObjectURL
11
- const blob = new Blob([data], { type: "text/plain" });
12
- const jsonObjectUrl = URL.createObjectURL(blob);
13
-
14
- // Create an anchor element, set it's
15
- // href to be the Object URL we have created
16
- // and set the download property to be the file name
17
- // we want to set
18
- const anchorEl = document.createElement("a");
19
- anchorEl.href = jsonObjectUrl;
20
- anchorEl.download = filename;
21
-
22
- // There is no need to actually attach the DOM
23
- // element but we do need to click on it
24
- anchorEl.click();
25
-
26
- // We don't want to keep a reference to the file
27
- // any longer so we release it manually
28
- URL.revokeObjectURL(jsonObjectUrl);
29
- },
30
- []
31
- );
32
-
33
- return downloadJSON;
34
- }
@@ -1,25 +0,0 @@
1
- import { h } from "preact";
2
- import { Link } from "preact-router/match";
3
- import style from "./style.module.css";
4
- import logo from "../../assets/imgs/logo.png";
5
- import github from "../../assets/imgs/github.png";
6
-
7
- const Header = () => (
8
- <header class={style.header}>
9
- <div class={style.nav}>
10
- <img class={style.logo} src={logo} />
11
- <nav>
12
- <Link activeClassName={style.active} href="/">
13
- Home
14
- </Link>
15
- </nav>
16
- </div>
17
- <div class={style.github}>
18
- <a href="https://www.github.com/JamesLMilner/terra-draw">
19
- <img src={github} />
20
- </a>
21
- </div>
22
- </header>
23
- );
24
-
25
- export default Header;
@@ -1,78 +0,0 @@
1
- .header {
2
- width: 100%;
3
- height: 70px;
4
- padding: 0;
5
- background: #fdfdfd;
6
- box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
7
- z-index: 50;
8
- display: flex;
9
- color: #565656;
10
- display: flex;
11
- justify-content: space-between;
12
- }
13
-
14
- .header .nav {
15
- width: 100%;
16
- display: flex;
17
- }
18
-
19
- .github {
20
- display: flex;
21
- justify-items: center;
22
- align-items: center;
23
- margin-right: 20px;
24
- }
25
-
26
- .logo {
27
- height: 35px;
28
- display: flex;
29
- align-self: center;
30
- padding-left: 20px;
31
- }
32
-
33
- .header h1 {
34
- float: left;
35
- margin: 0;
36
- padding: 0 15px;
37
- font-size: 24px;
38
- line-height: 70px;
39
- font-weight: 400;
40
- color: #fdfdfd;
41
- }
42
-
43
- .header nav {
44
- font-size: 100%;
45
- margin-left: 20px;
46
- }
47
-
48
- .header nav a {
49
- display: inline-block;
50
- height: 70px;
51
- line-height: 70px;
52
- padding: 0 15px;
53
- min-width: 50px;
54
- text-align: center;
55
- background: fdfdfd;
56
- text-decoration: none;
57
- color: #565656;
58
- will-change: background-color;
59
- }
60
-
61
- .header nav a:hover,
62
- .header nav a:active {
63
- border-bottom: solid 5px #00d088;
64
- }
65
-
66
- .header nav a.active {
67
- border-bottom: solid 5px #00d088;
68
- }
69
-
70
- @media screen and (max-width: 500px) {
71
- .logo {
72
- display: none;
73
- }
74
-
75
- .header nav {
76
- margin-left: 0px;
77
- }
78
- }
@@ -1,101 +0,0 @@
1
- import { h } from "preact";
2
- import style from "./style.module.css";
3
- import { getHHMMSS } from "../../utils/dates";
4
- import { area, length } from "../../utils/geo";
5
- import { useMemo } from "preact/hooks";
6
- import { GeoJSONStoreFeatures } from "../../node_modules/terra-draw/dist/store/store";
7
-
8
- const InfoTab = ({
9
- selected,
10
- features,
11
- }: {
12
- selected: undefined | GeoJSONStoreFeatures;
13
- features: GeoJSONStoreFeatures[];
14
- }) => {
15
- const { points, lines, polygons } = useMemo(() => {
16
- const points: GeoJSONStoreFeatures[] = [];
17
- const lines: GeoJSONStoreFeatures[] = [];
18
- const polygons: GeoJSONStoreFeatures[] = [];
19
- features.forEach((f) => {
20
- if (f.geometry.type === "Point") {
21
- points.push(f);
22
- }
23
- if (f.geometry.type === "LineString") {
24
- lines.push(f);
25
- }
26
- if (f.geometry.type === "Polygon") {
27
- polygons.push(f);
28
- }
29
- });
30
-
31
- return { points, lines, polygons };
32
- }, [features]);
33
-
34
- return (
35
- <div class={style.container}>
36
- <div class={style.all}>
37
- <h3 class={style.header}> All Features </h3>
38
- <span class={style.row}>
39
- <span class={style.type}>Total</span> {features.length}
40
- </span>
41
- <span class={style.row}>
42
- <span class={style.type}>Polygons:</span>
43
- {polygons.length}
44
- </span>
45
- <span class={style.row}>
46
- <span class={style.type}>LineStrings:</span>
47
- {lines.length}
48
- </span>
49
- <span class={style.row}>
50
- <span class={style.type}>Points:</span>
51
- {points.length}
52
- </span>
53
- </div>
54
- <div class={style.current}>
55
- <h3 class={style.header}> Selected Feature </h3>
56
- <span class={style.row}>
57
- <span class={style.type}>ID</span>
58
- {selected ? (selected.id as string).slice(0, 8) + "..." : "N/A"}
59
- </span>
60
- <span class={style.row}>
61
- <span class={style.type}>Geometry Type</span>
62
- {selected ? selected.geometry.type : "N/A"}
63
- </span>
64
- <span class={style.row}>
65
- <span class={style.type}>Created</span>
66
- {selected
67
- ? getHHMMSS(selected.properties.createdAt as number)
68
- : "N/A"}
69
- </span>
70
- <span class={style.row}>
71
- <span class={style.type}>Updated</span>
72
- {selected
73
- ? getHHMMSS(selected.properties.updatedAt as number)
74
- : "N/A"}
75
- </span>
76
- <span class={style.row}>
77
- <span class={style.type}>Coordinates</span>
78
- {selected && selected.geometry.type === "Polygon"
79
- ? selected.geometry.coordinates[0].length
80
- : selected && selected.geometry.type === "LineString"
81
- ? selected.geometry.coordinates.length
82
- : "N/A"}
83
- </span>
84
- <span class={style.row}>
85
- <span class={style.type}>Area (m2)</span>
86
- {selected && selected.geometry.type === "Polygon"
87
- ? area(selected).toFixed(2)
88
- : "N/A"}
89
- </span>
90
- <span class={style.row}>
91
- <span class={style.type}>Length (km)</span>
92
- {selected && selected.geometry.type === "LineString"
93
- ? length(selected).toFixed(2)
94
- : "N/A"}
95
- </span>
96
- </div>
97
- </div>
98
- );
99
- };
100
-
101
- export default InfoTab;
@@ -1,42 +0,0 @@
1
- .current,
2
- .all {
3
- display: flex;
4
- flex-direction: column;
5
- border-radius: 20px;
6
- border: solid 3px #565656;
7
- padding: 20px;
8
- margin-bottom: 20px;
9
- }
10
-
11
- .header {
12
- margin-top: 0;
13
- font-weight: bolder;
14
- font-size: 20px;
15
- text-transform: capitalize;
16
- }
17
-
18
- .type {
19
- display: inline-block;
20
- width: 150px;
21
- }
22
-
23
- button:hover {
24
- background: white;
25
- border: solid 3px #222222;
26
- }
27
-
28
- .container {
29
- width: 100%;
30
- padding: 20px;
31
- }
32
-
33
- .row {
34
- width: 100%;
35
- display: flex;
36
- justify-content: space-between;
37
- border-bottom: 1px solid #d9d9d9;
38
- margin-bottom: 10px;
39
- white-space: nowrap;
40
- overflow: hidden;
41
- text-overflow: ellipsis;
42
- }
@@ -1,24 +0,0 @@
1
- import { h } from "preact";
2
- import style from "./style.module.css";
3
-
4
- const ClearButton = ({
5
- label,
6
- onClick,
7
- }: {
8
- onClick: () => void;
9
- label?: string;
10
- }) => {
11
- return (
12
- <button
13
- id={'clear'}
14
- class={style.button}
15
- onClick={() => {
16
- onClick()
17
- }}
18
- >
19
- {label}
20
- </button>
21
- );
22
- };
23
-
24
- export default ClearButton;
@@ -1,41 +0,0 @@
1
- import { h } from "preact";
2
- import style from "./style.module.css";
3
- import { titleCase } from "../../utils/casing";
4
-
5
- const MapButton = ({
6
- mode,
7
- currentMode,
8
- changeMode,
9
- label,
10
- hiddenOnTouch,
11
- }: {
12
- mode: string;
13
- currentMode: string;
14
- changeMode: (mode: string) => void;
15
- label?: string;
16
- hiddenOnTouch?: boolean;
17
- }) => {
18
- let classes = style.button;
19
-
20
- if (hiddenOnTouch) {
21
- classes = `${style.hiddenOnMobile} ${classes}`;
22
- }
23
-
24
- if (currentMode === mode) {
25
- classes = `${style.active} ${classes}`;
26
- }
27
-
28
- return (
29
- <button
30
- id={mode}
31
- class={classes}
32
- onClick={() => {
33
- changeMode(mode);
34
- }}
35
- >
36
- {label ? label : titleCase(mode)}
37
- </button>
38
- );
39
- };
40
-
41
- export default MapButton;