react-spatial 1.5.3 → 1.5.4
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 +231 -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/components/BasicMap/BasicMap.js +278 -0
- 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 +93 -320
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -0
- package/components/CanvasSaveButton/index.js +1 -0
- package/components/CanvasSaveButton/index.js.map +7 -0
- package/components/Copyright/Copyright.js +55 -0
- 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 +62 -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/components/FitExtent/FitExtent.js +32 -0
- 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 +61 -144
- package/components/Geolocation/Geolocation.js.map +7 -0
- package/components/Geolocation/index.js +1 -0
- package/components/Geolocation/index.js.map +7 -0
- package/components/LayerTree/LayerTree.js +278 -0
- package/components/LayerTree/LayerTree.js.map +7 -0
- package/components/LayerTree/index.js +1 -0
- package/components/LayerTree/index.js.map +7 -0
- package/components/MousePosition/MousePosition.js +110 -0
- package/components/MousePosition/MousePosition.js.map +7 -0
- package/components/MousePosition/index.js +1 -0
- package/components/MousePosition/index.js.map +7 -0
- package/components/NorthArrow/NorthArrow.js +43 -0
- package/components/NorthArrow/NorthArrow.js.map +7 -0
- package/components/NorthArrow/index.js +1 -0
- package/components/NorthArrow/index.js.map +7 -0
- package/components/Overlay/Overlay.js +122 -0
- package/components/Overlay/Overlay.js.map +7 -0
- package/components/Overlay/index.js +1 -0
- package/components/Overlay/index.js.map +7 -0
- package/components/Permalink/Permalink.js +206 -0
- 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 +55 -165
- 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 -50
- 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 +223 -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/components/ScaleLine/ScaleLine.js +32 -0
- package/components/ScaleLine/ScaleLine.js.map +7 -0
- package/components/ScaleLine/index.js +1 -0
- package/components/ScaleLine/index.js.map +7 -0
- package/components/StopsFinder/StopsFinder.js +210 -0
- package/components/StopsFinder/StopsFinder.js.map +7 -0
- package/components/StopsFinder/StopsFinderOption.js +51 -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/components/Zoom/Zoom.js +130 -0
- 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 +1 -1
- package/{src/propTypes.js → propTypes.js} +12 -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 +412 -0
- package/utils/KML.js.map +7 -0
- package/utils/KMLFormat.js +69 -0
- 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.js +0 -413
- 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.js +0 -89
- 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.js +0 -62
- 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.js +0 -487
- 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.js +0 -175
- 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.js +0 -75
- 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.js +0 -176
- 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.js +0 -326
- 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.js +0 -50
- 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.js +0 -284
- 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.js +0 -180
- 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.js +0 -100
- 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
package/src/utils/KML.test.js
DELETED
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import VectorLayer from 'ol/layer/Vector';
|
|
2
|
-
import VectorSource from 'ol/source/Vector';
|
|
3
|
-
import { Style } from 'ol/style';
|
|
4
|
-
import { get } from 'ol/proj';
|
|
5
|
-
import beautify from 'xml-beautifier';
|
|
6
|
-
import KML from './KML';
|
|
7
|
-
|
|
8
|
-
const xmlns =
|
|
9
|
-
'xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd"';
|
|
10
|
-
|
|
11
|
-
const expectWriteResult = (feats, str) => {
|
|
12
|
-
expect(
|
|
13
|
-
beautify(
|
|
14
|
-
KML.writeFeatures(
|
|
15
|
-
{
|
|
16
|
-
name: 'lala',
|
|
17
|
-
olLayer: new VectorLayer({
|
|
18
|
-
source: new VectorSource({
|
|
19
|
-
features: feats,
|
|
20
|
-
}),
|
|
21
|
-
}),
|
|
22
|
-
},
|
|
23
|
-
get('EPSG:4326'),
|
|
24
|
-
),
|
|
25
|
-
),
|
|
26
|
-
).toEqual(beautify(str));
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
describe('KML', () => {
|
|
30
|
-
describe('readFeatures() and writeFeatures()', () => {
|
|
31
|
-
test('should read/write LineStyle and ExtendedData (linesDash, lineStartIcon and lineEndIcon).', () => {
|
|
32
|
-
const str = `
|
|
33
|
-
<kml ${xmlns}>
|
|
34
|
-
<Document>
|
|
35
|
-
<name>lala</name>
|
|
36
|
-
<Placemark>
|
|
37
|
-
<Style>
|
|
38
|
-
<LineStyle>
|
|
39
|
-
<color>ff056600</color>
|
|
40
|
-
<width>1</width>
|
|
41
|
-
</LineStyle>
|
|
42
|
-
</Style>
|
|
43
|
-
<ExtendedData>
|
|
44
|
-
<Data name="lineDash"><value>40,40</value></Data>
|
|
45
|
-
<Data name="lineEndIcon"><value>{"url":"fooarrowend.png","scale":0.35,"size":[36,58],"zIndex":1}</value></Data>
|
|
46
|
-
<Data name="lineStartIcon"><value>{"url":"fooarrowstart.png","scale":0.35,"size":[36,58],"zIndex":1}</value></Data>
|
|
47
|
-
</ExtendedData>
|
|
48
|
-
<LineString><coordinates>0,1,0 3,5,0 40,25,0</coordinates></LineString>
|
|
49
|
-
</Placemark>
|
|
50
|
-
</Document>
|
|
51
|
-
</kml>
|
|
52
|
-
`;
|
|
53
|
-
const feats = KML.readFeatures(str);
|
|
54
|
-
const styles = feats[0].getStyle();
|
|
55
|
-
expect(feats.length).toBe(1);
|
|
56
|
-
expect(styles.length).toBe(3);
|
|
57
|
-
|
|
58
|
-
// line stroke
|
|
59
|
-
const strokeStyle = styles[0].getStroke();
|
|
60
|
-
expect(strokeStyle.getColor()).toEqual([0, 102, 5, 1]);
|
|
61
|
-
expect(strokeStyle.getLineDash()).toEqual([40, 40]);
|
|
62
|
-
|
|
63
|
-
// line start icon
|
|
64
|
-
const lineStartStyle = styles[1];
|
|
65
|
-
expect(lineStartStyle.getImage().getRotation()).toEqual(
|
|
66
|
-
-0.9272952180016122,
|
|
67
|
-
);
|
|
68
|
-
expect(lineStartStyle.getImage().getColor()).toEqual([0, 102, 5, 1]);
|
|
69
|
-
expect(lineStartStyle.getImage().getRotateWithView()).toBe(true);
|
|
70
|
-
expect(lineStartStyle.getGeometry()(feats[0]).getCoordinates()).toEqual([
|
|
71
|
-
0, 1, 0,
|
|
72
|
-
]);
|
|
73
|
-
expect(lineStartStyle.getZIndex()).toEqual(1);
|
|
74
|
-
|
|
75
|
-
// line end icon
|
|
76
|
-
const lineEndStyle = styles[2];
|
|
77
|
-
expect(lineEndStyle.getImage().getRotation()).toEqual(
|
|
78
|
-
-0.49555167348582857,
|
|
79
|
-
);
|
|
80
|
-
expect(lineEndStyle.getImage().getRotateWithView()).toBe(true);
|
|
81
|
-
expect(lineEndStyle.getImage().getColor()).toEqual([0, 102, 5, 1]);
|
|
82
|
-
expect(lineEndStyle.getGeometry()(feats[0]).getCoordinates()).toEqual([
|
|
83
|
-
40, 25, 0,
|
|
84
|
-
]);
|
|
85
|
-
expect(lineEndStyle.getZIndex()).toEqual(1);
|
|
86
|
-
|
|
87
|
-
expectWriteResult(feats, str);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('should read/write TextStyle and ExtendedData.', () => {
|
|
91
|
-
const str = `
|
|
92
|
-
<kml ${xmlns}>
|
|
93
|
-
<Document>
|
|
94
|
-
<name>lala</name>
|
|
95
|
-
<Placemark>
|
|
96
|
-
<name> bar </name>
|
|
97
|
-
<Style>
|
|
98
|
-
<IconStyle>
|
|
99
|
-
<scale>0</scale>
|
|
100
|
-
</IconStyle>
|
|
101
|
-
<LabelStyle>
|
|
102
|
-
<color>ff7e3420</color>
|
|
103
|
-
<scale>2</scale>
|
|
104
|
-
</LabelStyle>
|
|
105
|
-
</Style>
|
|
106
|
-
<ExtendedData>
|
|
107
|
-
<Data name="textAlign">
|
|
108
|
-
<value>right</value>
|
|
109
|
-
</Data>
|
|
110
|
-
<Data name="textBackgroundFillColor">
|
|
111
|
-
<value>rgba(255,255,255,0.01)</value>
|
|
112
|
-
</Data>
|
|
113
|
-
<Data name="textFont">
|
|
114
|
-
<value>bold 16px arial</value>
|
|
115
|
-
</Data>
|
|
116
|
-
<Data name="textOffsetX">
|
|
117
|
-
<value>-90</value>
|
|
118
|
-
</Data>
|
|
119
|
-
<Data name="textOffsetY">
|
|
120
|
-
<value>30</value>
|
|
121
|
-
</Data>
|
|
122
|
-
<Data name="textPadding">
|
|
123
|
-
<value>5,6,7,8</value>
|
|
124
|
-
</Data>
|
|
125
|
-
<Data name="textRotation">
|
|
126
|
-
<value>2.303834612632515</value>
|
|
127
|
-
</Data>
|
|
128
|
-
<Data name="textStrokeColor">
|
|
129
|
-
<value>rgba(100,255,255,0.2)</value>
|
|
130
|
-
</Data>
|
|
131
|
-
<Data name="textStrokeWidth">
|
|
132
|
-
<value>3</value>
|
|
133
|
-
</Data>
|
|
134
|
-
</ExtendedData>
|
|
135
|
-
<Point>
|
|
136
|
-
<coordinates>0,0,0</coordinates>
|
|
137
|
-
</Point>
|
|
138
|
-
</Placemark>
|
|
139
|
-
</Document>
|
|
140
|
-
</kml>
|
|
141
|
-
`;
|
|
142
|
-
const feats = KML.readFeatures(str);
|
|
143
|
-
const style = feats[0].getStyleFunction()(feats[0], 1);
|
|
144
|
-
expect(feats.length).toBe(1);
|
|
145
|
-
expect(style instanceof Style).toBe(true);
|
|
146
|
-
|
|
147
|
-
// Text
|
|
148
|
-
const styleText = style.getText();
|
|
149
|
-
expect(styleText.getText()).toBe('bar'); // spaces are trimmed.
|
|
150
|
-
expect(styleText.getFont()).toEqual('bold 16px arial');
|
|
151
|
-
expect(styleText.getFill()).toEqual({ color_: [32, 52, 126, 1] });
|
|
152
|
-
expect(styleText.getStroke()).toEqual({
|
|
153
|
-
color_: 'rgba(100,255,255,0.2)',
|
|
154
|
-
width_: 3,
|
|
155
|
-
lineCap_: undefined,
|
|
156
|
-
lineDashOffset_: undefined,
|
|
157
|
-
lineDash_: null,
|
|
158
|
-
lineJoin_: undefined,
|
|
159
|
-
miterLimit_: undefined,
|
|
160
|
-
});
|
|
161
|
-
expect(styleText.getScale()).toEqual(2);
|
|
162
|
-
expect(styleText.getRotation()).toEqual('2.303834612632515');
|
|
163
|
-
expect(styleText.getPadding()).toEqual([5, 6, 7, 8]);
|
|
164
|
-
expect(styleText.getBackgroundFill()).toEqual({
|
|
165
|
-
color_: 'rgba(255,255,255,0.01)',
|
|
166
|
-
});
|
|
167
|
-
expect(styleText.getTextAlign()).toEqual('right');
|
|
168
|
-
expect(styleText.getOffsetX()).toEqual(-90);
|
|
169
|
-
expect(styleText.getOffsetY()).toEqual(30);
|
|
170
|
-
expectWriteResult(feats, str);
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test('should read and write lineDash and fillPattern style for polygon', () => {
|
|
174
|
-
const str = `
|
|
175
|
-
<kml ${xmlns}>
|
|
176
|
-
<Document>
|
|
177
|
-
<name>lala</name>
|
|
178
|
-
<Placemark>
|
|
179
|
-
<description></description>
|
|
180
|
-
<Style>
|
|
181
|
-
<LineStyle>
|
|
182
|
-
<color>ff0000eb</color>
|
|
183
|
-
<width>2</width>
|
|
184
|
-
</LineStyle>
|
|
185
|
-
<PolyStyle>
|
|
186
|
-
<fill>0</fill>
|
|
187
|
-
</PolyStyle>
|
|
188
|
-
</Style>
|
|
189
|
-
<ExtendedData>
|
|
190
|
-
<Data name="fillPattern">
|
|
191
|
-
<value>{"id":3,"color":[235,0,0,1]}</value>
|
|
192
|
-
</Data>
|
|
193
|
-
<Data name="lineDash">
|
|
194
|
-
<value>1,1</value>
|
|
195
|
-
</Data>
|
|
196
|
-
</ExtendedData>
|
|
197
|
-
<Polygon>
|
|
198
|
-
<outerBoundaryIs>
|
|
199
|
-
<LinearRing>
|
|
200
|
-
<coordinates>8.521,47.381,0 8.529,47.375,0 8.531,47.382,0 8.521,47.381,0</coordinates>
|
|
201
|
-
</LinearRing>
|
|
202
|
-
</outerBoundaryIs>
|
|
203
|
-
</Polygon>
|
|
204
|
-
</Placemark>
|
|
205
|
-
</Document>
|
|
206
|
-
</kml>
|
|
207
|
-
`;
|
|
208
|
-
const feats = KML.readFeatures(str);
|
|
209
|
-
const styles = feats[0].getStyle();
|
|
210
|
-
expect(feats.length).toBe(1);
|
|
211
|
-
expect(styles.length).toBe(1);
|
|
212
|
-
|
|
213
|
-
// Polygon
|
|
214
|
-
const feature = feats[0];
|
|
215
|
-
const outlineStyle = styles[0].getStroke();
|
|
216
|
-
expect(outlineStyle.getColor()).toEqual([235, 0, 0, 1]);
|
|
217
|
-
expect(outlineStyle.getWidth()).toEqual(2);
|
|
218
|
-
const fillStyle = styles[0].getFill();
|
|
219
|
-
expect(feature.get('fillPattern')).toEqual({
|
|
220
|
-
id: 3,
|
|
221
|
-
color: [235, 0, 0, 1],
|
|
222
|
-
});
|
|
223
|
-
const color = fillStyle.getColor();
|
|
224
|
-
expect(color.id).toBe(3);
|
|
225
|
-
expect(color.color).toEqual([235, 0, 0, 1]);
|
|
226
|
-
expectWriteResult(feats, str);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
test('should add zIndex and rotation to icon style and pictureOptions to feature properties.', () => {
|
|
230
|
-
const str = `
|
|
231
|
-
<kml ${xmlns}>
|
|
232
|
-
<Document>
|
|
233
|
-
<name>lala</name>
|
|
234
|
-
<Placemark>
|
|
235
|
-
<description></description>
|
|
236
|
-
<Style>
|
|
237
|
-
<IconStyle>
|
|
238
|
-
<scale>
|
|
239
|
-
2
|
|
240
|
-
</scale>
|
|
241
|
-
<heading>
|
|
242
|
-
1.5707963267948966
|
|
243
|
-
</heading>
|
|
244
|
-
<Icon>
|
|
245
|
-
<href>https://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
|
|
246
|
-
<gx:w>64</gx:w>
|
|
247
|
-
<gx:h>64</gx:h>
|
|
248
|
-
</Icon>
|
|
249
|
-
<hotSpot x="20" y="2" xunits="pixels" yunits="pixels"/>
|
|
250
|
-
</IconStyle>
|
|
251
|
-
</Style>
|
|
252
|
-
<ExtendedData>
|
|
253
|
-
<Data name="iconRotation">
|
|
254
|
-
<value>1.5707963267948966</value>
|
|
255
|
-
</Data>
|
|
256
|
-
<Data name="maxZoom">
|
|
257
|
-
<value>18.5</value>
|
|
258
|
-
</Data>
|
|
259
|
-
<Data name="minZoom">
|
|
260
|
-
<value>15</value>
|
|
261
|
-
</Data>
|
|
262
|
-
<Data name="pictureOptions">
|
|
263
|
-
<value>{"resolution":4,"defaultScale":0.5}</value>
|
|
264
|
-
</Data>
|
|
265
|
-
<Data name="zIndex">
|
|
266
|
-
<value>1</value>
|
|
267
|
-
</Data>
|
|
268
|
-
</ExtendedData>
|
|
269
|
-
<Point>
|
|
270
|
-
<coordinates>0,0,0</coordinates>
|
|
271
|
-
</Point>
|
|
272
|
-
</Placemark>
|
|
273
|
-
</Document>
|
|
274
|
-
</kml>
|
|
275
|
-
`;
|
|
276
|
-
const feats = KML.readFeatures(str);
|
|
277
|
-
const style = feats[0].getStyleFunction()(feats[0], 1);
|
|
278
|
-
expect(style.getZIndex()).toBe(1);
|
|
279
|
-
expect(style.getImage().getRotation()).toBe(1.5707963267948966);
|
|
280
|
-
expect(feats[0].get('pictureOptions')).toEqual({
|
|
281
|
-
resolution: 4,
|
|
282
|
-
defaultScale: 0.5,
|
|
283
|
-
});
|
|
284
|
-
expect(feats[0].get('maxZoom')).toEqual(18.5);
|
|
285
|
-
expect(feats[0].get('minZoom')).toEqual(15);
|
|
286
|
-
expectWriteResult(feats, str);
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
describe('writeDocumentCamera()', () => {
|
|
291
|
-
const str = `
|
|
292
|
-
<kml ${xmlns}>
|
|
293
|
-
<Document>
|
|
294
|
-
<name>
|
|
295
|
-
CamTest
|
|
296
|
-
</name>
|
|
297
|
-
</Document>
|
|
298
|
-
</kml>`;
|
|
299
|
-
|
|
300
|
-
const strWithCam = `<kml ${xmlns}>
|
|
301
|
-
<Document>
|
|
302
|
-
<name>
|
|
303
|
-
CamTest
|
|
304
|
-
</name>
|
|
305
|
-
<Camera xmlns="">
|
|
306
|
-
<Heading>
|
|
307
|
-
270
|
|
308
|
-
</Heading>
|
|
309
|
-
<Altitude>
|
|
310
|
-
300
|
|
311
|
-
</Altitude>
|
|
312
|
-
<Longitude>
|
|
313
|
-
5.8
|
|
314
|
-
</Longitude>
|
|
315
|
-
<Latitude>
|
|
316
|
-
41.6
|
|
317
|
-
</Latitude>
|
|
318
|
-
</Camera>
|
|
319
|
-
</Document>
|
|
320
|
-
</kml>`;
|
|
321
|
-
|
|
322
|
-
test('should insert the correct <Camera> tag.', () => {
|
|
323
|
-
const kmlWithKamera = KML.writeDocumentCamera(str, {
|
|
324
|
-
heading: 270,
|
|
325
|
-
altitude: 300,
|
|
326
|
-
longitude: 5.8,
|
|
327
|
-
latitude: 41.6,
|
|
328
|
-
});
|
|
329
|
-
expect(beautify(kmlWithKamera)).toEqual(beautify(strWithCam));
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
test('should remove the present <Camera> tag when called without cameraAttributes.', () => {
|
|
333
|
-
const kmlWithoutKamera = KML.writeDocumentCamera(strWithCam);
|
|
334
|
-
expect(beautify(kmlWithoutKamera)).toEqual(beautify(str));
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
});
|
package/src/utils/KMLFormat.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import OLKML from 'ol/format/KML';
|
|
2
|
-
import {
|
|
3
|
-
parse,
|
|
4
|
-
pushParseAndPop,
|
|
5
|
-
isDocument,
|
|
6
|
-
makeStructureNS,
|
|
7
|
-
makeObjectPropertySetter,
|
|
8
|
-
} from 'ol/xml';
|
|
9
|
-
import { extend, includes } from 'ol/array';
|
|
10
|
-
import { readDecimal, readString } from 'ol/format/xsd';
|
|
11
|
-
|
|
12
|
-
const NAMESPACE_URIS = [
|
|
13
|
-
null,
|
|
14
|
-
'http://earth.google.com/kml/2.0',
|
|
15
|
-
'http://earth.google.com/kml/2.1',
|
|
16
|
-
'http://earth.google.com/kml/2.2',
|
|
17
|
-
'http://www.opengis.net/kml/2.2',
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const CAMERA_PARSERS = makeStructureNS(NAMESPACE_URIS, {
|
|
21
|
-
Altitude: makeObjectPropertySetter(readDecimal),
|
|
22
|
-
Longitude: makeObjectPropertySetter(readDecimal),
|
|
23
|
-
Latitude: makeObjectPropertySetter(readDecimal),
|
|
24
|
-
Tilt: makeObjectPropertySetter(readDecimal),
|
|
25
|
-
AltitudeMode: makeObjectPropertySetter(readString),
|
|
26
|
-
Heading: makeObjectPropertySetter(readDecimal),
|
|
27
|
-
Roll: makeObjectPropertySetter(readDecimal),
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
class KML extends OLKML {
|
|
31
|
-
/**
|
|
32
|
-
* Read the cameras of the KML.
|
|
33
|
-
*
|
|
34
|
-
* @param {Document|Element|string} source Source.
|
|
35
|
-
* @return {Array<Object>} Cameras.
|
|
36
|
-
* @api
|
|
37
|
-
*/
|
|
38
|
-
readCamera(source) {
|
|
39
|
-
const cameras = [];
|
|
40
|
-
if (typeof source === 'string') {
|
|
41
|
-
const doc = parse(source);
|
|
42
|
-
extend(cameras, this.readCameraFromDocument(doc));
|
|
43
|
-
} else if (isDocument(source)) {
|
|
44
|
-
extend(
|
|
45
|
-
cameras,
|
|
46
|
-
this.readCameraFromDocument(/** @type {Document} */ (source)),
|
|
47
|
-
);
|
|
48
|
-
} else {
|
|
49
|
-
extend(cameras, this.readCameraFromNode(/** @type {Element} */ (source)));
|
|
50
|
-
}
|
|
51
|
-
return cameras;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @param {Document} doc Document.
|
|
56
|
-
* @return {Array<Object>} Cameras.
|
|
57
|
-
*/
|
|
58
|
-
readCameraFromDocument(doc) {
|
|
59
|
-
const cameras = [];
|
|
60
|
-
for (let n = /** @type {Node} */ (doc.firstChild); n; n = n.nextSibling) {
|
|
61
|
-
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
62
|
-
extend(cameras, this.readCameraFromNode(/** @type {Element} */ (n)));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return cameras;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @param {Element} node Node.
|
|
70
|
-
* @return {Array<Object>} Cameras.
|
|
71
|
-
* @api
|
|
72
|
-
*/
|
|
73
|
-
readCameraFromNode(node) {
|
|
74
|
-
const cameras = [];
|
|
75
|
-
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
|
76
|
-
if (
|
|
77
|
-
includes(NAMESPACE_URIS, n.namespaceURI) &&
|
|
78
|
-
n.localName === 'Camera'
|
|
79
|
-
) {
|
|
80
|
-
const obj = pushParseAndPop({}, CAMERA_PARSERS, n, []);
|
|
81
|
-
cameras.push(obj);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
for (let n = node.firstElementChild; n; n = n.nextElementSibling) {
|
|
85
|
-
const { localName } = n;
|
|
86
|
-
if (
|
|
87
|
-
includes(NAMESPACE_URIS, n.namespaceURI) &&
|
|
88
|
-
(localName === 'Document' ||
|
|
89
|
-
localName === 'Folder' ||
|
|
90
|
-
localName === 'Placemark' ||
|
|
91
|
-
localName === 'kml')
|
|
92
|
-
) {
|
|
93
|
-
extend(cameras, this.readCameraFromNode(n));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return cameras;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default KML;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import KML from './KMLFormat';
|
|
2
|
-
|
|
3
|
-
const xmlns =
|
|
4
|
-
'xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/kml/2.2 https://developers.google.com/kml/schema/kml22gx.xsd"';
|
|
5
|
-
|
|
6
|
-
describe('KML', () => {
|
|
7
|
-
test('should read <Camera> tags correctly.', () => {
|
|
8
|
-
const str = `
|
|
9
|
-
<kml ${xmlns}>
|
|
10
|
-
<Document>
|
|
11
|
-
<name>lala</name>
|
|
12
|
-
<Camera>
|
|
13
|
-
<Heading>
|
|
14
|
-
270
|
|
15
|
-
</Heading>
|
|
16
|
-
<Altitude>
|
|
17
|
-
300
|
|
18
|
-
</Altitude>
|
|
19
|
-
<Longitude>
|
|
20
|
-
5.8
|
|
21
|
-
</Longitude>
|
|
22
|
-
<Latitude>
|
|
23
|
-
41.6
|
|
24
|
-
</Latitude>
|
|
25
|
-
</Camera>
|
|
26
|
-
<Placemark>
|
|
27
|
-
<Camera>
|
|
28
|
-
<Heading>
|
|
29
|
-
180
|
|
30
|
-
</Heading>
|
|
31
|
-
<AltitudeMode>
|
|
32
|
-
clampToGround
|
|
33
|
-
</AltitudeMode>
|
|
34
|
-
</Camera>
|
|
35
|
-
</Placemark>
|
|
36
|
-
</Document>
|
|
37
|
-
</kml>
|
|
38
|
-
`;
|
|
39
|
-
const format = new KML();
|
|
40
|
-
const cameras = format.readCamera(str);
|
|
41
|
-
|
|
42
|
-
expect(cameras.length).toEqual(2);
|
|
43
|
-
expect(cameras[0].Heading).toEqual(270);
|
|
44
|
-
expect(cameras[0].Altitude).toEqual(300);
|
|
45
|
-
expect(cameras[0].Longitude).toEqual(5.8);
|
|
46
|
-
expect(cameras[0].Latitude).toEqual(41.6);
|
|
47
|
-
expect(cameras[1].Heading).toEqual(180);
|
|
48
|
-
expect(cameras[1].AltitudeMode).toEqual('clampToGround');
|
|
49
|
-
});
|
|
50
|
-
});
|
|
Binary file
|
|
Binary file
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import getPolygonPattern from './getPolygonPattern';
|
|
2
|
-
|
|
3
|
-
describe('getPolygonPattern()', () => {
|
|
4
|
-
test('render pattern with default properties (id=1, color = [235, 0, 0, 1])', () => {
|
|
5
|
-
const color = [235, 0, 0, 1];
|
|
6
|
-
const pattern = getPolygonPattern();
|
|
7
|
-
expect(pattern).toEqual(color);
|
|
8
|
-
expect(pattern.id).toBe();
|
|
9
|
-
expect(pattern.color).toBe();
|
|
10
|
-
expect(pattern.empty).toBe();
|
|
11
|
-
expect(pattern.canvas).toBe();
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
test('render pattern 0 (no fill) color and (light blue) opacity', () => {
|
|
15
|
-
const id = 0;
|
|
16
|
-
const color = [0, 60, 80, 0.41000000000000003];
|
|
17
|
-
const pattern = getPolygonPattern(id, [0, 60, 80, 0.41000000000000003]);
|
|
18
|
-
expect(pattern.id).toBe(id);
|
|
19
|
-
expect(pattern.color).toEqual(color);
|
|
20
|
-
expect(pattern.empty).toBe(true);
|
|
21
|
-
expect(pattern.canvas).toBe();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('render pattern 1 (full by color) color and (light blue) opacity', () => {
|
|
25
|
-
const id = 1;
|
|
26
|
-
const color = [0, 60, 80, 0.41000000000000003];
|
|
27
|
-
const pattern = getPolygonPattern(id, [0, 60, 80, 0.41000000000000003]);
|
|
28
|
-
expect(pattern).toEqual(color);
|
|
29
|
-
expect(pattern.id).toBe();
|
|
30
|
-
expect(pattern.color).toBe();
|
|
31
|
-
expect(pattern.empty).toBe();
|
|
32
|
-
expect(pattern.canvas).toBe();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('render pattern 2 (cross) color and (light blue) opacity', () => {
|
|
36
|
-
const id = 2;
|
|
37
|
-
const color = [0, 60, 80, 0.41000000000000003];
|
|
38
|
-
const pattern = getPolygonPattern(id, [0, 60, 80, 0.41000000000000003]);
|
|
39
|
-
expect(pattern.id).toBe(id);
|
|
40
|
-
expect(pattern.color).toEqual(color);
|
|
41
|
-
expect(pattern.empty).toBe();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('render pattern 3 (diagonal line from bottom-left tot top-right) with color (light blue) and opacity', () => {
|
|
45
|
-
const id = 3;
|
|
46
|
-
const color = [0, 60, 80, 0.41000000000000003];
|
|
47
|
-
const pattern = getPolygonPattern(id, [0, 60, 80, 0.41000000000000003]);
|
|
48
|
-
expect(pattern.id).toBe(id);
|
|
49
|
-
expect(pattern.color).toEqual(color);
|
|
50
|
-
expect(pattern.empty).toBe();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('render pattern 4 (diagonal line from top-left to bottom-right) with color (light blue) and opacity', () => {
|
|
54
|
-
const id = 4;
|
|
55
|
-
const color = [0, 60, 80, 0.41000000000000003];
|
|
56
|
-
const pattern = getPolygonPattern(id, [0, 60, 80, 0.41000000000000003]);
|
|
57
|
-
expect(pattern.id).toBe(id);
|
|
58
|
-
expect(pattern.color).toEqual(color);
|
|
59
|
-
expect(pattern.empty).toBe();
|
|
60
|
-
});
|
|
61
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { getHoursAndMinutes, getDelayString } from './timeUtils';
|
|
2
|
-
|
|
3
|
-
const RealDate = Date;
|
|
4
|
-
describe('timeUtils', () => {
|
|
5
|
-
beforeEach(() => {
|
|
6
|
-
global.Date = jest.fn(() => {
|
|
7
|
-
return {
|
|
8
|
-
getHours: () => {
|
|
9
|
-
return 0;
|
|
10
|
-
},
|
|
11
|
-
getMinutes: () => {
|
|
12
|
-
return 2;
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
});
|
|
16
|
-
Object.assign(Date, RealDate);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
global.Date = RealDate;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('getHoursAndMinutes should be correct.', () => {
|
|
24
|
-
expect(getHoursAndMinutes(123456)).toBe('00:02');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('getDelayString should be correct.', () => {
|
|
28
|
-
expect(getDelayString(123456)).toBe('2m3s');
|
|
29
|
-
});
|
|
30
|
-
});
|