Skip to content

Commit

Permalink
union vector tile geoms; load geojson for edit
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Mar 19, 2024
1 parent f08d7fd commit 68b4fc4
Show file tree
Hide file tree
Showing 7 changed files with 147 additions and 2 deletions.
75 changes: 75 additions & 0 deletions LICENSES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,23 @@ In addition, the following third party dependencies are compiled into [**wq.js**
</details>

<details><summary><b><a href="null">polygon-clipping</a> 0.15.7</b></summary>

> The MIT License (MIT)
>
> Copyright (c) 2018 Mike Fogel <[email protected]> - covers everything not specially attributed to others below.
>
> Copyright (c) 2016 Alexander Milevski <[email protected]> - 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.
>
</details>

<details><summary><b><a href="null">@popperjs/core</a> 2.11.8</b></summary>

> The MIT License (MIT)
Expand Down Expand Up @@ -2006,6 +2023,36 @@ In addition, the following third party dependencies are compiled into [**wq.js**

&nbsp; &nbsp; <b><a href="null">resolve-pathname</a> 2.2.0</b>

<details><summary><b><a href="null">robust-predicates</a> 3.0.2</b> <i>(Unlicense)</i></summary>

> 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 <http://unlicense.org>
>
</details>

<details><summary><b><a href="null">rudy-history</a> 1.0.0</b></summary>

> The MIT License (MIT)
Expand Down Expand Up @@ -2087,6 +2134,8 @@ In addition, the following third party dependencies are compiled into [**wq.js**
</details>

&nbsp; &nbsp; <b><a href="null">splaytree</a> 3.1.2</b>

<details><summary><b><a href="null">split-on-first</a> 3.0.0</b></summary>

> MIT License
Expand Down Expand Up @@ -2276,6 +2325,32 @@ In addition, the following third party dependencies are compiled into [**wq.js**
</details>

<details><summary><b><a href="https://github.com/Turfjs/turf">@turf/union</a> 6.5.0</b></summary>

> 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.
>
</details>

<details><summary><b><a href="null">type-detect</a> 4.0.8</b></summary>

> Copyright (c) 2013 Jake Luer <[email protected]> (http://alogicalparadox.com)
Expand Down
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/map-gl-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions packages/map-gl-web/src/components/MapIdentify.js
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down Expand Up @@ -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 });
Expand Down
19 changes: 19 additions & 0 deletions packages/map/src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default [
"0BSD",
"Apache-2.0",
"MIT/X11",
"Unlicense",
].includes(dependency.license);
},
},
Expand Down
4 changes: 2 additions & 2 deletions wq/app/static/app/.sha256
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit 68b4fc4

Please sign in to comment.