Package: GeoTrackSupport
GeoTrackSupport
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
computeBoundingArea() |
|
|
|
|
|
||||||||||||||||||||
findChildren() |
|
|
|
|
|
||||||||||||||||||||
findSegments() |
|
|
|
|
|
||||||||||||||||||||
getBoundingArea() |
|
|
|
|
|
||||||||||||||||||||
lambda$computeBoundingArea$0(GeoTrackSegment) |
|
|
|
|
|
Coverage
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.geo.spi;
27:
28: import jakarta.annotation.Nonnull;
29: import java.util.List;
30: import it.tidalwave.dam.model.spi.EntitySupport;
31: import it.tidalwave.geo.Area;
32: import it.tidalwave.geo.GeoTrack;
33: import it.tidalwave.geo.GeoTrackSegment;
34: import it.tidalwave.geo.RectangularArea;
35: import it.tidalwave.util.Finder;
36: import it.tidalwave.util.LazySupplier;
37: import it.tidalwave.role.SimpleComposite;
38: import lombok.Getter;
39: import lombok.RequiredArgsConstructor;
40: import lombok.ToString;
41: import static lombok.AccessLevel.PROTECTED;
42:
43: /***************************************************************************************************************************************************************
44: *
45: * @author Fabrizio Giudici
46: *
47: **************************************************************************************************************************************************************/
48: @RequiredArgsConstructor(access = PROTECTED) @ToString(of="displayName")
49: public abstract class GeoTrackSupport<T> extends EntitySupport implements GeoTrack, SimpleComposite<GeoTrackSegment>
50: {
51: @Nonnull
52: protected final LazySupplier<T> delegateSupplier;
53:
54: @Nonnull @Getter
55: protected final String displayName;
56:
57: @Nonnull @SuppressWarnings("this-escape")
58: protected final LazySupplier<RectangularArea> boundingAreaSupplier = LazySupplier.of(this::computeBoundingArea);
59:
60: /***********************************************************************************************************************************************************
61: * {@inheritDoc}
62: **********************************************************************************************************************************************************/
63: @Override @Nonnull @SuppressWarnings("this-escape")
64: public Finder<GeoTrackSegment> findSegments()
65: {
66: return Finder.ofSupplier(this::getSegments);
67: }
68:
69: /***********************************************************************************************************************************************************
70: * {@inheritDoc}
71: **********************************************************************************************************************************************************/
72: @Override @Nonnull
73: public Finder<GeoTrackSegment> findChildren()
74: {
75: return findSegments();
76: }
77:
78: /***********************************************************************************************************************************************************
79: * {@inheritDoc}
80: **********************************************************************************************************************************************************/
81: @Nonnull
82: public RectangularArea getBoundingArea()
83: {
84: return boundingAreaSupplier.get();
85: }
86:
87: /***********************************************************************************************************************************************************
88: *
89: **********************************************************************************************************************************************************/
90: @Nonnull
91: protected abstract List<GeoTrackSegment> getSegments();
92:
93: /***********************************************************************************************************************************************************
94: *
95: **********************************************************************************************************************************************************/
96: @Nonnull
97: protected RectangularArea computeBoundingArea()
98: {
99: return findSegments().stream()
100: .parallel()
101: .flatMap(segment -> segment.findTrackPoints().stream())
102: .reduce(Area.emptyRectangularArea(), RectangularArea::including, RectangularArea::including);
103: }
104: }