Skip to content

Commit 0aa4ba4

Browse files
committed
Run prettier
1 parent 09866b1 commit 0aa4ba4

32 files changed

+733
-618
lines changed

demos/schm/demo.js

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
1-
21
import TrackManager from '../../src/interaction/TrackManager';
32
import GraphHopperRouter from '../../src/router/GraphHopper';
4-
import {ExtractFromSegmentProfiler, FallbackProfiler, SwisstopoProfiler} from '../../src/profiler/index';
3+
import {
4+
ExtractFromSegmentProfiler,
5+
FallbackProfiler,
6+
SwisstopoProfiler,
7+
} from '../../src/profiler/index';
58
import Profile from '../../src/Profile';
69
import {styleFunction} from './style';
710
import {Style, Circle, Fill} from 'ol/style';
811
import {createMap} from './swisstopo';
912
import {getTrack, getPOIs} from './track';
1013
import {click} from 'ol/events/condition';
1114

12-
const ROUTING_URL = 'https://graphhopper-all.schweizmobil.ch/route?vehicle=schmwander&type=json&weighting=fastest&elevation=true&way_point_max_distance=0&instructions=false&points_encoded=true';
13-
15+
const ROUTING_URL =
16+
'https://graphhopper-all.schweizmobil.ch/route?vehicle=schmwander&type=json&weighting=fastest&elevation=true&way_point_max_distance=0&instructions=false&points_encoded=true';
1417

1518
async function main() {
16-
1719
const {map, trackLayer, shadowTrackLayer} = createMap('map');
1820

1921
const projection = map.getView().getProjection();
2022
const router = new GraphHopperRouter({
2123
url: ROUTING_URL,
22-
mapProjection: projection
24+
mapProjection: projection,
2325
});
2426

2527
const profiler = new FallbackProfiler({
2628
profilers: [
2729
new ExtractFromSegmentProfiler(),
2830
new SwisstopoProfiler({
29-
projection: projection
30-
})
31-
]
31+
projection: projection,
32+
}),
33+
],
3234
});
3335

