@@ -7,10 +7,11 @@ import {
77} from '@angular/core' ;
88import { Feature } from 'ol' ;
99import { Style , Stroke , Fill , Circle , RegularShape } from 'ol/style' ;
10- import { LineString , Point } from 'ol/geom' ;
10+ import { LineString , MultiLineString , Point } from 'ol/geom' ;
1111import { toLonLat } from 'ol/proj' ;
1212import { MapComponent } from '../map.component' ;
13- import { fromLonLatArray , mapifyCoords } from '../util' ;
13+ import { Coordinate } from '../models' ;
14+ import { fromLonLatArray , splitAtAntimeridian } from '../util' ;
1415import { getRhumbLineBearing } from 'geolib' ;
1516import { GeolibInputCoordinates } from 'geolib/es/types' ;
1617import { FBFeatureLayerComponent } from '../sk-feature.component' ;
@@ -62,15 +63,24 @@ export class FreeboardRouteLayerComponent extends FBFeatureLayerComponent {
6263 for ( const r of routes ) {
6364 if ( r [ 2 ] ) {
6465 // selected
65- const mc = mapifyCoords ( r [ 1 ] . feature . geometry . coordinates ) ;
66- const c = fromLonLatArray ( mc ) ;
66+ const rawCoords = r [ 1 ] . feature . geometry . coordinates ;
67+ // Split at antimeridian so each segment stays within [-180,180] and
68+ // OL wrapX clones the feature correctly into all world copies.
69+ const multiCoords = splitAtAntimeridian ( rawCoords ) . map (
70+ ( seg ) => fromLonLatArray ( seg ) as Coordinate [ ]
71+ ) ;
6772 const f = new Feature ( {
68- geometry : new LineString ( c ) ,
73+ geometry : new MultiLineString ( multiCoords ) ,
6974 name : r [ 1 ] . name
7075 } ) ;
7176 f . setId ( 'route.' + r [ 0 ] ) ;
7277 f . set ( 'pointMetadata' , r [ 1 ] . feature . properties . coordinatesMeta ?? null ) ;
73- f . setStyle ( this . buildStyle ( f ) ) ;
78+ // Use original waypoints (not split) for point-marker iteration so
79+ // markers land exactly on waypoints within the standard world extent.
80+ const waypointLine = new LineString (
81+ fromLonLatArray ( rawCoords ) as Coordinate [ ]
82+ ) ;
83+ f . setStyle ( this . buildStyle ( f , waypointLine ) ) ;
7484 fa . push ( f ) ;
7585 }
7686 }
@@ -79,8 +89,8 @@ export class FreeboardRouteLayerComponent extends FBFeatureLayerComponent {
7989 }
8090
8191 // Route style function
82- buildStyle ( feature : Feature ) {
83- const geometry = feature . getGeometry ( ) as LineString ;
92+ buildStyle ( feature : Feature , lineGeom ?: LineString ) {
93+ const geometry = lineGeom ?? ( feature . getGeometry ( ) as LineString ) ;
8494 const styles = [ ] ;
8595 const id = ( feature . getId ( ) as string ) . split ( '.' ) . slice ( - 1 ) [ 0 ] ;
8696 const isActive = id === this . activeRoute ;
0 commit comments