@Override public boolean equals(final Object other) { if (other instanceof PolyLineRoute) { return ((PolyLineRoute) other).asPolyLine().equals(this.asPolyLine()); } return false; }
@Test public void testEqualsShape() { final PolyLine polyLine1 = PolyLine .wkt("LINESTRING (10.5553105 48.3419094, 10.5552096 48.3417501, 10.5551312 48.3416583, " + "10.5551027 48.341611, 10.5550183 48.3415143, 10.5549357 48.3414668, " + "10.5548325 48.3414164, 10.5548105 48.3415201, 10.5548015 48.3415686, " + "10.5548925 48.3416166, 10.5550334 48.3416375, 10.5551312 48.3416583)"); final PolyLine polyLine2 = PolyLine .wkt("LINESTRING (10.5551312 48.3416583, 10.5551027 48.341611, 10.5550183 48.3415143, " + "10.5549357 48.3414668, 10.5548325 48.3414164, 10.5548105 48.3415201, " + "10.5548015 48.3415686, 10.5548925 48.3416166, 10.5550334 48.3416375, " + "10.5551312 48.3416583, 10.5552096 48.3417501, 10.5553105 48.3419094)"); Assert.assertFalse(polyLine1.equals(polyLine2)); Assert.assertTrue(polyLine1.equalsShape(polyLine2)); }
/** * Compare edges that have the same identifier. If two edges have the same identifier, but do * not share the same geometry, that means we have inconsistent edges * * @param edgesPerEdgeIdentifier * A mapping from edge identifiers to list of edges for that identifier * @return Indicator whether we have inconsistent edges or not */ private boolean hasInconsistentEdges(final MultiMap<Long, Edge> edgesPerEdgeIdentifier) { for (final List<Edge> edgeListForSameIdentifier : edgesPerEdgeIdentifier.values()) { // Use first edge as reference final Edge referenceEdge = edgeListForSameIdentifier.get(0); final PolyLine referenceGeometry = referenceEdge.asPolyLine(); // Go through edges // These edges have the same id, but they come from different sub atlases // If they are equal, that implies consistency issues for (int i = 1; i < edgeListForSameIdentifier.size(); i++) { final PolyLine similarGeometry = edgeListForSameIdentifier.get(i).asPolyLine(); if (!referenceGeometry.equals(similarGeometry)) { return true; } } } return false; }
private boolean differentLines(final Line baseLine, final Line alterLine) { try { if (!baseLine.asPolyLine().equals(alterLine.asPolyLine())) { return true; } return false; } catch (final Exception e) { throw new CoreException("Unable to compare line geometries for {} and {}", baseLine, alterLine, e); } }
@Override public boolean equals(final Object other) { if (other instanceof SnappedLocation) { return this.origin.equals(((SnappedLocation) other).getOrigin()) && this.target.equals(((SnappedLocation) other).getTarget()); } if (other instanceof Location) { return super.equals(other); } return false; }
public static Optional<FeatureChange> getLineChangeIfNecessary(final Line beforeLine, final Line afterLine) { try { boolean featureChangeWouldBeUseful = false; final CompleteLine bloatedLine = CompleteLine.shallowFrom(afterLine); if (!beforeLine.asPolyLine().equals(afterLine.asPolyLine())) { bloatedLine.withPolyLine(afterLine.asPolyLine()); featureChangeWouldBeUseful = true; } if (featureChangeWouldBeUseful) { return Optional.of(new FeatureChange(ChangeType.ADD, bloatedLine)); } } catch (final Exception exception) { throw new CoreException("Unable to compare lines {} and {}", beforeLine, afterLine, exception); } return Optional.empty(); }
private void validateEdgePolyLinesMatch(final Edge forwardEdge, final Edge backwardEdge) { final BiPredicate<PolyLine, PolyLine> equal = (left, right) -> left .equals(right.reversed()); final long forwardEdgeIdentifier = forwardEdge.getIdentifier(); final PolyLine forwardPolyLine = forwardEdge.asPolyLine(); final PolyLine backwardPolyLine = backwardEdge.asPolyLine(); if (differ(forwardPolyLine, backwardPolyLine, equal)) { throw new CoreException( "Forward edge {} polyline {} does not match its backward edge polyline {}", forwardEdgeIdentifier, forwardPolyLine, backwardPolyLine); } } }
protected void validateReverseEdgePolyLineUpdated() { for (final Edge edge : this.atlas .edges(edge -> edge.hasReverseEdge() && edge.isMasterEdge())) { final Edge reversed = edge.reversed().orElseThrow(() -> new CoreException( "Edge {} should have a reverse, but does not.", edge.getIdentifier())); final PolyLine forward = edge.asPolyLine(); final PolyLine backward = reversed.asPolyLine(); if (!forward.equals(backward.reversed())) { throw new CoreException( "Edge {} and its reverse {} have mismatching PolyLines: Forward = {}, Backward = {}", edge.getIdentifier(), reversed.getIdentifier(), forward, backward); } } } }
@Test public void testTruncatingWithZeroIndices() { final PolyLine line = new PolyLine(Location.CROSSING_85_280, Location.TEST_1); final Iterable<Location> truncated = line.truncate(0, 0); Assert.assertTrue(new PolyLine(truncated).equals(line)); }
@Test public void testTruncatingFromStart() { final PolyLine line = new PolyLine(Location.CROSSING_85_280, Location.TEST_1); final Iterable<Location> truncated = line.truncate(1, 0); Assert.assertTrue(new PolyLine(truncated).equals(new PolyLine(Location.TEST_1))); }
@Test public void testTruncatingFromBothSides() { final PolyLine line = new PolyLine(Location.CROSSING_85_280, Location.TEST_1, Location.TEST_2); final Iterable<Location> truncated = line.truncate(1, 1); Assert.assertTrue(new PolyLine(truncated).equals(new PolyLine(Location.TEST_1))); }
@Test public void testTruncatingFromEnd() { final PolyLine line = new PolyLine(Location.CROSSING_85_280, Location.TEST_1); final Iterable<Location> truncated = line.truncate(0, 1); Assert.assertTrue(new PolyLine(truncated).equals(new PolyLine(Location.CROSSING_85_280))); }
if (!thisPolyLine.equals(thatPolyLine))
@Test public void testSinglePointConversion() { final Location location = Location.TEST_1; final PolyLine polyline = new PolyLine(location); final byte[] wkb = new WkbPolyLineConverter().convert(polyline); final PolyLine polylineConverted = new WkbPolyLineConverter().backwardConvert(wkb); Assert.assertTrue("Input/output PolyLine must be the same", polyline.equals(polylineConverted)); }
private boolean differentEdges(final Edge baseEdge, final Edge alterEdge) { try { boolean result = false; if (!baseEdge.asPolyLine().equals(alterEdge.asPolyLine())) { result = true; } if (!result && baseEdge.start().getIdentifier() != alterEdge.start().getIdentifier()) { result = true; } if (!result && baseEdge.end().getIdentifier() != alterEdge.end().getIdentifier()) { result = true; } if (result) { // Make sure that there is not way to find a match with the other polylines result = !hasGoodMatch(baseEdge, alterEdge.getAtlas()); } return result; } catch (final Exception e) { throw new CoreException("Unable to compare edges {} and {}", baseEdge, alterEdge, e); } }
if (!beforeEdge.asPolyLine().equals(afterEdge.asPolyLine()))