From 68b4fc452c94542dde14efe089ffa285dc388cd8 Mon Sep 17 00:00:00 2001 From: "S. Andrew Sheppard" Date: Tue, 19 Mar 2024 20:51:15 +0000 Subject: [PATCH] union vector tile geoms; load geojson for edit --- LICENSES.md | 75 +++++++++++++++++++ package-lock.json | 33 ++++++++ packages/map-gl-web/package.json | 1 + .../map-gl-web/src/components/MapIdentify.js | 16 ++++ packages/map/src/map.js | 19 +++++ rollup.config.js | 1 + wq/app/static/app/.sha256 | 4 +- 7 files changed, 147 insertions(+), 2 deletions(-) diff --git a/LICENSES.md b/LICENSES.md index c9ac13a8..e8e1fb1c 100644 --- a/LICENSES.md +++ b/LICENSES.md @@ -1457,6 +1457,23 @@ In addition, the following third party dependencies are compiled into [**wq.js** +
polygon-clipping 0.15.7 + +> The MIT License (MIT) +> +> Copyright (c) 2018 Mike Fogel - covers everything not specially attributed to others below. +> +> Copyright (c) 2016 Alexander Milevski - covers all portions originally part of github:w8r/martinez, from which this project was forked on Febuary 2, 2018. +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +> + +
+
@popperjs/core 2.11.8 > The MIT License (MIT) @@ -2006,6 +2023,36 @@ In addition, the following third party dependencies are compiled into [**wq.js**     resolve-pathname 2.2.0 +
robust-predicates 3.0.2 (Unlicense) + +> This is free and unencumbered software released into the public domain. +> +> Anyone is free to copy, modify, publish, use, compile, sell, or +> distribute this software, either in source code form or as a compiled +> binary, for any purpose, commercial or non-commercial, and by any +> means. +> +> In jurisdictions that recognize copyright laws, the author or authors +> of this software dedicate any and all copyright interest in the +> software to the public domain. We make this dedication for the benefit +> of the public at large and to the detriment of our heirs and +> successors. We intend this dedication to be an overt act of +> relinquishment in perpetuity of all present and future rights to this +> software under copyright law. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +> IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +> OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +> ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +> OTHER DEALINGS IN THE SOFTWARE. +> +> For more information, please refer to +> + +
+
rudy-history 1.0.0 > The MIT License (MIT) @@ -2087,6 +2134,8 @@ In addition, the following third party dependencies are compiled into [**wq.js**
+    splaytree 3.1.2 +
split-on-first 3.0.0 > MIT License @@ -2276,6 +2325,32 @@ In addition, the following third party dependencies are compiled into [**wq.js**
+
@turf/union 6.5.0 + +> The MIT License (MIT) +> +> Copyright (c) 2017 TurfJS +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of +> this software and associated documentation files (the "Software"), to deal in +> the Software without restriction, including without limitation the rights to +> use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +> the Software, and to permit persons to whom the Software is furnished to do so, +> subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +> FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +> COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +> IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +> CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +> + +
+
type-detect 4.0.8 > Copyright (c) 2013 Jake Luer (http://alogicalparadox.com) diff --git a/package-lock.json b/package-lock.json index 4bb29fa7..e3182153 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4060,6 +4060,19 @@ "url": "https://opencollective.com/turf" } }, + "node_modules/@turf/union": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@turf/union/-/union-6.5.0.tgz", + "integrity": "sha512-igYWCwP/f0RFHIlC2c0SKDuM/ObBaqSljI3IdV/x71805QbIvY/BYGcJdyNcgEA6cylIGl/0VSlIbpJHZ9ldhw==", + "dependencies": { + "@turf/helpers": "^6.5.0", + "@turf/invariant": "^6.5.0", + "polygon-clipping": "^0.15.3" + }, + "funding": { + "url": "https://opencollective.com/turf" + } + }, "node_modules/@types/babel__core": { "version": "7.20.0", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.0.tgz", @@ -10493,6 +10506,15 @@ "node": ">=8" } }, + "node_modules/polygon-clipping": { + "version": "0.15.7", + "resolved": "https://registry.npmjs.org/polygon-clipping/-/polygon-clipping-0.15.7.tgz", + "integrity": "sha512-nhfdr83ECBg6xtqOAJab1tbksbBAOMUltN60bU+llHVOL0e5Onm1WpAXXWXVB39L8AJFssoIhEVuy/S90MmotA==", + "dependencies": { + "robust-predicates": "^3.0.2", + "splaytree": "^3.1.0" + } + }, "node_modules/potpack": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/potpack/-/potpack-2.0.0.tgz", @@ -11398,6 +11420,11 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/robust-predicates": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz", + "integrity": "sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==" + }, "node_modules/rollup": { "version": "3.25.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.25.1.tgz", @@ -11787,6 +11814,11 @@ "spdx-ranges": "^2.0.0" } }, + "node_modules/splaytree": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/splaytree/-/splaytree-3.1.2.tgz", + "integrity": "sha512-4OM2BJgC5UzrhVnnJA4BkHKGtjXNzzUfpQjCO8I05xYPsfS/VuQDwjCGGMi8rYQilHEV4j8NBqTFbls/PZEE7A==" + }, "node_modules/split-on-first": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-3.0.0.tgz", @@ -12882,6 +12914,7 @@ "dependencies": { "@mapbox/mapbox-gl-draw": "^1.4.1", "@turf/circle": "^6.5.0", + "@turf/union": "^6.5.0", "@wq/map": "^2.0.0", "@wq/material": "^2.0.0", "mapbox-gl": "npm:empty-npm-package@^1.0.0", diff --git a/packages/map-gl-web/package.json b/packages/map-gl-web/package.json index fbf3c52a..05edd5ac 100644 --- a/packages/map-gl-web/package.json +++ b/packages/map-gl-web/package.json @@ -33,6 +33,7 @@ "dependencies": { "@mapbox/mapbox-gl-draw": "^1.4.1", "@turf/circle": "^6.5.0", + "@turf/union": "^6.5.0", "@wq/map": "^2.0.0", "@wq/material": "^2.0.0", "mapbox-gl": "npm:empty-npm-package@^1.0.0", diff --git a/packages/map-gl-web/src/components/MapIdentify.js b/packages/map-gl-web/src/components/MapIdentify.js index 61c976aa..ab6617a5 100644 --- a/packages/map-gl-web/src/components/MapIdentify.js +++ b/packages/map-gl-web/src/components/MapIdentify.js @@ -1,6 +1,7 @@ import { useEffect } from "react"; import { useMapInstance } from "../hooks.js"; import { usePluginReducer } from "@wq/react"; +import union from "@turf/union"; export default function MapIdentify() { const map = useMapInstance(), @@ -30,6 +31,21 @@ export default function MapIdentify() { function updateHighlight(evt, overlay) { const features = evt.features.map((feature) => { feature.popup = overlay.popup; + if ( + feature.source && + feature.sourceLayer && + ["Polygon", "MultiPolygon"].includes(feature.geometry.type) + ) { + const sourceFeature = map + .querySourceFeatures(feature.source, { + sourceLayer: feature.sourceLayer, + filter: ["==", ["id"], feature.id], + }) + .reduce(union); + if (sourceFeature && sourceFeature.geometry) { + feature.geometry = sourceFeature.geometry; + } + } return feature; }); setHighlight({ type: "FeatureCollection", features }); diff --git a/packages/map/src/map.js b/packages/map/src/map.js index ef0e4b86..b61413cb 100644 --- a/packages/map/src/map.js +++ b/packages/map/src/map.js @@ -308,6 +308,25 @@ map.init = function (config) { }); }; +// Load deferred geometries before edit +map.context = async function (ctx, routeInfo) { + if ( + routeInfo.mode === "edit" && + ctx.id && + routeInfo.page_config.defer_geometry && + routeInfo.page_config.geometry_fields + ) { + const field = routeInfo.page_config.geometry_fields.slice(-1)[0]; + if (field && !ctx[field.name]) { + const response = await fetch( + `${this.app.service}/${routeInfo.page_config.url}/${ctx.id}.geojson` + ), + data = await response.json(); + return { [field.name]: data.geometry }; + } + } +}; + // Default base map configuration - override to customize function _defaultBasemaps() { var cdn = diff --git a/rollup.config.js b/rollup.config.js index e8190e46..46035e78 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -118,6 +118,7 @@ export default [ "0BSD", "Apache-2.0", "MIT/X11", + "Unlicense", ].includes(dependency.license); }, }, diff --git a/wq/app/static/app/.sha256 b/wq/app/static/app/.sha256 index c83583eb..762db4b4 100644 --- a/wq/app/static/app/.sha256 +++ b/wq/app/static/app/.sha256 @@ -2,5 +2,5 @@ c637d052aaddf8b0ad878819ee30facb74a3ba34cbed310a0fd1834fc02f46a2 css/mapbox-gl- 731181d400d65a8b09d842f55b70bc4dc11010b15b8549e2c65a69d233fbdd2e css/maplibre-gl.css cfb20121bd733aa6795e9f2f180c327d561c51cff783196f1eaa01ba42701bec css/wq.css a222d0281caeab67157dc947f83971d219156060bd98a529c035de4cec92a8f5 js/maplibre-gl.js -563decb118a55c391ebe55dd8ffa3b89895051be96e609be278b2d4d3da5cee0 js/wq.dev.js' -4b70e87f426ba6948d23b095418317480110e5f4b88bbe1477e036bee9ee9798 js/wq.js' +c856aaf7890b3ecf9e6921f31916044196ee15aa2e48a854a0455995b9e47882 js/wq.dev.js' +68c09e974002ea85436e7aadfd575e1ee46dff4cedbfd3b75c3f2b3ccc314f6e js/wq.js'