3436
/**
3537
* @param {MapBrowserEvent} mapBrowserEvent
3638
* @param {string} pointType
3739
* @return {boolean}
3840
*/
39-
const deleteCondition = function(mapBrowserEvent, pointType) {
41+
const deleteCondition = function (mapBrowserEvent, pointType) {
4042
return click(mapBrowserEvent) && pointType !== 'POI';
4143
};
4244

@@ -54,8 +56,8 @@ async function main() {
5456
const trackId = search.get('trackId');
5557
if (trackId) {
5658
trackManager.restoreFeatures([
57-
...await getTrack(trackId, projection),
58-
...await getPOIs(trackId, projection),
59+
...(await getTrack(trackId, projection)),
60+
...(await getPOIs(trackId, projection)),
5961
]);
6062
map.getView().fit(trackLayer.getSource().getExtent(), {
6163
padding: [50, 50, 50, 50],
@@ -70,7 +72,6 @@ async function main() {
7072
profileTarget: '#profile',
7173
});
7274

73-
7475
trackManager.addTrackChangeEventListener(() => {
7576
const segments = trackManager.getSegments();
7677
d3Profile.refreshProfile(segments);
@@ -86,10 +87,13 @@ async function main() {
8687

8788
trackManager.mode = 'edit';
8889
const tmEl = document.querySelector('#trackmode');
89-
tmEl.addEventListener('change', evt => trackManager.mode = evt.target.value);
90+
tmEl.addEventListener(
91+
'change',
92+
(evt) => (trackManager.mode = evt.target.value)
93+
);
9094

9195
document.querySelector('#snap').addEventListener('click', () => {
92-
trackManager.snapping = ! trackManager.snapping;
96+
trackManager.snapping = !trackManager.snapping;
9397
});
9498
document.querySelector('#delete').addEventListener('click', () => {
9599
trackManager.deleteLastPoint();
@@ -98,28 +102,34 @@ async function main() {
98102
trackManager.clear();
99103
});
100104

101-
document.querySelector('#undo').addEventListener('click', () => trackManager.undo());
102-
document.querySelector('#redo').addEventListener('click', () => trackManager.redo());
105+
document
106+
.querySelector('#undo')
107+
.addEventListener('click', () => trackManager.undo());
108+
document
109+
.querySelector('#redo')
110+
.addEventListener('click', () => trackManager.redo());
103111
document.querySelector('#getTrackData').addEventListener('click', () => {
104112
trackManager.getTrackFeature();
105113
const features = [
106114
...trackManager.getControlPoints(),
107-
...trackManager.getSegments()
115+
...trackManager.getSegments(),
108116
];
109-
trackManager.restoreFeatures(features)
117+
trackManager.restoreFeatures(features);
110118
});
111119
document.querySelector('#reverse').addEventListener('click', () => {
112120
trackManager.reverse();
113121
});
114122

115-
d3Profile.setTrackHoverStyle(new Style({
116-
image: new Circle({
117-
fill: new Fill({
118-
color: 'blue',
123+
d3Profile.setTrackHoverStyle(
124+
new Style({
125+
image: new Circle({
126+
fill: new Fill({
127+
color: 'blue',
128+
}),
129+
radius: 9,
119130
}),
120-
radius: 9
121131
})
122-
}));
132+
);
123133
}
124134

125135
main();

demos/schm/schm.html

Lines changed: 57 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,61 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
<head>
4+
<title>Edit track demo</title>
5+
<meta charset="UTF-8" />
6+
<link
7+
rel="stylesheet"
8+
href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/7.3.0/ol.css"
9+
integrity="sha512-wMgv53RaFRJEYY55kgTe9rv1s3A75Ph6q8N42gB6SqupPnIQveEO00rpsC+v/g66hDZ8YRbnB/R8MySKSG6tZg=="
10+
crossorigin="anonymous"
11+
referrerpolicy="no-referrer"
12+
/>
13+
<script src="./demo.js" type="module"></script>
14+
<style>
15+
html,
16+
body,
17+
main {
18+
height: 100%;
19+
margin: 0;
20+
}
21+
main {
22+
display: flex;
23+
}
24+
#map {
25+
height: 100vh;
26+
width: 100%;
27+
}
28+
#profile {
29+
height: 150px;
30+
width: 300px;
31+
}
32+
</style>
33+
</head>
334

4-
<head>
5-
<title>Edit track demo</title>
6-
<meta charset="UTF-8">
7-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/openlayers/7.3.0/ol.css" integrity="sha512-wMgv53RaFRJEYY55kgTe9rv1s3A75Ph6q8N42gB6SqupPnIQveEO00rpsC+v/g66hDZ8YRbnB/R8MySKSG6tZg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
8-
<script src="./demo.js" type="module"></script>
9-
<style>
10-
html, body, main {
11-
height: 100%;
12-
margin: 0;
13-
}
14-
main {
15-
display: flex;
16-
}
17-
#map {
18-
height: 100vh;
19-
width: 100%;
20-
}
21-
#profile {
22-
height: 150px;
23-
width: 300px;
24-
}
25-
</style>
26-
</head>
27-
28-
<body>
29-
<main>
30-
<div>
31-
<div id="profile"></div>
32-
<select id="trackmode">
33-
<option value="edit">edit</option>
34-
<option value="">view</option>
35-
</select>
36-
<br />
37-
<a href="#" id="snap">Snap</a>
38-
<br />
39-
<a href="#" id="delete">delete last point</a>
40-
<br />
41-
<a href="#" id="undo">Undo</a>
42-
<br />
43-
<a href="#" id="redo">Redo</a>
44-
<br />
45-
<a href="#" id="clear">clear track</a>
46-
<br />
47-
<a href="#" id="getTrackData">save & restore</a>
48-
<br />
49-
<a href="#" id="reverse">reverse</a>
50-
</div>
51-
<div id="map"></div>
52-
</main>
53-
</body>
54-
35+
<body>
36+
<main>
37+
<div>
38+
<div id="profile"></div>
39+
<select id="trackmode">
40+
<option value="edit">edit</option>
41+
<option value="">view</option>
42+
</select>
43+
<br />
44+
<a href="#" id="snap">Snap</a>
45+
<br />
46+
<a href="#" id="delete">delete last point</a>
47+
<br />
48+
<a href="#" id="undo">Undo</a>
49+
<br />
50+
<a href="#" id="redo">Redo</a>
51+
<br />
52+
<a href="#" id="clear">clear track</a>
53+
<br />
54+
<a href="#" id="getTrackData">save & restore</a>
55+
<br />
56+
<a href="#" id="reverse">reverse</a>
57+
</div>
58+
<div id="map"></div>
59+
</main>
60+
</body>
5561
</html>

demos/schm/shadowtrack.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ import {Style, Stroke} from 'ol/style';
22
import VectorSource from 'ol/source/Vector.js';
33
import VectorLayer from 'ol/layer/Vector.js';
44

5-
65
/**
76
* @type {Style}
87
*/
9-
export const style = new Style({
8+
export const style = new Style({
109
stroke: new Stroke({
1110
color: '#00cc33aa',
12-
width: 6
13-
})
11+
width: 6,
12+
}),
1413
});
1514

1615
/**

demos/schm/style.js

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { Fill, Stroke, Style, Icon, Text, RegularShape } from "ol/style";
2-
import { toString } from "ol/color";
1+
import {Fill, Stroke, Style, Icon, Text, RegularShape} from 'ol/style';
2+
import {toString} from 'ol/color';
33

44
const color = [227, 6, 19];
55
const lightColor = [...color, 0.6];
66

77
const poiSvg = `
88
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="33">
9-
<path d="M10 0C5 0 .5 3 .5 9c0 4 9.5 24 9.5 24s9.5-20 9.5-24c0-6-4.5-9-9.5-9z" fill="${toString(color)}"/>
9+
<path d="M10 0C5 0 .5 3 .5 9c0 4 9.5 24 9.5 24s9.5-20 9.5-24c0-6-4.5-9-9.5-9z" fill="${toString(
10+
color
11+
)}"/>
1012
</svg>
1113
`;
1214

@@ -25,7 +27,7 @@ export const controlPoint = new Style({
2527
}),
2628
text: new Text({
2729
fill: new Fill({
28-
color: "#fff",
30+
color: '#fff',
2931
}),
3032
}),
3133
});
@@ -35,10 +37,10 @@ export const sketchControlPoint = controlPoint.clone();
3537
export const numberedControlPoint = controlPoint.clone();
3638

3739
export const firstControlPoint = controlPoint.clone();
38-
firstControlPoint.getText().setText("A");
40+
firstControlPoint.getText().setText('A');
3941

4042
export const lastControlPoint = controlPoint.clone();
41-
lastControlPoint.getText().setText("B");
43+
lastControlPoint.getText().setText('B');
4244

4345
export const poiPoint = new Style({
4446
zIndex: 100,
@@ -51,35 +53,35 @@ export const poiPoint = new Style({
5153
const sketchLabel = {
5254
POI: new Style({
5355
text: new Text({
54-
font: "20px sans-serif",
56+
font: '20px sans-serif',
5557
offsetX: 20,
56-
textAlign: "left",
58+
textAlign: 'left',
5759
backgroundFill: new Fill({
58-
color: "#ffffffaa",
60+
color: '#ffffffaa',
5961
}),
60-
text: "drag to move POI",
62+
text: 'drag to move POI',
6163
}),
6264
}),
6365
cp: new Style({
6466
text: new Text({
65-
font: "20px sans-serif",
67+
font: '20px sans-serif',
6668
offsetX: 20,
67-
textAlign: "left",
69+
textAlign: 'left',
6870
backgroundFill: new Fill({
69-
color: "#ffffffaa",
71+
color: '#ffffffaa',
7072
}),
71-
text: "click to delete\ndrag to move point",
73+
text: 'click to delete\ndrag to move point',
7274
}),
7375
}),
7476
segment: new Style({
7577
text: new Text({
7678
backgroundFill: new Fill({
77-
color: "#ffffffaa",
79+
color: '#ffffffaa',
7880
}),
7981
offsetX: 20,
80-
textAlign: "left",
81-
font: "20px sans-serif",
82-
text: "drag to create point",
82+
textAlign: 'left',
83+
font: '20px sans-serif',
84+
text: 'drag to create point',
8385
}),
8486
}),
8587
};
@@ -101,24 +103,24 @@ trackLineModifying.getStroke().setLineDash([1, 12]);
101103
* @return {?Style}
102104
*/
103105
export function styleFunction(feature, _) {
104-
const type = feature.get("type");
105-
const subtype = feature.get("subtype");
106-
const index = feature.get("index");
106+
const type = feature.get('type');
107+
const subtype = feature.get('subtype');
108+
const index = feature.get('index');
107109

108110
switch (type) {
109-
case "sketch": {
111+
case 'sketch': {
110112
if (subtype) {
111113
return [sketchControlPoint, sketchLabel[subtype]];
112114
}
113115
return sketchControlPoint;
114116
}
115-
case "POI":
117+
case 'POI':
116118
return poiPoint;
117-
case "controlPoint":
119+
case 'controlPoint':
118120
switch (subtype) {
119-
case "first":
121+
case 'first':
120122
return firstControlPoint;
121-
case "last":
123+
case 'last':
122124
return lastControlPoint;
123125
default:
124126
if (index !== undefined) {
@@ -127,9 +129,9 @@ export function styleFunction(feature, _) {
127129
}
128130
return controlPoint;
129131
}
130-
case "segment":
132+
case 'segment':
131133
switch (subtype) {
132-
case "modifying":
134+
case 'modifying':
133135
return trackLineModifying;
134136
default:
135137
return trackLine;

0 commit comments

Comments
 (0)