Skip to contentMethod: lambda$accept$1(MapView.OverlayHelper, GeoTrackPoint)
1: /*
2: * *************************************************************************************************************************************************************
3: *
4: * blueMarine III: Semantic DAM
5: * http://tidalwave.it/projects/bluemarine3
6: *
7: * Copyright (C) 2024 - 2025 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *************************************************************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
12: * You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17: * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
18: *
19: * *************************************************************************************************************************************************************
20: *
21: * git clone https://bitbucket.org/tidalwave/bluemarine3-src
22: * git clone https://github.com/tidalwave-it/bluemarine3-src
23: *
24: * *************************************************************************************************************************************************************
25: */
26: package it.tidalwave.bluemarine3.mapviewer.impl.javafx;
27:
28: import jakarta.annotation.Nonnull;
29: import java.util.function.Consumer;
30: import javafx.scene.Node;
31: import javafx.scene.paint.Color;
32: import javafx.scene.shape.Circle;
33: import it.tidalwave.geo.GeoTrack;
34: import it.tidalwave.geo.GeoTrackPoint;
35: import it.tidalwave.mapviewer.javafx.MapView;
36: import lombok.RequiredArgsConstructor;
37: import lombok.extern.slf4j.Slf4j;
38: import static it.tidalwave.bluemarine3.mapviewer.impl.javafx.Converters.toMapCoordinates;
39:
40: /***************************************************************************************************************************************************************
41: *
42: * The creator of the track overlay.
43: *
44: * @author Fabrizio Giudici
45: *
46: **************************************************************************************************************************************************************/
47: @RequiredArgsConstructor @Slf4j
48: public class TrackOverlayCreator implements Consumer<MapView.OverlayHelper>
49: {
50: @Nonnull
51: private final GeoTrack track;
52:
53: /***********************************************************************************************************************************************************
54: * {@inheritDoc}
55: **********************************************************************************************************************************************************/
56: @Override
57: public void accept (@Nonnull final MapView.OverlayHelper helper)
58: {
59: log.debug("drawing track...");
60: final var start = System.currentTimeMillis();
61: helper.addAll(track.findSegments()
62: .stream()
63: .parallel()
64: .flatMap(s -> s.findTrackPoints().stream())
65: .map(p -> createNode(helper, p))
66: .toList());
67: log.debug(">>>> track drawn in {} msec", System.currentTimeMillis() - start);
68: }
69:
70: /***********************************************************************************************************************************************************
71: *
72: **********************************************************************************************************************************************************/
73: @Nonnull
74: private static Node createNode (@Nonnull final MapView.OverlayHelper helper, @Nonnull final GeoTrackPoint point)
75: {
76: final var mapPoint = helper.toMapViewPoint(toMapCoordinates(point));
77: final var node = new Circle(2.5, Color.RED); // TODO: point.maybeAs(_TrackPointRenderable_).orElse(...)
78: node.setVisible(true);
79: node.setTranslateX(mapPoint.x());
80: node.setTranslateY(mapPoint.y());
81: return node;
82: }
83: }