Storing track points independently from their tracks (#3). Also adding some basic tests for gpx database operations.

This commit is contained in:
Eric van der Vlist 2022-09-26 21:48:46 +02:00
parent e1da4a1e4a
commit 6e9fc21830
7 changed files with 130 additions and 83 deletions

73
package-lock.json generated
View File

@ -28,6 +28,7 @@
"@trapezedev/configure": "^5.0.3",
"@types/jest": "^26.0.20",
"@types/node": "^12.19.15",
"@types/pouchdb": "^6.4.0",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"@types/react-router": "^5.1.11",
@ -40,6 +41,7 @@
"isomorphic-xml2js": "^0.1.3",
"lodash": "^4.17.21",
"pouchdb": "^7.3.0",
"pouchdb-browser": "^7.3.0",
"pouchdb-find": "^7.3.0",
"react": "^18.2.0",
"react-app-polyfill": "^3.0.0",
@ -67,8 +69,7 @@
"workbox-streams": "^5.1.4"
},
"devDependencies": {
"@types/lodash": "^4.14.184",
"@types/pouchdb": "^6.4.0"
"@types/lodash": "^4.14.184"
}
},
"node_modules/@adobe/css-tools": {
@ -3991,7 +3992,6 @@
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz",
"integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==",
"dev": true,
"dependencies": {
"@types/ms": "*"
}
@ -4184,8 +4184,7 @@
"node_modules/@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==",
"dev": true
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
},
"node_modules/@types/node": {
"version": "12.20.55",
@ -4206,7 +4205,6 @@
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@types/pouchdb/-/pouchdb-6.4.0.tgz",
"integrity": "sha512-eGCpX+NXhd5VLJuJMzwe3L79fa9+IDTrAG3CPaf4s/31PD56hOrhDJTSmRELSXuiqXr6+OHzzP0PldSaWsFt7w==",
"dev": true,
"dependencies": {
"@types/pouchdb-adapter-cordova-sqlite": "*",
"@types/pouchdb-adapter-fruitdown": "*",
@ -4229,7 +4227,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-cordova-sqlite/-/pouchdb-adapter-cordova-sqlite-1.0.1.tgz",
"integrity": "sha512-nqlXpW1ho3KBg1mUQvZgH2755y3z/rw4UA7ZJCPMRTHofxGMY8izRVw5rHBL4/7P615or0J2udpRYxgkT3D02g==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4238,7 +4235,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-fruitdown/-/pouchdb-adapter-fruitdown-6.1.3.tgz",
"integrity": "sha512-Wz1Z1JLOW1hgmFQjqnSkmyyfH7by/iWb4abKn684WMvQfmxx6BxKJpJ4+eulkVPQzzgMMSgU1MpnQOm9FgRkbw==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4247,7 +4243,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-http/-/pouchdb-adapter-http-6.1.3.tgz",
"integrity": "sha512-9Z4TLbF/KJWy/D2sWRPBA+RNU0odQimfdvlDX+EY7rGcd3aVoH8qjD/X0Xcd/0dfBH5pKrNIMFFQgW/TylRCmA==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4256,7 +4251,6 @@
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-idb/-/pouchdb-adapter-idb-6.1.4.tgz",
"integrity": "sha512-KIAXbkF4uYUz0ZwfNEFLtEkK44mEWopAsD76UhucH92XnJloBysav+TjI4FFfYQyTjoW3S1s6V+Z14CUJZ0F6w==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4265,7 +4259,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-leveldb/-/pouchdb-adapter-leveldb-6.1.3.tgz",
"integrity": "sha512-ex8NFqQGFwEpFi7AaZ5YofmuemfZNsL3nTFZBUCAKYMBkazQij1pe2ILLStSvJr0XS0qxgXjCEW19T5Wqiiskg==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4274,7 +4267,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-localstorage/-/pouchdb-adapter-localstorage-6.1.3.tgz",
"integrity": "sha512-oor040tye1KKiGLWYtIy7rRT7C2yoyX3Tf6elEJRpjOA7Ja/H8lKc4LaSh9ATbptIcES6MRqZDxtp7ly9hsW3Q==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4283,7 +4275,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-memory/-/pouchdb-adapter-memory-6.1.3.tgz",
"integrity": "sha512-gVbsIMzDzgZYThFVT4eVNsmuZwVm/4jDxP1sjlgc3qtDIxbtBhGgyNfcskwwz9Zu5Lv1avkDsIWvcxQhnvRlHg==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4292,7 +4283,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-node-websql/-/pouchdb-adapter-node-websql-6.1.3.tgz",
"integrity": "sha512-F/P+os6Jsa7CgHtH64+Z0HfwIcj0hIRB5z8gNhF7L7dxPWoAfkopK5H2gydrP3sQrlGyN4WInF+UJW/Zu1+FKg==",
"dev": true,
"dependencies": {
"@types/pouchdb-adapter-websql": "*",
"@types/pouchdb-core": "*"
@ -4302,7 +4292,6 @@
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-websql/-/pouchdb-adapter-websql-6.1.4.tgz",
"integrity": "sha512-zMJQCtXC40hBsIDRn0GhmpeGMK0f9l/OGWfLguvczROzxxcOD7REI+e6SEmX7gJKw5JuMvlfuHzkQwjmvSJbtg==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4311,7 +4300,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-browser/-/pouchdb-browser-6.1.3.tgz",
"integrity": "sha512-EdYowrWxW9SWBMX/rux2eq7dbHi5Zeyzz+FF/IAsgQKnUxgeCO5VO2j4zTzos0SDyJvAQU+EYRc11r7xGn5tvA==",
"dev": true,
"dependencies": {
"@types/pouchdb-adapter-http": "*",
"@types/pouchdb-adapter-idb": "*",
@ -4325,7 +4313,6 @@
"version": "7.0.10",
"resolved": "https://registry.npmjs.org/@types/pouchdb-core/-/pouchdb-core-7.0.10.tgz",
"integrity": "sha512-mKhjLlWWXyV3PTTjDhzDV1kc2dolO7VYFa75IoKM/hr8Er9eo8RIbS7mJLfC8r/C3p6ihZu9yZs1PWC1LQ0SOA==",
"dev": true,
"dependencies": {
"@types/debug": "*",
"@types/pouchdb-find": "*"
@ -4335,7 +4322,6 @@
"version": "6.3.7",
"resolved": "https://registry.npmjs.org/@types/pouchdb-find/-/pouchdb-find-6.3.7.tgz",
"integrity": "sha512-b2dr9xoZRK5Mwl8UiRA9l5j9mmCxNfqXuu63H1KZHwJLILjoIIz7BntCvM0hnlnl7Q8P8wORq0IskuaMq5Nnnw==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4344,7 +4330,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-http/-/pouchdb-http-6.1.3.tgz",
"integrity": "sha512-0e9E5SqNOyPl/3FnEIbENssB4FlJsNYuOy131nxrZk36S+y1R/6qO7ZVRypWpGTqBWSuVd7gCsq2UDwO/285+w==",
"dev": true,
"dependencies": {
"@types/pouchdb-adapter-http": "*",
"@types/pouchdb-core": "*"
@ -4354,7 +4339,6 @@
"version": "6.1.7",
"resolved": "https://registry.npmjs.org/@types/pouchdb-mapreduce/-/pouchdb-mapreduce-6.1.7.tgz",
"integrity": "sha512-WzBwm7tmO9QhfRzVaWT4v6JQSS/fG2OoUDrWrhX87rPe2Pn6laPvdK5li6myNRxCoI/l5e8Jd+oYBAFnaiFucA==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*"
}
@ -4363,7 +4347,6 @@
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-node/-/pouchdb-node-6.1.4.tgz",
"integrity": "sha512-wnTCH8X1JOPpNOfVhz8HW0AvmdHh6pt40MuRj0jQnK7QEHsHS79WujsKTKSOF8QXtPwpvCNSsI7ut7H7tfxxJQ==",
"dev": true,
"dependencies": {
"@types/pouchdb-adapter-http": "*",
"@types/pouchdb-adapter-leveldb": "*",
@ -4376,7 +4359,6 @@
"version": "6.4.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-replication/-/pouchdb-replication-6.4.4.tgz",
"integrity": "sha512-BsE5LKpjJK4iAf6Fx5kyrMw+33V+Ip7uWldUnU2BYrrvtR+MLD22dcImm7DZN1st2wPPb91i0XEnQzvP0w1C/Q==",
"dev": true,
"dependencies": {
"@types/pouchdb-core": "*",
"@types/pouchdb-find": "*"
@ -15057,6 +15039,19 @@
"buffer-from": "1.1.2"
}
},
"node_modules/pouchdb-browser": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/pouchdb-browser/-/pouchdb-browser-7.3.0.tgz",
"integrity": "sha512-reuVLKEiTBlhQKQPqlr/4k0QMalV9sVITZixEgut+aAhUrSJoBdQLC5GFRvGiocJXraOb78aqvVs7iztlr3qnQ==",
"dependencies": {
"argsarray": "0.0.1",
"immediate": "3.3.0",
"inherits": "2.0.4",
"spark-md5": "3.0.2",
"uuid": "8.3.2",
"vuvuzela": "1.0.3"
}
},
"node_modules/pouchdb-collate": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/pouchdb-collate/-/pouchdb-collate-7.3.0.tgz",
@ -22284,7 +22279,6 @@
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.7.tgz",
"integrity": "sha512-9AonUzyTjXXhEOa0DnqpzZi6VHlqKMswga9EXjpXnnqxwLtdvPPtlO8evrI5D9S6asFRCQ6v+wpiUKbw+vKqyg==",
"dev": true,
"requires": {
"@types/ms": "*"
}
@ -22473,8 +22467,7 @@
"@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==",
"dev": true
"integrity": "sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA=="
},
"@types/node": {
"version": "12.20.55",
@ -22495,7 +22488,6 @@
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/@types/pouchdb/-/pouchdb-6.4.0.tgz",
"integrity": "sha512-eGCpX+NXhd5VLJuJMzwe3L79fa9+IDTrAG3CPaf4s/31PD56hOrhDJTSmRELSXuiqXr6+OHzzP0PldSaWsFt7w==",
"dev": true,
"requires": {
"@types/pouchdb-adapter-cordova-sqlite": "*",
"@types/pouchdb-adapter-fruitdown": "*",
@ -22518,7 +22510,6 @@
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-cordova-sqlite/-/pouchdb-adapter-cordova-sqlite-1.0.1.tgz",
"integrity": "sha512-nqlXpW1ho3KBg1mUQvZgH2755y3z/rw4UA7ZJCPMRTHofxGMY8izRVw5rHBL4/7P615or0J2udpRYxgkT3D02g==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22527,7 +22518,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-fruitdown/-/pouchdb-adapter-fruitdown-6.1.3.tgz",
"integrity": "sha512-Wz1Z1JLOW1hgmFQjqnSkmyyfH7by/iWb4abKn684WMvQfmxx6BxKJpJ4+eulkVPQzzgMMSgU1MpnQOm9FgRkbw==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22536,7 +22526,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-http/-/pouchdb-adapter-http-6.1.3.tgz",
"integrity": "sha512-9Z4TLbF/KJWy/D2sWRPBA+RNU0odQimfdvlDX+EY7rGcd3aVoH8qjD/X0Xcd/0dfBH5pKrNIMFFQgW/TylRCmA==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22545,7 +22534,6 @@
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-idb/-/pouchdb-adapter-idb-6.1.4.tgz",
"integrity": "sha512-KIAXbkF4uYUz0ZwfNEFLtEkK44mEWopAsD76UhucH92XnJloBysav+TjI4FFfYQyTjoW3S1s6V+Z14CUJZ0F6w==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22554,7 +22542,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-leveldb/-/pouchdb-adapter-leveldb-6.1.3.tgz",
"integrity": "sha512-ex8NFqQGFwEpFi7AaZ5YofmuemfZNsL3nTFZBUCAKYMBkazQij1pe2ILLStSvJr0XS0qxgXjCEW19T5Wqiiskg==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22563,7 +22550,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-localstorage/-/pouchdb-adapter-localstorage-6.1.3.tgz",
"integrity": "sha512-oor040tye1KKiGLWYtIy7rRT7C2yoyX3Tf6elEJRpjOA7Ja/H8lKc4LaSh9ATbptIcES6MRqZDxtp7ly9hsW3Q==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22572,7 +22558,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-memory/-/pouchdb-adapter-memory-6.1.3.tgz",
"integrity": "sha512-gVbsIMzDzgZYThFVT4eVNsmuZwVm/4jDxP1sjlgc3qtDIxbtBhGgyNfcskwwz9Zu5Lv1avkDsIWvcxQhnvRlHg==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22581,7 +22566,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-node-websql/-/pouchdb-adapter-node-websql-6.1.3.tgz",
"integrity": "sha512-F/P+os6Jsa7CgHtH64+Z0HfwIcj0hIRB5z8gNhF7L7dxPWoAfkopK5H2gydrP3sQrlGyN4WInF+UJW/Zu1+FKg==",
"dev": true,
"requires": {
"@types/pouchdb-adapter-websql": "*",
"@types/pouchdb-core": "*"
@ -22591,7 +22575,6 @@
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-adapter-websql/-/pouchdb-adapter-websql-6.1.4.tgz",
"integrity": "sha512-zMJQCtXC40hBsIDRn0GhmpeGMK0f9l/OGWfLguvczROzxxcOD7REI+e6SEmX7gJKw5JuMvlfuHzkQwjmvSJbtg==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22600,7 +22583,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-browser/-/pouchdb-browser-6.1.3.tgz",
"integrity": "sha512-EdYowrWxW9SWBMX/rux2eq7dbHi5Zeyzz+FF/IAsgQKnUxgeCO5VO2j4zTzos0SDyJvAQU+EYRc11r7xGn5tvA==",
"dev": true,
"requires": {
"@types/pouchdb-adapter-http": "*",
"@types/pouchdb-adapter-idb": "*",
@ -22614,7 +22596,6 @@
"version": "7.0.10",
"resolved": "https://registry.npmjs.org/@types/pouchdb-core/-/pouchdb-core-7.0.10.tgz",
"integrity": "sha512-mKhjLlWWXyV3PTTjDhzDV1kc2dolO7VYFa75IoKM/hr8Er9eo8RIbS7mJLfC8r/C3p6ihZu9yZs1PWC1LQ0SOA==",
"dev": true,
"requires": {
"@types/debug": "*",
"@types/pouchdb-find": "*"
@ -22624,7 +22605,6 @@
"version": "6.3.7",
"resolved": "https://registry.npmjs.org/@types/pouchdb-find/-/pouchdb-find-6.3.7.tgz",
"integrity": "sha512-b2dr9xoZRK5Mwl8UiRA9l5j9mmCxNfqXuu63H1KZHwJLILjoIIz7BntCvM0hnlnl7Q8P8wORq0IskuaMq5Nnnw==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22633,7 +22613,6 @@
"version": "6.1.3",
"resolved": "https://registry.npmjs.org/@types/pouchdb-http/-/pouchdb-http-6.1.3.tgz",
"integrity": "sha512-0e9E5SqNOyPl/3FnEIbENssB4FlJsNYuOy131nxrZk36S+y1R/6qO7ZVRypWpGTqBWSuVd7gCsq2UDwO/285+w==",
"dev": true,
"requires": {
"@types/pouchdb-adapter-http": "*",
"@types/pouchdb-core": "*"
@ -22643,7 +22622,6 @@
"version": "6.1.7",
"resolved": "https://registry.npmjs.org/@types/pouchdb-mapreduce/-/pouchdb-mapreduce-6.1.7.tgz",
"integrity": "sha512-WzBwm7tmO9QhfRzVaWT4v6JQSS/fG2OoUDrWrhX87rPe2Pn6laPvdK5li6myNRxCoI/l5e8Jd+oYBAFnaiFucA==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*"
}
@ -22652,7 +22630,6 @@
"version": "6.1.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-node/-/pouchdb-node-6.1.4.tgz",
"integrity": "sha512-wnTCH8X1JOPpNOfVhz8HW0AvmdHh6pt40MuRj0jQnK7QEHsHS79WujsKTKSOF8QXtPwpvCNSsI7ut7H7tfxxJQ==",
"dev": true,
"requires": {
"@types/pouchdb-adapter-http": "*",
"@types/pouchdb-adapter-leveldb": "*",
@ -22665,7 +22642,6 @@
"version": "6.4.4",
"resolved": "https://registry.npmjs.org/@types/pouchdb-replication/-/pouchdb-replication-6.4.4.tgz",
"integrity": "sha512-BsE5LKpjJK4iAf6Fx5kyrMw+33V+Ip7uWldUnU2BYrrvtR+MLD22dcImm7DZN1st2wPPb91i0XEnQzvP0w1C/Q==",
"dev": true,
"requires": {
"@types/pouchdb-core": "*",
"@types/pouchdb-find": "*"
@ -30428,6 +30404,19 @@
"buffer-from": "1.1.2"
}
},
"pouchdb-browser": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/pouchdb-browser/-/pouchdb-browser-7.3.0.tgz",
"integrity": "sha512-reuVLKEiTBlhQKQPqlr/4k0QMalV9sVITZixEgut+aAhUrSJoBdQLC5GFRvGiocJXraOb78aqvVs7iztlr3qnQ==",
"requires": {
"argsarray": "0.0.1",
"immediate": "3.3.0",
"inherits": "2.0.4",
"spark-md5": "3.0.2",
"uuid": "8.3.2",
"vuvuzela": "1.0.3"
}
},
"pouchdb-collate": {
"version": "7.3.0",
"resolved": "https://registry.npmjs.org/pouchdb-collate/-/pouchdb-collate-7.3.0.tgz",

View File

@ -23,6 +23,7 @@
"@trapezedev/configure": "^5.0.3",
"@types/jest": "^26.0.20",
"@types/node": "^12.19.15",
"@types/pouchdb": "^6.4.0",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"@types/react-router": "^5.1.11",
@ -35,6 +36,7 @@
"isomorphic-xml2js": "^0.1.3",
"lodash": "^4.17.21",
"pouchdb": "^7.3.0",
"pouchdb-browser": "^7.3.0",
"pouchdb-find": "^7.3.0",
"react": "^18.2.0",
"react-app-polyfill": "^3.0.0",
@ -86,8 +88,7 @@
]
},
"devDependencies": {
"@types/lodash": "^4.14.184",
"@types/pouchdb": "^6.4.0"
"@types/lodash": "^4.14.184"
},
"description": "An Ionic project"
}

View File

@ -3,7 +3,7 @@ import { IonApp, setupIonicReact } from '@ionic/react';
import store from './store/index';
import { Provider } from 'react-redux';
import { Suspense } from 'react';
import { PouchDB, Find } from 'react-pouchdb';
import { PouchDB } from 'react-pouchdb';
/* Core CSS required for Ionic components to work properly */
import '@ionic/react/css/core.css';

50
src/db/gpx.test.ts Normal file
View File

@ -0,0 +1,50 @@
import { initDb } from '.';
import PouchDB from 'pouchdb';
import { appendTrkpt } from './gpx';
import PouchDBFind from 'pouchdb-find';
import { mkdtempSync, rmdirSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
PouchDB.plugin(PouchDBFind);
//PouchDB.plugin(require('pouchdb-find'));
// export class PouchService {
// constructor() {
// PouchDB.plugin(PouchDBFind);
// }
// }
// jest.useFakeTimers();
const tmpDir = mkdtempSync(join(tmpdir(), 'dyomedea-testDB'));
var db: PouchDB.Database;
beforeEach(async () => {
db = new PouchDB(tmpDir);
await initDb(db, () => {});
});
afterEach(async () => {
// await db.close();
await db.destroy();
});
describe('Checking that trkpts are beeing inserted', () => {
test('and that we have two documents after the first call', async () => {
await appendTrkpt(db, {});
const results = await db.find({ selector: {} });
const docs = results.docs;
// console.log(`docs: ${JSON.stringify(docs)}`);
expect(docs.length).toBe(2);
});
test('and that we have three documents after the second call', async () => {
await appendTrkpt(db, {});
await appendTrkpt(db, {});
const results = await db.find({ selector: {} });
const docs = results.docs;
console.log(`docs: ${JSON.stringify(docs)}`);
expect(docs.length).toBe(3);
});
});

View File

@ -3,6 +3,7 @@ import {
string_to_bytes,
bytes_to_base64,
} from '@openpgp/asmcrypto.js';
import { documentSharp } from 'ionicons/icons';
export const pushGpx = async (db: any, payload: any) => {
const gpxString = JSON.stringify(payload.gpx);
@ -41,7 +42,7 @@ export const pushGpx = async (db: any, payload: any) => {
prune(gpx);
const doc = { ...payload, _id, type: 'gpx', gpx };
const doc = { ...payload, _id, type: 'gpx', subtype: 'other', gpx };
console.log(JSON.stringify(doc));
await db.put(doc);
@ -55,10 +56,10 @@ export const pushGpx = async (db: any, payload: any) => {
const CURRENT_GPX = '---current gpx---';
const initialTrack = {
_id: CURRENT_GPX,
type: 'GPX',
track: {
const initialGpx = {
type: 'gpx',
subtype: 'current',
gpx: {
$: {
version: '1.1',
creator: 'dyomedea version 0.000001',
@ -92,29 +93,28 @@ const initialTrack = {
};
export const appendTrkpt = async (db: any, trkpt: any) => {
var track: any;
await db
.get(CURRENT_GPX)
.then((result: any) => {
track = result;
})
.catch((error: any) => {
if ((error.status = '404')) {
track = initialTrack;
} else {
console.log(`db.get(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
alert(`db.get(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
}
});
track.metadata.lastModified = trkpt.time;
const currentTrkseg = track.track.trk.at(-1).trkseg.at(-1);
currentTrkseg.trkpt.push(trkpt);
db.put(track)
.then((response: any) => {
console.log(`db.put(track), response: ${JSON.stringify(response)}`);
})
.catch((error: any) => {
console.log(`db.put(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
alert(`db.put(CURRENT_TRACK), ERROR: ${JSON.stringify(error)}`);
});
const currents = await db.find({
selector: {
type: 'gpx',
subtype: 'current',
},
fields: ['_id'],
});
console.log(`appendTrkpt - db.find() : ${JSON.stringify(currents)}`);
var currentId;
if (currents.docs.length > 0) {
currentId = currents.docs[0]._id;
} else {
initialGpx.metadata.lastModified = trkpt.time;
initialGpx.gpx.metadata.time = trkpt.time;
const response = await db.post(initialGpx);
currentId = response.id;
}
console.log(`currentId: ${currentId}`);
const docPoint = { type: 'trkpt', gpx: currentId, trkpt: trkpt };
await db.post(docPoint);
console.log(JSON.stringify(docPoint));
};

View File

@ -21,12 +21,12 @@ export const initDb = async (db: any, setDbReady: any) => {
}
}
// WARNING: defs must use the canonical form andbe identical to what will be returned by db.getIndexes
// WARNING: defs must use the canonical form and be identical to what will be returned by db.getIndexes
const requiredIndexes: any = [
{
name: 'type',
name: 'type-subtype',
def: {
fields: [{ type: 'asc' }],
fields: [{ type: 'asc' }, { subtype: 'asc' }],
},
},
{
@ -73,7 +73,7 @@ export const initDb = async (db: any, setDbReady: any) => {
const indexes = await db.getIndexes();
console.log(`indexes: ${JSON.stringify(indexes)}`);
const explain = await db.explain({
const explain1 = await db.explain({
selector: {
type: 'trkpt',
gpx: 'xxxx',
@ -81,5 +81,13 @@ export const initDb = async (db: any, setDbReady: any) => {
// sort: ['trkpt.time'],
// use_index: 'type-trkpt-gpx-time',
});
console.log(`explain: ${JSON.stringify(explain)}`);
console.log(`explain1: ${JSON.stringify(explain1)}`);
const explain2 = await db.explain({
selector: {
type: 'gpx',
},
// sort: ['trkpt.time'],
// use_index: 'type-trkpt-gpx-time',
});
console.log(`explain2: ${JSON.stringify(explain2)}`);
};

View File

@ -1,12 +1,11 @@
/* Ionic Variables and Theming. For more info, please see:
http://ionicframework.com/docs/theming/ */
#background-content {
background: transparent;
}
/** Ionic CSS Variables **/
:root {
/** Transparent background so that underlying tiles and whiteboard can be seen **/
--ion-background-color: transparent;