Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private static SegmentPosition getSegmentPosition(
// Avoid worst case distance == 0
if (distance.equals(BigDecimal.ZERO)) {
return new SegmentPosition(segments.getFirst().segment,
segments.getFirst().startDistance);
BigDecimal.ZERO);
}

// Avoid worst case distance == segment length
Expand All @@ -248,7 +248,7 @@ private static SegmentPosition getSegmentPosition(
RoundingMode.HALF_UP);
if (diff.compareTo(BigDecimal.ZERO) == 0) {
return new SegmentPosition(segments.getLast().segment,
segments.getLast().startDistance);
distance.subtract(segments.getLast().startDistance));
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.text.StringSubstitutor;
import org.eclipse.emf.ecore.EObject;
Expand Down Expand Up @@ -151,26 +154,34 @@ public GEO_Kante getGeoKante() {

private List<GEOKanteMetadata> alreadyFoundMetaData;

private List<TOP_Kante> topKanteWithInvalidCRS;

@Activate
void active() {
topologicalCoordinates = Optional.empty();
alreadyFoundMetaData = new ArrayList<>();
topKanteWithInvalidCRS = new ArrayList<>();
}

@Override
public void handleEvent(final Event event) {
if (event.getTopic().equals(Events.CLOSE_SESSION)) {
alreadyFoundMetaData.clear();
topologicalCoordinates = Optional.empty();
return;
topKanteWithInvalidCRS.clear();
}
}

@Override
protected List<PlazError> run(
final MultiContainer_AttributeGroup container) {
final List<PlazError> result = new ArrayList<>();
getRelevantPOs(container)
getTopKanteWithDifferentCRS(container);
getRelevantPOs(container).stream()
.filter(po -> PunktObjektExtensions.getTopKanten(po)
.stream()
.noneMatch(topKante -> topKanteWithInvalidCRS.stream()
.anyMatch(t -> t.equals(topKante))))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is irrelevant, when the TOP_Kante contains more than one CRS or CRS is sontiges, therefore skip the PointObject, which belong to this TOP_Kanten

.forEach(po -> po.getPunktObjektTOPKante().forEach(potk -> {
if (isNotDistinctCoordinateSystem(potk)) {
result.add(createGeoCoordinateError(po,
Expand Down Expand Up @@ -201,6 +212,33 @@ protected List<PlazError> run(
return result;
}

private void getTopKanteWithDifferentCRS(
final MultiContainer_AttributeGroup container) {
Streams.stream(container.getTOPKante()).forEach(topKante -> {
final Set<ENUMGEOKoordinatensystem> topKanteCrs = TopKanteExtensions
.getGeoKanten(topKante)
.stream()
.flatMap(geoKante -> Stream.of(
GeoKanteExtensions.getGeoKnotenA(geoKante),
GeoKanteExtensions.getGeoKnotenB(geoKante)))
.flatMap(geoKnoten -> Streams.stream(
GeoKnotenExtensions.getGeoPunkte(geoKnoten)))
.map(geoPunkt -> EObjectExtensions
.getNullableObject(geoPunkt,
g -> g.getGEOPunktAllg()
.getGEOKoordinatensystem()
.getWert())
.orElse(null))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
if (topKanteCrs.size() > 1 || topKanteCrs.stream()
.anyMatch(
crs -> crs == ENUMGEOKoordinatensystem.ENUMGEO_KOORDINATENSYSTEM_SONSTIGE)) {
topKanteWithInvalidCRS.add(topKante);
}
});
}

private PlazError validGeoCoordinate(final Punkt_Objekt po,
final Punkt_Objekt_TOP_Kante_AttributeGroup potk,
final GEOKanteCoordinate topCoordinate) {
Expand Down
Loading