Skip to content

Commit

Permalink
Filter station without label (eclipse-set#1268)
Browse files Browse the repository at this point in the history
  • Loading branch information
TruongQuangSB authored Jan 21, 2025
1 parent 75bb263 commit 3110dc8
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions web/siteplan/src/feature/StationFeature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default class StationFeature extends LageplanFeature<Station> {
}

getFeatures (model: SiteplanState): Feature<Geometry>[] {
return this.getObjectsModel(model).map(element => this.createStationFeature(element))
return this.getObjectsModel(model).filter(element => element.label?.text)
.map(element => this.createStationFeature(element))
}

private createStationFeature (station: Station): Feature<Geometry> {
Expand All @@ -51,30 +52,28 @@ export default class StationFeature extends LageplanFeature<Station> {
new Point(position),
station.label?.text
)
if (station.label?.text) {
feature.setStyle((_, resolution) => {
const baseResolution = this.map.getView().getResolutionForZoom(this.svgService.getBaseZoomLevel())
const scale = baseResolution / resolution
let textRotation = avgRotation
if (isLabelFlipRequired(textRotation - 90, this.map)) {
textRotation += 180
}

return new Style({
text: new Text({
text: 'Bstg ' + station.label.text,
scale: scale * 3,
rotateWithView: true,
rotation: textRotation * Math.PI / 180,
textAlign: 'center',
fill: new Fill({
color: getLabelColor(station) ?? 'black'
})
feature.setStyle((_, resolution) => {
const baseResolution = this.map.getView().getResolutionForZoom(this.svgService.getBaseZoomLevel())
const scale = baseResolution / resolution
let textRotation = avgRotation
if (isLabelFlipRequired(textRotation - 90, this.map)) {
textRotation += 180
}

return new Style({
text: new Text({
text: 'Bstg ' + station.label?.text,
scale: scale * 3,
rotateWithView: true,
rotation: textRotation * Math.PI / 180,
textAlign: 'center',
fill: new Fill({
color: getLabelColor(station) ?? 'black'
})
})
})
}
})

return feature
}

Expand Down

0 comments on commit 3110dc8

Please sign in to comment.