Cleanup (remove the tree/branch mechanism which isn't useful).
This commit is contained in:
parent
38224d73da
commit
21a63ec54c
|
@ -2,11 +2,8 @@ import { Grid, IconButton } from '@suid/material';
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
import { Geometry } from 'ol/geom';
|
import { Geometry } from 'ol/geom';
|
||||||
import { Component, createSignal, For, Show } from 'solid-js';
|
import { Component, createSignal, For, Show } from 'solid-js';
|
||||||
import { unwrap } from 'solid-js/store';
|
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
import CloseIcon from '@suid/icons-material/Close';
|
|
||||||
import EditIcon from '@suid/icons-material/Edit';
|
import EditIcon from '@suid/icons-material/Edit';
|
||||||
import { tree } from '../map';
|
|
||||||
import { Paper, Stack } from '@suid/material';
|
import { Paper, Stack } from '@suid/material';
|
||||||
import styled from '@suid/material/styles/styled';
|
import styled from '@suid/material/styles/styled';
|
||||||
import Dialog from '../dialog';
|
import Dialog from '../dialog';
|
||||||
|
@ -29,7 +26,6 @@ export const clickHandler = (event: any) => {
|
||||||
caller: '<Infos/> / clickHandler',
|
caller: '<Infos/> / clickHandler',
|
||||||
event,
|
event,
|
||||||
features,
|
features,
|
||||||
tree: unwrap(tree),
|
|
||||||
});
|
});
|
||||||
selectedFeatures.map((feature) => feature.set('isSelected', false));
|
selectedFeatures.map((feature) => feature.set('isSelected', false));
|
||||||
selectedFeatures = features;
|
selectedFeatures = features;
|
||||||
|
@ -42,8 +38,6 @@ export const clickHandler = (event: any) => {
|
||||||
feature,
|
feature,
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
const branch = tree[id];
|
|
||||||
if (branch?.updateHandler) branch.updateHandler(feature);
|
|
||||||
});
|
});
|
||||||
if (features.length > 0) {
|
if (features.length > 0) {
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
|
|
|
@ -46,23 +46,6 @@ const [getState, setState] = createSignal({
|
||||||
|
|
||||||
export { getState };
|
export { getState };
|
||||||
|
|
||||||
interface Branch {
|
|
||||||
vectorLayer?: VectorLayer;
|
|
||||||
features?: Feature[];
|
|
||||||
hidden?: boolean;
|
|
||||||
updateHandler?: (feature: Feature) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Tree {
|
|
||||||
[key: string]: Branch;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [tree, setTree] = createStore<Tree>({});
|
|
||||||
export { tree };
|
|
||||||
export const setBranch = (key: string, branch: Branch) => {
|
|
||||||
setTree({ ...tree, [key]: branch });
|
|
||||||
};
|
|
||||||
|
|
||||||
const Map: Component = () => {
|
const Map: Component = () => {
|
||||||
const [getMap, setMap] = createSignal<OlMap | null>(null);
|
const [getMap, setMap] = createSignal<OlMap | null>(null);
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
@ -208,7 +191,6 @@ const Map: Component = () => {
|
||||||
olMap.on(['singleclick'], clickHandler);
|
olMap.on(['singleclick'], clickHandler);
|
||||||
|
|
||||||
setMap(olMap);
|
setMap(olMap);
|
||||||
setBranch('/', { vectorLayer: vectorLayer });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
export { default, getState, tree, setBranch } from './Map';
|
export { default, getState } from './Map';
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import { Component, createEffect, createResource } from 'solid-js';
|
import { Component, createEffect, createResource } from 'solid-js';
|
||||||
|
|
||||||
|
|
||||||
import dispatch from '../../workers/dispatcher-main';
|
import dispatch from '../../workers/dispatcher-main';
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
import GeoJSON from 'ol/format/GeoJSON';
|
import GeoJSON from 'ol/format/GeoJSON';
|
||||||
import { setBranch, tree } from '../map';
|
|
||||||
import { Feature } from 'ol';
|
import { Feature } from 'ol';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
@ -27,7 +25,7 @@ export const Trkseg: Component<Props> = ({ vectorSource, trksegId }) => {
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Trkseg', vectorSource, trksegId, trkseg: trkseg() });
|
console.log({ caller: 'Trkseg', vectorSource, trksegId, trkseg: trkseg() });
|
||||||
|
|
||||||
if (trkseg() && !tree[trksegId]) {
|
if (trkseg()) {
|
||||||
let geo: any = {
|
let geo: any = {
|
||||||
type: 'FeatureCollection',
|
type: 'FeatureCollection',
|
||||||
features: [
|
features: [
|
||||||
|
@ -67,17 +65,9 @@ export const Trkseg: Component<Props> = ({ vectorSource, trksegId }) => {
|
||||||
const features = new GeoJSON().readFeatures(geo);
|
const features = new GeoJSON().readFeatures(geo);
|
||||||
console.log({ caller: 'Trkseg', features });
|
console.log({ caller: 'Trkseg', features });
|
||||||
vectorSource.addFeatures(features);
|
vectorSource.addFeatures(features);
|
||||||
setBranch(trksegId, { features, updateHandler });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateHandler = (feature: Feature) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'Trkseg / updateHandler / clicked',
|
|
||||||
feature,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return <></>;
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,12 @@
|
||||||
import {
|
import { Component, createEffect, createSignal, onCleanup } from 'solid-js';
|
||||||
Component,
|
|
||||||
createEffect,
|
|
||||||
createResource,
|
|
||||||
createSignal,
|
|
||||||
onCleanup,
|
|
||||||
} from 'solid-js';
|
|
||||||
|
|
||||||
import dispatch, { cancelDispatch } from '../../workers/dispatcher-main';
|
import dispatch, { cancelDispatch } from '../../workers/dispatcher-main';
|
||||||
import VectorSource from 'ol/source/Vector';
|
import VectorSource from 'ol/source/Vector';
|
||||||
import GeoJSON from 'ol/format/GeoJSON';
|
import GeoJSON from 'ol/format/GeoJSON';
|
||||||
import { setBranch, tree } from '../map';
|
|
||||||
import { Feature } from 'ol';
|
|
||||||
import { useI18n } from '@solid-primitives/i18n';
|
import { useI18n } from '@solid-primitives/i18n';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import Dialog from '../dialog';
|
import Dialog from '../dialog';
|
||||||
import { Box, Button, Grid, Stack, TextField } from '@suid/material';
|
import { Box, Button, Stack, TextField } from '@suid/material';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
wptId: string;
|
wptId: string;
|
||||||
|
@ -85,7 +77,7 @@ export const Wpt: Component<Props> = ({ vectorSource, wptId: wptId }) => {
|
||||||
createEffect(() => {
|
createEffect(() => {
|
||||||
console.log({ caller: 'Wpt', vectorSource, wptId, wpt: cloneDeep(wpt()) });
|
console.log({ caller: 'Wpt', vectorSource, wptId, wpt: cloneDeep(wpt()) });
|
||||||
|
|
||||||
if (wpt() /* && !tree[wptId] */) {
|
if (wpt()) {
|
||||||
const existingFeature = vectorSource.getFeatureById(wptId);
|
const existingFeature = vectorSource.getFeatureById(wptId);
|
||||||
if (existingFeature) {
|
if (existingFeature) {
|
||||||
vectorSource.removeFeature(existingFeature);
|
vectorSource.removeFeature(existingFeature);
|
||||||
|
@ -108,17 +100,9 @@ export const Wpt: Component<Props> = ({ vectorSource, wptId: wptId }) => {
|
||||||
const features = new GeoJSON().readFeatures(geo);
|
const features = new GeoJSON().readFeatures(geo);
|
||||||
console.log({ caller: 'Wpt', features });
|
console.log({ caller: 'Wpt', features });
|
||||||
vectorSource.addFeatures(features);
|
vectorSource.addFeatures(features);
|
||||||
// setBranch(wptId, { features, updateHandler });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateHandler = (feature: Feature) => {
|
|
||||||
console.log({
|
|
||||||
caller: 'Wpt / updateHandler / clicked',
|
|
||||||
feature,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const closeHandler = () => {
|
const closeHandler = () => {
|
||||||
setMode(Mode.CLOSED);
|
setMode(Mode.CLOSED);
|
||||||
};
|
};
|
||||||
|
@ -129,10 +113,6 @@ export const Wpt: Component<Props> = ({ vectorSource, wptId: wptId }) => {
|
||||||
wptId,
|
wptId,
|
||||||
editedWpt: editedWpt(),
|
editedWpt: editedWpt(),
|
||||||
});
|
});
|
||||||
// const newWpt = wpt();
|
|
||||||
// if (newWpt) {
|
|
||||||
// newWpt.name = name.value;
|
|
||||||
// }
|
|
||||||
dispatch({ action: 'putWpt', params: { id: wptId, wpt: editedWpt() } });
|
dispatch({ action: 'putWpt', params: { id: wptId, wpt: editedWpt() } });
|
||||||
setMode(Mode.CLOSED);
|
setMode(Mode.CLOSED);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue