/** * Updates the {@link Point} tags for all existing {@link Point}s in the original Atlas, and * adds it to the updated Atlas. */ private void addUpdatedPoints() { this.getAtlas().points().forEach(point -> { final long pointIdentifier = point.getIdentifier(); if (this.changeSet.getUpdatedPointTags().containsKey(pointIdentifier)) { final Point originalPoint = this.getAtlas().point(pointIdentifier); final Map<String, String> updatedTags = originalPoint.getTags(); updatedTags.putAll( this.changeSet.getUpdatedPointTags().get(pointIdentifier).getTags()); this.getBuilder().addPoint(pointIdentifier, originalPoint.getLocation(), updatedTags); } }); }
public static CompletePoint from(final Point point) { return new CompletePoint(point.getIdentifier(), point.getLocation(), point.getTags(), point .relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
@Override public String toString() { return "[Point: id=" + this.getIdentifier() + ", location=" + this.getLocation() + ", " + tagString() + "]"; } }
@Override public String toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Point: id=" + this.getIdentifier() + ", location=" + this.getLocation() + ", relations=(" + relationsString + "), " + tagString() + "]"; }
@Override public Location getLocation() { return getRepresentativeSubPoint().getLocation(); }
public static CompletePoint shallowFrom(final Point point) { return new CompletePoint(point.getIdentifier()) .withInitialBounds(point.getLocation().bounds()); }
final Rectangle box = point.getLocation().boxAround(boundsSize); final Set<String> points = Iterables.stream(point.getAtlas().pointsWithin(box)) .map(nearbyPoint -> nearbyPoint.tag(AddressStreetTag.KEY)).filter(Objects::nonNull) .collectToSet(); final Set<String> edges = Iterables.stream(point.getAtlas().edgesIntersecting(box)) .map(nearbyEdge -> nearbyEdge.tag(NameTag.KEY)).filter(Objects::nonNull) .collectToSet(); this.getLocalizedInstruction(2, point.getOsmIdentifier()))); this.getLocalizedInstruction(0, point.getOsmIdentifier(), points))); this.getLocalizedInstruction(1, point.getOsmIdentifier(), edges)));
/** * Check if the {@link Point} with the given identifier is a {@link Relation} member in the * given {@link Atlas}. * * @param atlas * The {@link Atlas} to check * @param pointIdentifier * The {@link Point} identifier to use * @return {@code true} if the given {@link Point} identifier is a {@link Relation} member in * the given {@link Atlas} */ private boolean isRelationMember(final Atlas atlas, final long pointIdentifier) { return !atlas.point(pointIdentifier).relations().isEmpty(); }
final boolean isRelationMember = !point.relations().isEmpty(); .isEmpty(this.rawAtlas.linesContaining(point.getLocation())); if (!isRelationMember && isIsolatedNode)
final Point source = atlas.point(33); final CompletePoint result = CompletePoint.shallowFrom(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); result.withLocation(Location.CENTER); Assert.assertEquals(Rectangle.forLocated(source.bounds(), Location.CENTER), result.bounds()); final Map<String, String> tags = Maps.hashMap("key", "value"); result.withTags(tags); Assert.assertEquals(tags, result.getTags()); result.withRelationIdentifiers(source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) Assert.assertEquals(Rectangle.forLocated(source.bounds(), Location.COLOSSEUM), result.bounds());
if (point.getIdentifier() == 1 || point.getIdentifier() == 2) "CIV", point.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("None of the points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); else if (point.getIdentifier() == 3 || point.getIdentifier() == 4) "LBR", point.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("None of the points should have a synthetic boundary tag", point.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); "CIV,LBR", point.getTag(ISOCountryTag.KEY).get()); Assert.assertEquals("All new points are non-existing synthetic boundary nodes", SyntheticBoundaryNodeTag.YES.toString(), point.getTag(SyntheticBoundaryNodeTag.KEY).get());
public void recordPoint(final Point point) { this.pointsToStayPoints.add(point.getIdentifier()); } }
if (builder.peek().point(memberIdentifier) == null) builder.addPoint(memberIdentifier, pointMember.getLocation(), pointMember.getTags());
@Test public void testPoint() { final Point point1 = this.atlas.point(1); final Point point2 = this.atlas.point(2); final Point point3 = this.atlas.point(3); final Point point4 = this.atlas.point(4); final Point point5 = this.atlas.point(5); final Point point6 = this.atlas.point(6); final Point point7 = this.atlas.point(7); logger.trace(point1.toString()); logger.trace(point2.toString()); logger.trace(point3.toString()); logger.trace(point4.toString()); logger.trace(point5.toString()); logger.trace(point6.toString()); logger.trace(point7.toString()); Assert.assertTrue(Location.TEST_3.boxAround(Distance.ONE_METER) .fullyGeometricallyEncloses(point1.getLocation())); Assert.assertTrue(Location.TEST_3.boxAround(Distance.kilometers(2)) .fullyGeometricallyEncloses(point3.getLocation())); Assert.assertEquals(1, Iterables .size(this.atlas.pointsWithin(Location.TEST_3.boxAround(Distance.ONE_METER)))); Assert.assertEquals(3, Iterables .size(this.atlas.pointsWithin(Location.TEST_3.boxAround(Distance.kilometers(2))))); final Rectangle box = Location.TEST_3.boxAround(Distance.ONE_METER); Assert.assertEquals(1, Iterables.size( this.atlas.points(point -> box.fullyGeometricallyEncloses(point.getLocation())))); }
@Override public Map<String, String> getTags() { return this.getRepresentativeSubPoint().getTags(); }
.point(3089123457000000L).tag(SyntheticNearestNeighborCountryCodeTag.KEY)); Assert.assertEquals(SyntheticBoundaryNodeTag.EXISTING.name(), slicedAtlas.point(3089123457000000L).tag(SyntheticBoundaryNodeTag.KEY)); .point(3089123458000000L).tag(SyntheticNearestNeighborCountryCodeTag.KEY)); Assert.assertEquals(SyntheticBoundaryNodeTag.EXISTING.name(), slicedAtlas.point(3089123458000000L).tag(SyntheticBoundaryNodeTag.KEY));
@Test public void testLineTouchingBoundary() { final Atlas rawAtlas = this.setup.getRoadTouchingBoundaryAtlas(); final Atlas slicedAtlas = new RawAtlasCountrySlicer(COUNTRIES, COUNTRY_BOUNDARY_MAP) .slice(rawAtlas); // Check Line correctness Assert.assertEquals("A single line exists in the raw Atlas", 1, rawAtlas.numberOfLines()); Assert.assertEquals("The line was untouched after cutting", 1, slicedAtlas.numberOfLines()); Assert.assertEquals("Expect the line to have Ivory Coast country code", "CIV", slicedAtlas.line(1).getTag(ISOCountryTag.KEY).get()); // Check Point correctness Assert.assertEquals("Two points exist in the raw Atlas", 2, rawAtlas.numberOfPoints()); Assert.assertEquals("Two points exist in the sliced Atlas", 2, slicedAtlas.numberOfPoints()); final Point fullyInIvoryCoast = slicedAtlas.point(1); Assert.assertEquals("Expect point to be fully inside Ivory Coast border", "CIV", fullyInIvoryCoast.getTag(ISOCountryTag.KEY).get()); Assert.assertFalse("Point should not have a synthetic boundary tag", fullyInIvoryCoast.getTag(SyntheticBoundaryNodeTag.KEY).isPresent()); final Point exactlyOnBorder = slicedAtlas.point(2); Assert.assertEquals("Expect point on border to have two country codes", "CIV,LBR", exactlyOnBorder.getTag(ISOCountryTag.KEY).get()); Assert.assertEquals("Point should have an existing synthetic boundary tag", SyntheticBoundaryNodeTag.EXISTING.toString(), exactlyOnBorder.getTag(SyntheticBoundaryNodeTag.KEY).get()); }
@Override public boolean validCheckForObject(final AtlasObject object) { return object instanceof Point && !this.isFlagged(((Point) object).getLocation()); }
/** * Adds a {@link TemporaryNode} for the given {@link Location} to the given * {@link NodeOccurrenceCounter}. Note: there should only be a single raw atlas {@link Point} at * the given {@link Location}. * * @param location * The {@link Location} of the node to add * @param nodeCounter * The {@link NodeOccurrenceCounter} to add to */ private void addPointToNodeList(final Location location, final NodeOccurrenceCounter nodeCounter) { this.rawAtlas.pointsAt(location).forEach(point -> nodeCounter .addNode(new TemporaryNode(point.getIdentifier(), point.getLocation()))); }
/** * This function will validate if the supplied atlas object is valid for the check. * * @param object * the atlas object supplied by the Atlas-Checks framework for evaluation * @return {@code true} if this object should be checked */ @Override public boolean validCheckForObject(final AtlasObject object) { // We only need to check for Point's because by definition a Node will be connected to an // Edge. return object instanceof Point && object.getOsmTags().size() == 0 && ((Point) object).relations().size() == 0; }