react-spatial 1.5.3 → 1.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +262 -0
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -0
- package/components/BaseLayerSwitcher/index.js +1 -0
- package/components/BaseLayerSwitcher/index.js.map +7 -0
- package/{src/components → components}/BasicMap/BasicMap.js +80 -170
- package/components/BasicMap/BasicMap.js.map +7 -0
- package/components/BasicMap/index.js +1 -0
- package/components/BasicMap/index.js.map +7 -0
- package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.js +133 -278
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
- package/components/CanvasSaveButton/index.js +1 -0
- package/components/CanvasSaveButton/index.js.map +7 -0
- package/{src/components → components}/Copyright/Copyright.js +21 -41
- package/components/Copyright/Copyright.js.map +7 -0
- package/components/Copyright/index.js +1 -0
- package/components/Copyright/index.js.map +7 -0
- package/components/FeatureExportButton/FeatureExportButton.js +80 -0
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -0
- package/components/FeatureExportButton/index.js +1 -0
- package/components/FeatureExportButton/index.js.map +7 -0
- package/{src/components → components}/FitExtent/FitExtent.js +16 -30
- package/components/FitExtent/FitExtent.js.map +7 -0
- package/components/FitExtent/index.js +1 -0
- package/components/FitExtent/index.js.map +7 -0
- package/{src/components → components}/Geolocation/Geolocation.js +60 -110
- package/components/Geolocation/Geolocation.js.map +7 -0
- package/components/Geolocation/index.js +1 -0
- package/components/Geolocation/index.js.map +7 -0
- package/{src/components → components}/LayerTree/LayerTree.js +113 -213
- package/components/LayerTree/LayerTree.js.map +7 -0
- package/components/LayerTree/index.js +1 -0
- package/components/LayerTree/index.js.map +7 -0
- package/{src/components → components}/MousePosition/MousePosition.js +37 -70
- package/components/MousePosition/MousePosition.js.map +7 -0
- package/components/MousePosition/index.js +1 -0
- package/components/MousePosition/index.js.map +7 -0
- package/{src/components → components}/NorthArrow/NorthArrow.js +18 -34
- package/components/NorthArrow/NorthArrow.js.map +7 -0
- package/components/NorthArrow/index.js +1 -0
- package/components/NorthArrow/index.js.map +7 -0
- package/{src/components → components}/Overlay/Overlay.js +59 -85
- package/components/Overlay/Overlay.js.map +7 -0
- package/components/Overlay/index.js +1 -0
- package/components/Overlay/index.js.map +7 -0
- package/{src/components → components}/Permalink/Permalink.js +64 -147
- package/components/Permalink/Permalink.js.map +7 -0
- package/components/Permalink/index.js +1 -0
- package/components/Permalink/index.js.map +7 -0
- package/{src/components → components}/Popup/Popup.js +57 -116
- package/components/Popup/Popup.js.map +7 -0
- package/components/Popup/index.js +1 -0
- package/components/Popup/index.js.map +7 -0
- package/{src/components → components}/ResizeHandler/ResizeHandler.js +15 -49
- package/components/ResizeHandler/ResizeHandler.js.map +7 -0
- package/components/ResizeHandler/index.js +1 -0
- package/components/ResizeHandler/index.js.map +7 -0
- package/components/RouteSchedule/RouteSchedule.js +268 -0
- package/components/RouteSchedule/RouteSchedule.js.map +7 -0
- package/components/RouteSchedule/index.js +1 -0
- package/components/RouteSchedule/index.js.map +7 -0
- package/{src/components → components}/ScaleLine/ScaleLine.js +8 -23
- package/components/ScaleLine/ScaleLine.js.map +7 -0
- package/components/ScaleLine/index.js +1 -0
- package/components/ScaleLine/index.js.map +7 -0
- package/{src/components → components}/StopsFinder/StopsFinder.js +74 -103
- package/components/StopsFinder/StopsFinder.js.map +7 -0
- package/components/StopsFinder/StopsFinderOption.js +44 -0
- package/components/StopsFinder/StopsFinderOption.js.map +7 -0
- package/components/StopsFinder/index.js +1 -0
- package/components/StopsFinder/index.js.map +7 -0
- package/{src/components → components}/Zoom/Zoom.js +46 -77
- package/components/Zoom/Zoom.js.map +7 -0
- package/components/Zoom/index.js +1 -0
- package/components/Zoom/index.js.map +7 -0
- package/package.json +32 -31
- package/{src/propTypes.js → propTypes.js} +30 -16
- package/propTypes.js.map +7 -0
- package/{src/setupTests.js → setupTests.js} +1 -1
- package/setupTests.js.map +7 -0
- package/utils/GlobalsForOle.js +94 -0
- package/utils/GlobalsForOle.js.map +7 -0
- package/utils/KML.js +420 -0
- package/utils/KML.js.map +7 -0
- package/{src/utils → utils}/KMLFormat.js +29 -32
- package/utils/KMLFormat.js.map +7 -0
- package/{src/utils → utils}/Styles.js +14 -20
- package/utils/Styles.js.map +7 -0
- package/{src/utils → utils}/getPolygonPattern.js +6 -34
- package/utils/getPolygonPattern.js.map +7 -0
- package/{src/utils → utils}/timeUtils.js +5 -22
- package/utils/timeUtils.js.map +7 -0
- package/.github/workflows/conventional-pr-title.yml +0 -21
- package/.github/workflows/main.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/post-checkout +0 -4
- package/.husky/post-merge +0 -4
- package/.husky/post-rebase +0 -4
- package/.husky/pre-commit +0 -4
- package/.nvmrc +0 -1
- package/.whitesource +0 -8
- package/CHANGELOG.md +0 -65
- package/DEVELOP.md +0 -113
- package/__mocks__/mapbox-gl.js +0 -11
- package/__mocks__/resize-observer-polyfill.js +0 -9
- package/babel.config.js +0 -3
- package/commitlint.config.js +0 -1
- package/data/topic1.js +0 -119
- package/data/topic2.js +0 -28
- package/doc/README.md +0 -21
- package/doc/doc-config.json +0 -4
- package/pull_request_template.md +0 -16
- package/renovate.json +0 -4
- package/scripts/read-pkg-json.js +0 -17
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.js +0 -322
- package/src/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -69
- package/src/components/BaseLayerSwitcher/README.md +0 -61
- package/src/components/BaseLayerSwitcher/__snapshots__/BaseLayerSwitcher.test.js.snap +0 -88
- package/src/components/BaseLayerSwitcher/index.js +0 -1
- package/src/components/BasicMap/BasicMap.test.js +0 -281
- package/src/components/BasicMap/README.md +0 -18
- package/src/components/BasicMap/index.js +0 -1
- package/src/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -148
- package/src/components/CanvasSaveButton/README.md +0 -76
- package/src/components/CanvasSaveButton/__snapshots__/CanvasSaveButton.test.js.snap +0 -76
- package/src/components/CanvasSaveButton/index.js +0 -1
- package/src/components/Copyright/Copyright.test.js +0 -134
- package/src/components/Copyright/README.md +0 -36
- package/src/components/Copyright/index.js +0 -1
- package/src/components/FeatureExportButton/FeatureExportButton.js +0 -118
- package/src/components/FeatureExportButton/FeatureExportButton.test.js +0 -417
- package/src/components/FeatureExportButton/README.md +0 -76
- package/src/components/FeatureExportButton/__snapshots__/FeatureExportButton.test.js.snap +0 -67
- package/src/components/FeatureExportButton/index.js +0 -1
- package/src/components/FitExtent/FitExtent.test.js +0 -48
- package/src/components/FitExtent/README.md +0 -34
- package/src/components/FitExtent/__snapshots__/FitExtent.test.js.snap +0 -13
- package/src/components/FitExtent/index.js +0 -1
- package/src/components/Geolocation/Geolocation.test.js +0 -267
- package/src/components/Geolocation/README.md +0 -25
- package/src/components/Geolocation/__snapshots__/Geolocation.test.js.snap +0 -92
- package/src/components/Geolocation/index.js +0 -1
- package/src/components/LayerTree/LayerTree.test.js +0 -337
- package/src/components/LayerTree/README.md +0 -92
- package/src/components/LayerTree/__snapshots__/LayerTree.test.js.snap +0 -1746
- package/src/components/LayerTree/index.js +0 -1
- package/src/components/MousePosition/MousePosition.test.js +0 -132
- package/src/components/MousePosition/README.md +0 -50
- package/src/components/MousePosition/__snapshots__/MousePosition.test.js.snap +0 -76
- package/src/components/MousePosition/index.js +0 -1
- package/src/components/NorthArrow/NorthArrow.test.js +0 -104
- package/src/components/NorthArrow/README.md +0 -59
- package/src/components/NorthArrow/__snapshots__/NorthArrow.test.js.snap +0 -117
- package/src/components/NorthArrow/index.js +0 -1
- package/src/components/Overlay/Overlay.test.js +0 -149
- package/src/components/Overlay/README.md +0 -59
- package/src/components/Overlay/__snapshots__/Overlay.test.js.snap +0 -9
- package/src/components/Overlay/index.js +0 -1
- package/src/components/Permalink/Permalink.test.js +0 -285
- package/src/components/Permalink/README.md +0 -105
- package/src/components/Permalink/index.js +0 -1
- package/src/components/Popup/Popup.test.js +0 -307
- package/src/components/Popup/README.md +0 -93
- package/src/components/Popup/__snapshots__/Popup.test.js.snap +0 -180
- package/src/components/Popup/index.js +0 -1
- package/src/components/README.md +0 -41
- package/src/components/ResizeHandler/ResizeHandler.test.js +0 -344
- package/src/components/ResizeHandler/index.js +0 -1
- package/src/components/RouteSchedule/README.md +0 -118
- package/src/components/RouteSchedule/RouteSchedule.js +0 -370
- package/src/components/RouteSchedule/RouteSchedule.test.js +0 -113
- package/src/components/RouteSchedule/__snapshots__/RouteSchedule.test.js.snap +0 -248
- package/src/components/RouteSchedule/index.js +0 -1
- package/src/components/ScaleLine/README.md +0 -29
- package/src/components/ScaleLine/ScaleLine.test.js +0 -30
- package/src/components/ScaleLine/__snapshots__/ScaleLine.test.js.snap +0 -7
- package/src/components/ScaleLine/index.js +0 -1
- package/src/components/StopsFinder/README.md +0 -50
- package/src/components/StopsFinder/StopsFinder.test.js +0 -17
- package/src/components/StopsFinder/StopsFinderOption.js +0 -61
- package/src/components/StopsFinder/__snapshots__/StopsFinder.test.js.snap +0 -133
- package/src/components/StopsFinder/index.js +0 -1
- package/src/components/Zoom/README.md +0 -25
- package/src/components/Zoom/Zoom.test.js +0 -141
- package/src/components/Zoom/__snapshots__/Zoom.test.js.snap +0 -201
- package/src/components/Zoom/index.js +0 -1
- package/src/styleguidist/ComponentsList.js +0 -52
- package/src/styleguidist/StyleGuide.js +0 -277
- package/src/styleguidist/styleguidist.css +0 -38
- package/src/utils/GlobalsForOle.js +0 -99
- package/src/utils/KML.js +0 -594
- package/src/utils/KML.test.js +0 -337
- package/src/utils/KMLFormat.test.js +0 -50
- package/src/utils/__snapshots__/KML.test.js.snap.KML-readFeatures()-and-writeFeatures()-should-read-and-write-lineDash-and-fillPattern-style-for-polygon.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-2-(cross)-color-and-(light-blue)-opacity.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-3-(diagonal-line-from-bottom-left-tot-top-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
- package/src/utils/__snapshots__/getPolygonPattern.test.js.snap.getPolygonPattern()-render-pattern-4-(diagonal-line-from-top-left-to-bottom-right)-with-color-(light-blue)-and-opacity.canvas-image.png +0 -0
- package/src/utils/getPolygonPattern.test.js +0 -61
- package/src/utils/timeUtils.test.js +0 -30
- package/styleguide.config.js +0 -251
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.md.scss +0 -0
- /package/{src/components → components}/BaseLayerSwitcher/BaseLayerSwitcher.scss +0 -0
- /package/{src/components → components}/BasicMap/BasicMap.md.scss +0 -0
- /package/{src/components → components}/CanvasSaveButton/CanvasSaveButton.md.scss +0 -0
- /package/{src/components → components}/Copyright/Copyright.md.scss +0 -0
- /package/{src/components → components}/FeatureExportButton/FeatureExportButton.md.scss +0 -0
- /package/{src/components → components}/FitExtent/FitExtent.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.md.scss +0 -0
- /package/{src/components → components}/Geolocation/Geolocation.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.md.scss +0 -0
- /package/{src/components → components}/LayerTree/LayerTree.scss +0 -0
- /package/{src/components → components}/MousePosition/MousePosition.md.scss +0 -0
- /package/{src/components → components}/NorthArrow/NorthArrow.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.md.scss +0 -0
- /package/{src/components → components}/Overlay/Overlay.scss +0 -0
- /package/{src/components → components}/Permalink/Permalink.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.md.scss +0 -0
- /package/{src/components → components}/Popup/Popup.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.md.scss +0 -0
- /package/{src/components → components}/RouteSchedule/RouteSchedule.scss +0 -0
- /package/{src/components → components}/ScaleLine/ScaleLine.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.md.scss +0 -0
- /package/{src/components → components}/Zoom/Zoom.scss +0 -0
- /package/{src/images → images}/RouteSchedule/firstStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/lastStation.png +0 -0
- /package/{src/images → images}/RouteSchedule/line.png +0 -0
- /package/{src/images → images}/RouteSchedule/station.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.basebright.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.osm.png +0 -0
- /package/{src/images → images}/baselayer/baselayer.travic.png +0 -0
- /package/{src/images → images}/baselayer/open.topo.map.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.hot.png +0 -0
- /package/{src/images → images}/baselayer/osm.baselayer.png +0 -0
- /package/{src/images → images}/favicon.png +0 -0
- /package/{src/images → images}/geops_logo.png +0 -0
- /package/{src/images → images}/geops_logo.svg +0 -0
- /package/{src/images → images}/geops_qr.png +0 -0
- /package/{src/images → images}/mots/bus_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/bus_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/cable_car_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/ferry_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/funicular_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/gondola_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/rail_square-grey-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round blue-01.svg +0 -0
- /package/{src/images → images}/mots/subway_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_poi-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_round-grey-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-blue-01.svg +0 -0
- /package/{src/images → images}/mots/tram_square-grey-01.svg +0 -0
- /package/{src/images → images}/northArrow.svg +0 -0
- /package/{src/images → images}/northArrow.url.svg +0 -0
- /package/{src/images → images}/northArrowCircle.svg +0 -0
- /package/{src/images → images}/northArrowCircle.url.svg +0 -0
- /package/{src/themes → themes}/README.md +0 -0
- /package/{src/themes → themes}/default/components.scss +0 -0
- /package/{src/themes → themes}/default/examples.scss +0 -0
- /package/{src/themes → themes}/default/index.scss +0 -0
- /package/{src/themes → themes}/default/mixins.scss +0 -0
- /package/{src/themes → themes}/default/variables.scss +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import 'jest-canvas-mock';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { configure, mount } from 'enzyme';
|
|
4
|
-
import Adapter from '@cfaester/enzyme-adapter-react-18';
|
|
5
|
-
import { act } from 'react-dom/test-utils';
|
|
6
|
-
import { Map, View } from 'ol';
|
|
7
|
-
import Tile from 'ol/Tile';
|
|
8
|
-
import TileLayer from 'ol/layer/Tile';
|
|
9
|
-
import TileSource from 'ol/source/Tile';
|
|
10
|
-
import { createXYZ } from 'ol/tilegrid';
|
|
11
|
-
import { Layer } from 'mobility-toolbox-js/ol';
|
|
12
|
-
import Copyright from './Copyright';
|
|
13
|
-
|
|
14
|
-
configure({ adapter: new Adapter() });
|
|
15
|
-
|
|
16
|
-
const image = new Image();
|
|
17
|
-
image.width = 256;
|
|
18
|
-
image.height = 256;
|
|
19
|
-
|
|
20
|
-
const tileLoadFunction = () => {
|
|
21
|
-
const tile = new Tile([0, 0, -1], 2 /* LOADED */);
|
|
22
|
-
tile.getImage = () => {
|
|
23
|
-
return image;
|
|
24
|
-
};
|
|
25
|
-
return tile;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const getOLTileLayer = () => {
|
|
29
|
-
const layer = new TileLayer({
|
|
30
|
-
source: new TileSource({
|
|
31
|
-
projection: 'EPSG:3857',
|
|
32
|
-
tileGrid: createXYZ(),
|
|
33
|
-
}),
|
|
34
|
-
});
|
|
35
|
-
layer.getSource().getTile = tileLoadFunction;
|
|
36
|
-
return layer;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const getLayer = (copyrights, visible = true) => {
|
|
40
|
-
return new Layer({
|
|
41
|
-
visible,
|
|
42
|
-
copyrights,
|
|
43
|
-
olLayer: getOLTileLayer(),
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
let layers;
|
|
48
|
-
let map;
|
|
49
|
-
|
|
50
|
-
describe('Copyright', () => {
|
|
51
|
-
beforeEach(() => {
|
|
52
|
-
const target = document.createElement('div');
|
|
53
|
-
document.body.appendChild(target);
|
|
54
|
-
layers = [getLayer('bar'), getLayer('foo', false)];
|
|
55
|
-
map = new Map({
|
|
56
|
-
target,
|
|
57
|
-
view: new View({
|
|
58
|
-
center: [0, 0],
|
|
59
|
-
zoom: 0,
|
|
60
|
-
}),
|
|
61
|
-
layers: layers.map((layer) => {
|
|
62
|
-
return layer.olLayer;
|
|
63
|
-
}),
|
|
64
|
-
});
|
|
65
|
-
map.setSize([200, 200]);
|
|
66
|
-
layers.forEach((layer) => {
|
|
67
|
-
layer.attachToMap(map);
|
|
68
|
-
});
|
|
69
|
-
act(() => {
|
|
70
|
-
map.renderSync();
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
afterEach(() => {
|
|
75
|
-
layers.forEach((layer) => {
|
|
76
|
-
layer.detachFromMap(map);
|
|
77
|
-
});
|
|
78
|
-
map.setTarget(null);
|
|
79
|
-
map = null;
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('is empty if no layers are visible', () => {
|
|
83
|
-
const component = mount(<Copyright map={map} />);
|
|
84
|
-
expect(component.html()).toBe(null);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('displays one copyright', () => {
|
|
88
|
-
const wrapper = mount(<Copyright map={map} />);
|
|
89
|
-
act(() => {
|
|
90
|
-
map.renderSync();
|
|
91
|
-
});
|
|
92
|
-
wrapper.update();
|
|
93
|
-
expect(wrapper.text()).toBe('bar');
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test('displays 2 copyrights', () => {
|
|
97
|
-
const wrapper = mount(<Copyright map={map} />);
|
|
98
|
-
layers[0].visible = true;
|
|
99
|
-
layers[1].visible = true;
|
|
100
|
-
act(() => {
|
|
101
|
-
map.renderSync();
|
|
102
|
-
});
|
|
103
|
-
wrapper.update();
|
|
104
|
-
expect(wrapper.text()).toBe('bar | foo');
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('displays a copyright using a custom format', () => {
|
|
108
|
-
const wrapper = mount(
|
|
109
|
-
<Copyright
|
|
110
|
-
map={map}
|
|
111
|
-
format={(copyrights) => {
|
|
112
|
-
return `Number of copyrights: ${copyrights.length}`;
|
|
113
|
-
}}
|
|
114
|
-
/>,
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
act(() => {
|
|
118
|
-
map.renderSync();
|
|
119
|
-
});
|
|
120
|
-
wrapper.update();
|
|
121
|
-
|
|
122
|
-
expect(wrapper.text()).toBe('Number of copyrights: 1');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test('set a custom className', () => {
|
|
126
|
-
const wrapper = mount(<Copyright map={map} className="foo" />);
|
|
127
|
-
expect(wrapper.find('.foo').length).toBe(1);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('set a custom attribute to the root element', () => {
|
|
131
|
-
const wrapper = mount(<Copyright map={map} foo="bar" />);
|
|
132
|
-
expect(wrapper.find('[foo]').length).toBe(1);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
The following example demonstrates the use of Copyright.
|
|
2
|
-
|
|
3
|
-
```js
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import Map from 'ol/Map';
|
|
6
|
-
import Tile from 'ol/layer/Tile';
|
|
7
|
-
import OSM from 'ol/source/OSM';
|
|
8
|
-
import { defaults } from 'ol/control';
|
|
9
|
-
import { Layer, MapboxLayer } from 'mobility-toolbox-js/ol';
|
|
10
|
-
import BasicMap from 'react-spatial/components/BasicMap';
|
|
11
|
-
import Copyright from 'react-spatial/components/Copyright';
|
|
12
|
-
|
|
13
|
-
const map = new Map({
|
|
14
|
-
controls: defaults({
|
|
15
|
-
attribution: false,
|
|
16
|
-
}),
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const layers = [
|
|
20
|
-
new MapboxLayer({
|
|
21
|
-
url: `https://maps.geops.io/styles/base_bright_v2/style.json?key=${window.apiKey}`,
|
|
22
|
-
}),
|
|
23
|
-
new Layer({
|
|
24
|
-
copyrights: '© My custom copyright for OSM Contributors',
|
|
25
|
-
olLayer: new Tile({
|
|
26
|
-
source: new OSM(),
|
|
27
|
-
}),
|
|
28
|
-
}),
|
|
29
|
-
];
|
|
30
|
-
window.layers = layers;
|
|
31
|
-
|
|
32
|
-
<div className="rs-copyright-example">
|
|
33
|
-
<BasicMap map={map} layers={layers} tabIndex={0} />
|
|
34
|
-
<Copyright map={map} />
|
|
35
|
-
</div>;
|
|
36
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Copyright';
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import React, { PureComponent } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import KMLFormat from 'ol/format/KML';
|
|
4
|
-
import { Layer } from 'mobility-toolbox-js/ol';
|
|
5
|
-
import KML from '../../utils/KML';
|
|
6
|
-
|
|
7
|
-
const propTypes = {
|
|
8
|
-
/**
|
|
9
|
-
* Children content of the Feature export button.
|
|
10
|
-
*/
|
|
11
|
-
children: PropTypes.node,
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Format to export features (function).
|
|
15
|
-
* Supported formats: https://openlayers.org/en/latest/apidoc/module-ol_format_Feature-FeatureFormat.html
|
|
16
|
-
*/
|
|
17
|
-
format: PropTypes.func,
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* An existing [mobility-toolbox-js Layer](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers),
|
|
21
|
-
* using a valid [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector.html)
|
|
22
|
-
*/
|
|
23
|
-
layer: PropTypes.instanceOf(Layer).isRequired,
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Map projection.
|
|
27
|
-
*/
|
|
28
|
-
projection: PropTypes.string,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const defaultProps = {
|
|
32
|
-
children: null,
|
|
33
|
-
format: KMLFormat,
|
|
34
|
-
projection: 'EPSG:3857',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The FeatureExportButton component creates a button that exports feature geometries
|
|
39
|
-
* from a [[mobility-toolbox-js Layer](https://mobility-toolbox-js.geops.io/api/identifiers%20html#ol-layers)]
|
|
40
|
-
* containing an [ol/layer/Vector](https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html)
|
|
41
|
-
* with a [ol/source/Vector](https://openlayers.org/en/latest/apidoc/module-ol_source_Vector.html) on click.<br>
|
|
42
|
-
* The default export format is KML, which supports the features' style export.<br>
|
|
43
|
-
* Other formats do not always support style export (See specific format specs).
|
|
44
|
-
*/
|
|
45
|
-
class FeatureExportButton extends PureComponent {
|
|
46
|
-
static createFeatureString(layer, projection, format) {
|
|
47
|
-
if (format === KMLFormat) {
|
|
48
|
-
return KML.writeFeatures(layer, projection);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line new-cap
|
|
52
|
-
return new format().writeFeatures(layer.olLayer.getSource().getFeatures(), {
|
|
53
|
-
featureProjection: projection,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static exportFeatures(layer, projection, format) {
|
|
58
|
-
const now = new Date()
|
|
59
|
-
.toJSON()
|
|
60
|
-
.slice(0, 20)
|
|
61
|
-
.replace(/[.:T-]+/g, '');
|
|
62
|
-
const featString = this.createFeatureString(layer, projection, format);
|
|
63
|
-
|
|
64
|
-
const formatString = featString
|
|
65
|
-
? featString.match(/<(\w+)\s+\w+.*?>/)[1]
|
|
66
|
-
: 'xml';
|
|
67
|
-
|
|
68
|
-
const fileName = `exported_features_${now}.${formatString}`;
|
|
69
|
-
const charset = document.characterSet || 'UTF-8';
|
|
70
|
-
const type = `${
|
|
71
|
-
formatString === 'kml'
|
|
72
|
-
? 'data:application/vnd.google-earth.kml+xml'
|
|
73
|
-
: 'data:text/xml'
|
|
74
|
-
};charset=${charset}`;
|
|
75
|
-
|
|
76
|
-
if (featString) {
|
|
77
|
-
if (window.navigator.msSaveBlob) {
|
|
78
|
-
// ie 11 and higher
|
|
79
|
-
window.navigator.msSaveBlob(new Blob([featString], { type }), fileName);
|
|
80
|
-
} else {
|
|
81
|
-
const link = document.createElement('a');
|
|
82
|
-
link.download = fileName;
|
|
83
|
-
link.href = `${type},${encodeURIComponent(featString)}`;
|
|
84
|
-
link.click();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
render() {
|
|
90
|
-
const { children, layer, projection, format, ...other } = this.props;
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<div
|
|
94
|
-
role="button"
|
|
95
|
-
className="rs-feature-export-button"
|
|
96
|
-
tabIndex={0}
|
|
97
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
98
|
-
{...other}
|
|
99
|
-
onClick={() => {
|
|
100
|
-
return FeatureExportButton.exportFeatures(layer, projection, format);
|
|
101
|
-
}}
|
|
102
|
-
onKeyPress={(evt) => {
|
|
103
|
-
return (
|
|
104
|
-
evt.which === 13 &&
|
|
105
|
-
FeatureExportButton.exportFeatures(layer, projection, format)
|
|
106
|
-
);
|
|
107
|
-
}}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
FeatureExportButton.propTypes = propTypes;
|
|
116
|
-
FeatureExportButton.defaultProps = defaultProps;
|
|
117
|
-
|
|
118
|
-
export default FeatureExportButton;
|
|
@@ -1,417 +0,0 @@
|
|
|
1
|
-
import 'jest-canvas-mock';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import renderer from 'react-test-renderer';
|
|
4
|
-
import { configure, mount, shallow } from 'enzyme';
|
|
5
|
-
import Adapter from '@cfaester/enzyme-adapter-react-18';
|
|
6
|
-
import { Layer } from 'mobility-toolbox-js/ol';
|
|
7
|
-
import GPX from 'ol/format/GPX';
|
|
8
|
-
import VectorSource from 'ol/source/Vector';
|
|
9
|
-
import Style from 'ol/style/Style';
|
|
10
|
-
import Icon from 'ol/style/Icon';
|
|
11
|
-
import Text from 'ol/style/Text';
|
|
12
|
-
import Fill from 'ol/style/Fill';
|
|
13
|
-
import Stroke from 'ol/style/Stroke';
|
|
14
|
-
import Circle from 'ol/geom/Circle';
|
|
15
|
-
import Point from 'ol/geom/Point';
|
|
16
|
-
import LineString from 'ol/geom/LineString';
|
|
17
|
-
import Feature from 'ol/Feature';
|
|
18
|
-
import VectorLayer from 'ol/layer/Vector';
|
|
19
|
-
|
|
20
|
-
import FeatureExportButton from '.';
|
|
21
|
-
|
|
22
|
-
configure({ adapter: new Adapter() });
|
|
23
|
-
|
|
24
|
-
const layer = new Layer({
|
|
25
|
-
name: 'Sample layer',
|
|
26
|
-
olLayer: new VectorLayer({
|
|
27
|
-
source: new VectorSource({
|
|
28
|
-
features: [
|
|
29
|
-
new Feature({
|
|
30
|
-
geometry: new Point([819103.972418, 6120013.078324]),
|
|
31
|
-
}),
|
|
32
|
-
],
|
|
33
|
-
}),
|
|
34
|
-
}),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('FeatureExportButton', () => {
|
|
38
|
-
describe('should match snapshot', () => {
|
|
39
|
-
test('with default attributes.', () => {
|
|
40
|
-
const component = renderer.create(<FeatureExportButton layer={layer} />);
|
|
41
|
-
const tree = component.toJSON();
|
|
42
|
-
expect(tree).toMatchSnapshot();
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('should match snapshot with cutom attributes.', () => {
|
|
46
|
-
const component = renderer.create(
|
|
47
|
-
<FeatureExportButton
|
|
48
|
-
layer={layer}
|
|
49
|
-
className="foo"
|
|
50
|
-
title="bar"
|
|
51
|
-
// eslint-disable-next-line jsx-a11y/tabindex-no-positive
|
|
52
|
-
tabIndex={2}
|
|
53
|
-
/>,
|
|
54
|
-
);
|
|
55
|
-
const tree = component.toJSON();
|
|
56
|
-
expect(tree).toMatchSnapshot();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
test('should match snapshot with children passed.', () => {
|
|
60
|
-
const component = renderer.create(
|
|
61
|
-
<FeatureExportButton layer={layer}>
|
|
62
|
-
<div>Foo</div>
|
|
63
|
-
</FeatureExportButton>,
|
|
64
|
-
);
|
|
65
|
-
const tree = component.toJSON();
|
|
66
|
-
expect(tree).toMatchSnapshot();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
describe('triggers onClick', () => {
|
|
71
|
-
// Use library 'jest-environment-jsdom-fourteen'
|
|
72
|
-
// to allow jest test of format.writeFeatures(feats).
|
|
73
|
-
const renderLayer = (featNumbers) => {
|
|
74
|
-
const featsArray = [];
|
|
75
|
-
for (let i = 0; i < featNumbers; i += 1) {
|
|
76
|
-
featsArray.push(
|
|
77
|
-
new Feature({
|
|
78
|
-
geometry: new Point([819103.972418, 6120013.078324]),
|
|
79
|
-
}),
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return new Layer({
|
|
84
|
-
name: 'ExportLayer',
|
|
85
|
-
olLayer: new VectorLayer({
|
|
86
|
-
source: new VectorSource({
|
|
87
|
-
features: featsArray,
|
|
88
|
-
}),
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const iconLayer = renderLayer(1);
|
|
94
|
-
|
|
95
|
-
const textStyle = new Style({
|
|
96
|
-
text: new Text({
|
|
97
|
-
text: 'text name',
|
|
98
|
-
font: 'normal 16px Helvetica',
|
|
99
|
-
stroke: new Stroke({
|
|
100
|
-
color: [255, 255, 255, 1],
|
|
101
|
-
width: 3,
|
|
102
|
-
}),
|
|
103
|
-
}),
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test('should be trigger click function.', () => {
|
|
107
|
-
const wrapper = shallow(<FeatureExportButton layer={iconLayer} />);
|
|
108
|
-
const spy = jest.spyOn(FeatureExportButton, 'exportFeatures');
|
|
109
|
-
wrapper.find('.rs-feature-export-button').simulate('click');
|
|
110
|
-
expect(spy).toHaveBeenCalledTimes(1);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('should use attributes for parsing', () => {
|
|
114
|
-
const wrapper = mount(
|
|
115
|
-
<FeatureExportButton
|
|
116
|
-
format={GPX}
|
|
117
|
-
projection="EPSG:4326"
|
|
118
|
-
layer={iconLayer}
|
|
119
|
-
/>,
|
|
120
|
-
);
|
|
121
|
-
const spy = jest.spyOn(FeatureExportButton, 'exportFeatures');
|
|
122
|
-
wrapper.find('.rs-feature-export-button').simulate('click');
|
|
123
|
-
expect(spy).toHaveBeenCalledWith(iconLayer, 'EPSG:4326', GPX);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
describe('#createFeatureString()', () => {
|
|
127
|
-
describe('using KMLFormat', () => {
|
|
128
|
-
test('should export kml by default.', () => {
|
|
129
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
130
|
-
iconLayer,
|
|
131
|
-
FeatureExportButton.defaultProps.projection,
|
|
132
|
-
FeatureExportButton.defaultProps.format,
|
|
133
|
-
);
|
|
134
|
-
expect(exportString).toMatchSnapshot();
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
const iconStyle = new Style({
|
|
138
|
-
image: new Icon({
|
|
139
|
-
anchor: [0.5, 46],
|
|
140
|
-
anchorXUnits: 'fraction',
|
|
141
|
-
anchorYUnits: 'pixels',
|
|
142
|
-
src: 'https://openlayers.org/en/latest/examples/data/icon.png',
|
|
143
|
-
}),
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
iconLayer.olLayer.getSource().forEachFeature((f) => {
|
|
147
|
-
f.setStyle(iconStyle);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
test('should export icon style in kml.', () => {
|
|
151
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
152
|
-
iconLayer,
|
|
153
|
-
FeatureExportButton.defaultProps.projection,
|
|
154
|
-
FeatureExportButton.defaultProps.format,
|
|
155
|
-
);
|
|
156
|
-
const expectedString =
|
|
157
|
-
'<Style><IconStyle><scale>2</scale><Icon><href>' +
|
|
158
|
-
'https://openlayers.org/en/latest/examples/data/icon.png' +
|
|
159
|
-
'</href></Icon></IconStyle></Style>';
|
|
160
|
-
expect(exportString.match(/<Style>(.*?)<\/Style>/g)[0]).toBe(
|
|
161
|
-
expectedString,
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
test('should export with layer name.', () => {
|
|
166
|
-
const namedlayer = renderLayer(1);
|
|
167
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
168
|
-
namedlayer,
|
|
169
|
-
FeatureExportButton.defaultProps.projection,
|
|
170
|
-
FeatureExportButton.defaultProps.format,
|
|
171
|
-
);
|
|
172
|
-
const expectedname = '<name>ExportLayer</name>';
|
|
173
|
-
expect(exportString.match(/<name>(.*?)<\/name>/g)[0]).toBe(
|
|
174
|
-
expectedname,
|
|
175
|
-
);
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
test('should export without layer name.', () => {
|
|
179
|
-
const unnamedlayer = renderLayer(1);
|
|
180
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
181
|
-
unnamedlayer,
|
|
182
|
-
FeatureExportButton.defaultProps.projection,
|
|
183
|
-
FeatureExportButton.defaultProps.format,
|
|
184
|
-
);
|
|
185
|
-
expect(
|
|
186
|
-
/<document><name>ExportLayer<\/name>/g.test(exportString),
|
|
187
|
-
).toBe(false);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
test('should export text style in kml.', () => {
|
|
191
|
-
const textlayer = renderLayer(2);
|
|
192
|
-
|
|
193
|
-
textlayer.olLayer.getSource().forEachFeature((f) => {
|
|
194
|
-
f.setStyle(textStyle);
|
|
195
|
-
});
|
|
196
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
197
|
-
textlayer,
|
|
198
|
-
FeatureExportButton.defaultProps.projection,
|
|
199
|
-
FeatureExportButton.defaultProps.format,
|
|
200
|
-
);
|
|
201
|
-
const expectedStyle =
|
|
202
|
-
'<Style><IconStyle><scale>0</scale></IconStyle>' +
|
|
203
|
-
'<LabelStyle><color>ff333333</color></LabelStyle></Style>';
|
|
204
|
-
expect(exportString.match(/<Style>(.*?)<\/Style>/g)[0]).toBe(
|
|
205
|
-
expectedStyle,
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
test('should only export none-empty text style in kml.', () => {
|
|
210
|
-
const textlayer = renderLayer(2);
|
|
211
|
-
|
|
212
|
-
textlayer.olLayer.getSource().forEachFeature((f) => {
|
|
213
|
-
f.setStyle(textStyle);
|
|
214
|
-
});
|
|
215
|
-
const exportString1 = FeatureExportButton.createFeatureString(
|
|
216
|
-
textlayer,
|
|
217
|
-
FeatureExportButton.defaultProps.projection,
|
|
218
|
-
FeatureExportButton.defaultProps.format,
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
expect(
|
|
222
|
-
exportString1.match(/<Placemark>(.*?)<\/Placemark>/g).length,
|
|
223
|
-
).toBe(2);
|
|
224
|
-
|
|
225
|
-
const newStyle = new Style({
|
|
226
|
-
text: new Text({
|
|
227
|
-
text: '',
|
|
228
|
-
font: 'normal 16px Helvetica',
|
|
229
|
-
stroke: new Stroke({
|
|
230
|
-
color: [255, 255, 255, 1],
|
|
231
|
-
width: 3,
|
|
232
|
-
}),
|
|
233
|
-
}),
|
|
234
|
-
});
|
|
235
|
-
// Set empty string as name for first feature
|
|
236
|
-
textlayer.olLayer.getSource().getFeatures()[0].setStyle(newStyle);
|
|
237
|
-
|
|
238
|
-
const exportString2 = FeatureExportButton.createFeatureString(
|
|
239
|
-
textlayer,
|
|
240
|
-
FeatureExportButton.defaultProps.projection,
|
|
241
|
-
FeatureExportButton.defaultProps.format,
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
expect(
|
|
245
|
-
exportString2.match(/<Placemark>(.*?)<\/Placemark>/g).length,
|
|
246
|
-
).toBe(1);
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
test("should not export 'Cirle geom' (kml unsupported).", () => {
|
|
250
|
-
const circleLayer = new Layer({
|
|
251
|
-
name: 'ExportLayer',
|
|
252
|
-
olLayer: new VectorLayer({
|
|
253
|
-
source: new VectorSource({
|
|
254
|
-
features: [
|
|
255
|
-
new Feature({
|
|
256
|
-
geometry: new Circle({
|
|
257
|
-
center: [843119.531243, 6111943.000197],
|
|
258
|
-
radius: 1000,
|
|
259
|
-
}),
|
|
260
|
-
}),
|
|
261
|
-
],
|
|
262
|
-
}),
|
|
263
|
-
}),
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
const circleStyle = new Style({
|
|
267
|
-
stroke: new Stroke({
|
|
268
|
-
color: 'red',
|
|
269
|
-
width: 3,
|
|
270
|
-
}),
|
|
271
|
-
fill: new Fill({
|
|
272
|
-
color: 'rgba(255, 0, 0, 0.1)',
|
|
273
|
-
}),
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
circleLayer.olLayer.getSource().forEachFeature((f) => {
|
|
277
|
-
f.setStyle(circleStyle);
|
|
278
|
-
});
|
|
279
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
280
|
-
circleLayer,
|
|
281
|
-
FeatureExportButton.defaultProps.projection,
|
|
282
|
-
FeatureExportButton.defaultProps.format,
|
|
283
|
-
);
|
|
284
|
-
expect(exportString).toBe(undefined);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test('should export extended data.', () => {
|
|
288
|
-
const extendedLayer = renderLayer(1);
|
|
289
|
-
|
|
290
|
-
const style = new Style({
|
|
291
|
-
stroke: new Stroke({
|
|
292
|
-
color: [0, 0, 0, 1],
|
|
293
|
-
lineDash: [40, 40],
|
|
294
|
-
}),
|
|
295
|
-
text: new Text({
|
|
296
|
-
text: 'text name',
|
|
297
|
-
font: 'normal 18px Arial',
|
|
298
|
-
rotation: 0.5,
|
|
299
|
-
backgroundFill: new Fill({
|
|
300
|
-
color: 'rgba(255,255,255,0.01)',
|
|
301
|
-
}),
|
|
302
|
-
}),
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
extendedLayer.olLayer.getSource().forEachFeature((f) => {
|
|
306
|
-
f.setStyle(style);
|
|
307
|
-
});
|
|
308
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
309
|
-
extendedLayer,
|
|
310
|
-
FeatureExportButton.defaultProps.projection,
|
|
311
|
-
FeatureExportButton.defaultProps.format,
|
|
312
|
-
);
|
|
313
|
-
const expectedStyle =
|
|
314
|
-
'<ExtendedData><Data name="lineDash"><value>40,40</value></Data>' +
|
|
315
|
-
'<Data name="textBackgroundFillColor"><value>rgba(255,255,255,0.01)</value></Data>' +
|
|
316
|
-
'<Data name="textFont"><value>normal 18px Arial</value></Data>' +
|
|
317
|
-
'<Data name="textRotation"><value>0.5</value></Data></ExtendedData>';
|
|
318
|
-
expect(
|
|
319
|
-
exportString.match(/<ExtendedData>(.*?)<\/ExtendedData>/g)[0],
|
|
320
|
-
).toBe(expectedStyle);
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
test('should not export others extended data than style.', () => {
|
|
324
|
-
const extendedLayer = renderLayer(1);
|
|
325
|
-
|
|
326
|
-
const style = new Style({
|
|
327
|
-
stroke: new Stroke({
|
|
328
|
-
color: [0, 0, 0, 1],
|
|
329
|
-
lineDash: [40, 40],
|
|
330
|
-
}),
|
|
331
|
-
text: new Text({
|
|
332
|
-
text: 'text name',
|
|
333
|
-
font: 'normal 18px Arial',
|
|
334
|
-
rotation: 0.5,
|
|
335
|
-
backgroundFill: new Fill({
|
|
336
|
-
color: 'rgba(255,255,255,0.01)',
|
|
337
|
-
}),
|
|
338
|
-
}),
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
extendedLayer.olLayer.getSource().forEachFeature((f) => {
|
|
342
|
-
f.setStyle(style);
|
|
343
|
-
f.set('foo', 'bar');
|
|
344
|
-
});
|
|
345
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
346
|
-
extendedLayer,
|
|
347
|
-
FeatureExportButton.defaultProps.projection,
|
|
348
|
-
FeatureExportButton.defaultProps.format,
|
|
349
|
-
);
|
|
350
|
-
const expectedStyle =
|
|
351
|
-
'<ExtendedData><Data name="lineDash"><value>40,40</value></Data>' +
|
|
352
|
-
'<Data name="textBackgroundFillColor"><value>rgba(255,255,255,0.01)</value></Data>' +
|
|
353
|
-
'<Data name="textFont"><value>normal 18px Arial</value></Data>' +
|
|
354
|
-
'<Data name="textRotation"><value>0.5</value></Data></ExtendedData>';
|
|
355
|
-
expect(
|
|
356
|
-
exportString.match(/<ExtendedData>(.*?)<\/ExtendedData>/g)[0],
|
|
357
|
-
).toBe(expectedStyle);
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
test('should export lineStartIcon and lineEndIcon style.', () => {
|
|
361
|
-
const extendedLayer = renderLayer(1);
|
|
362
|
-
const line = new Feature({
|
|
363
|
-
geometry: new LineString([
|
|
364
|
-
[0, 1],
|
|
365
|
-
[2, 3],
|
|
366
|
-
[4, 5],
|
|
367
|
-
]),
|
|
368
|
-
});
|
|
369
|
-
extendedLayer.olLayer.getSource().addFeatures([line]);
|
|
370
|
-
|
|
371
|
-
const style = [
|
|
372
|
-
new Style({
|
|
373
|
-
stroke: new Stroke({
|
|
374
|
-
color: [0, 0, 0, 1],
|
|
375
|
-
lineDash: [40, 40],
|
|
376
|
-
}),
|
|
377
|
-
}),
|
|
378
|
-
new Style({
|
|
379
|
-
geometry: () => {
|
|
380
|
-
return new Point([4, 5]);
|
|
381
|
-
},
|
|
382
|
-
image: new Icon({
|
|
383
|
-
src: 'fooarrowend.png',
|
|
384
|
-
}),
|
|
385
|
-
}),
|
|
386
|
-
new Style({
|
|
387
|
-
geometry: () => {
|
|
388
|
-
return new Point([0, 1]);
|
|
389
|
-
},
|
|
390
|
-
image: new Icon({
|
|
391
|
-
src: 'fooarrowstart.png',
|
|
392
|
-
}),
|
|
393
|
-
}),
|
|
394
|
-
];
|
|
395
|
-
line.setStyle(style);
|
|
396
|
-
|
|
397
|
-
const exportString = FeatureExportButton.createFeatureString(
|
|
398
|
-
extendedLayer,
|
|
399
|
-
FeatureExportButton.defaultProps.projection,
|
|
400
|
-
FeatureExportButton.defaultProps.format,
|
|
401
|
-
);
|
|
402
|
-
const expectedStyle =
|
|
403
|
-
'<ExtendedData><Data name="lineDash"><value>40,40</value></Data>' +
|
|
404
|
-
'<Data name="lineEndIcon">' +
|
|
405
|
-
'<value>{"url":"fooarrowend.png","scale":1,"size":null}</value></Data>' +
|
|
406
|
-
'<Data name="lineStartIcon">' +
|
|
407
|
-
'<value>{"url":"fooarrowstart.png","scale":1,"size":null}</value></Data>' +
|
|
408
|
-
'</ExtendedData>';
|
|
409
|
-
|
|
410
|
-
expect(
|
|
411
|
-
exportString.match(/<ExtendedData>(.*?)<\/ExtendedData>/g)[0],
|
|
412
|
-
).toBe(expectedStyle);
|
|
413
|
-
});
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
});
|
|
417
|
-
});
|