86 lines
2.6 KiB
JavaScript
86 lines
2.6 KiB
JavaScript
|
import { identify } from '@arcgis/core/rest/identify';
|
||
|
import IdentifyParameters from '@arcgis/core/rest/support/IdentifyParameters';
|
||
|
|
||
|
import { updateAmpelkarteEWS } from '@/redux/ampelkarteEWSSlice';
|
||
|
import { updateAmpelkarteGWWP } from '@/redux/ampelkarteGWWPSlice';
|
||
|
import { updateResourcesEWS } from '@/redux/resourcesEWSSlice';
|
||
|
import { updateResourcesGWWP } from '@/redux/resourcesGWWPSlice';
|
||
|
|
||
|
import { RESOURCES_EWS_URL, AMPEL_EWS_URL, RESOURCES_GWWP_URL, AMPEL_GWWP_URL } from '../config/config';
|
||
|
|
||
|
// query layers
|
||
|
export default function identifyAllLayers(view, mapPoint, dispatch, theme) {
|
||
|
// define query parameters
|
||
|
const params = new IdentifyParameters();
|
||
|
params.geometry = mapPoint;
|
||
|
params.tolerance = 0;
|
||
|
params.layerOption = 'all';
|
||
|
params.width = view.width;
|
||
|
params.height = view.height;
|
||
|
params.mapExtent = view.extent;
|
||
|
|
||
|
if (theme === 'EWS') {
|
||
|
identify(RESOURCES_EWS_URL, params)
|
||
|
.then((res) => {
|
||
|
const results = res.results.map((result) => {
|
||
|
return {
|
||
|
layerId: result.layerId,
|
||
|
layerName: result.layerName,
|
||
|
feature: { attributes: result.feature.attributes },
|
||
|
};
|
||
|
});
|
||
|
dispatch(updateResourcesEWS(results));
|
||
|
})
|
||
|
.catch(() => {
|
||
|
dispatch(updateResourcesEWS([]));
|
||
|
});
|
||
|
|
||
|
identify(AMPEL_EWS_URL, params)
|
||
|
.then((res) => {
|
||
|
const results = res.results.map((result) => {
|
||
|
return {
|
||
|
layerId: result.layerId,
|
||
|
layerName: result.layerName,
|
||
|
feature: { attributes: result.feature.attributes },
|
||
|
};
|
||
|
});
|
||
|
dispatch(updateAmpelkarteEWS(results));
|
||
|
})
|
||
|
.catch(() => {
|
||
|
dispatch(updateAmpelkarteEWS([]));
|
||
|
});
|
||
|
}
|
||
|
|
||
|
if (theme === 'GWWP') {
|
||
|
identify(RESOURCES_GWWP_URL, params)
|
||
|
.then((res) => {
|
||
|
const results = res.results.map((result) => {
|
||
|
return {
|
||
|
layerId: result.layerId,
|
||
|
layerName: result.layerName,
|
||
|
feature: { attributes: result.feature.attributes },
|
||
|
};
|
||
|
});
|
||
|
dispatch(updateResourcesGWWP(results));
|
||
|
})
|
||
|
.catch(() => {
|
||
|
dispatch(updateResourcesGWWP([]));
|
||
|
});
|
||
|
|
||
|
identify(AMPEL_GWWP_URL, params)
|
||
|
.then((res) => {
|
||
|
const results = res.results.map((result) => {
|
||
|
return {
|
||
|
layerId: result.layerId,
|
||
|
layerName: result.layerName,
|
||
|
feature: { attributes: result.feature.attributes },
|
||
|
};
|
||
|
});
|
||
|
dispatch(updateAmpelkarteGWWP(results));
|
||
|
})
|
||
|
.catch(() => {
|
||
|
dispatch(updateAmpelkarteGWWP([]));
|
||
|
});
|
||
|
}
|
||
|
}
|