@Override public Location getLocation() { return subPoint().getLocation(); }
@Override public Location getLocation() { return getRepresentativeSubPoint().getLocation(); }
@Override public boolean validCheckForObject(final AtlasObject object) { return object instanceof Point && !this.isFlagged(((Point) object).getLocation()); }
private boolean differentPoints(final Point basePoint, final Point alterPoint) { try { if (!basePoint.getLocation().equals(alterPoint.getLocation())) { return true; } return false; } catch (final Exception e) { throw new CoreException("Unable to compare points {} and {}", basePoint, alterPoint, e); } }
@Override protected Optional<CheckFlag> flag(final AtlasObject object) { final Point point = (Point) object; final List<Point> duplicates = Iterables .asList(object.getAtlas().pointsAt(point.getLocation())); if (duplicates.size() > 1) { this.markAsFlagged(point.getLocation()); final List<Long> duplicateIdentifiers = duplicates.stream() .map(AtlasEntity::getOsmIdentifier).collect(Collectors.toList()); return Optional.of(this.createFlag(object, this.getLocalizedInstruction(0, duplicateIdentifiers, point.getLocation()))); } return Optional.empty(); } }
@Override public String toString() { return "[Point: id=" + this.getIdentifier() + ", location=" + this.getLocation() + ", " + tagString() + "]"; } }
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 toDiffViewFriendlyString() { final String relationsString = this.parentRelationsAsDiffViewFriendlyString(); return "[Point: id=" + this.getIdentifier() + ", location=" + this.getLocation() + ", relations=(" + relationsString + "), " + tagString() + "]"; }
/** * 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()))); }
/** * Check if the {@link Point} with the given identifier is a shape point for some {@link Line} * 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 shape point for some * {@link Line} in the given {@link Atlas} */ private boolean isShapePoint(final Atlas atlas, final long pointIdentifier) { return Iterables .size(atlas.linesContaining(atlas.point(pointIdentifier).getLocation())) > 0; }
public static CompletePoint shallowFrom(final Point point) { return new CompletePoint(point.getIdentifier()) .withInitialBounds(point.getLocation().bounds()); }
@Override public Iterable<Point> pointsWithin(final Polygon polygon) { final Iterable<Point> points = this.getPointSpatialIndex().get(polygon.bounds()); if (polygon instanceof Rectangle) { return points; } return Iterables.filter(points, point -> polygon.fullyGeometricallyEncloses(point.getLocation())); }
/** * 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); } }); }
private String convertPoint(final Point item) { final StringList list = new StringList(); list.add(item.getIdentifier()); list.add(item.getLocation().toCompactString()); list.add(convertTags(item)); return list.join(SEPARATOR); }
private void addExistingPointsAndLines() { this.getAtlas().points().forEach(point -> { // Add the point, if it hasn't been deleted if (!this.changeSet.getDeletedPoints().contains(point.getIdentifier())) { this.getBuilder().addPoint(point.getIdentifier(), point.getLocation(), point.getTags()); } }); this.getAtlas().lines().forEach(line -> { // Add the line, if it hasn't been deleted if (!this.changeSet.getDeletedLines().contains(line.getIdentifier())) { this.getBuilder().addLine(line.getIdentifier(), line.asPolyLine(), line.getTags()); } }); }
public static FeatureChange simpleBloatedPointChange(final ChangeType changeType, final Atlas atlas, final AtlasEntity entity, final boolean saveAllGeometries) { final Long entityIdentifier = entity.getIdentifier(); if (changeType == ChangeType.REMOVE) { CompletePoint bloatedPoint = CompletePoint.shallowFrom(atlas.point(entityIdentifier)); if (saveAllGeometries) { bloatedPoint = bloatedPoint.withLocation(((Point) entity).getLocation()); } return new FeatureChange(changeType, bloatedPoint); } else { return new FeatureChange(changeType, CompletePoint.from(atlas.point(entityIdentifier))); } }
@Test public void testFull() { final Atlas atlas = this.rule.getAtlas(); final Point source = atlas.point(33); final CompletePoint result = CompletePoint.from(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); Assert.assertEquals(source.getLocation(), result.getLocation()); Assert.assertEquals(source.getTags(), result.getTags()); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); }
@Test public void testMovePoint() { final Atlas atlas = this.rule.getAtlas(); final ChangeBuilder changeBuilder = new ChangeBuilder(); final Point source = atlas.point(41822000000L); final Location newLocation = source.getLocation().shiftAlongGreatCircle(Heading.NORTH, Distance.ONE_METER); changeBuilder.add(new FeatureChange(ChangeType.ADD, CompletePoint.shallowFrom(source).withLocation(newLocation))); final Change change = changeBuilder.get(); final Atlas changeAtlas = new ChangeAtlas(atlas, change); Assert.assertEquals(newLocation, changeAtlas.point(41822000000L).getLocation()); final Relation disconnectedFeatures = changeAtlas.relation(41834000000L); final Point fromRelation = (Point) Iterables.stream(disconnectedFeatures.members()) .firstMatching(member -> "tree".equals(member.getRole())).get().getEntity(); Assert.assertEquals(newLocation, fromRelation.getLocation()); }
private void writePointsToBuilder(final Atlas atlas, final ProtoAtlas.Builder protoAtlasBuilder) { long numberOfPoints = 0; for (final Point point : atlas.points()) { final ProtoPoint.Builder protoPointBuilder = ProtoPoint.newBuilder(); protoPointBuilder.setId(point.getIdentifier()); protoPointBuilder.setLocation( ProtoAtlasBuilder.PROTOLOCATION_CONVERTER.backwardConvert(point.getLocation())); final Map<String, String> tags = point.getTags(); protoPointBuilder .addAllTags(ProtoAtlasBuilder.PROTOTAG_LIST_CONVERTER.backwardConvert(tags)); numberOfPoints++; protoAtlasBuilder.addPoints(protoPointBuilder.build()); } protoAtlasBuilder.setNumberOfPoints(numberOfPoints); }
/** * Add all points, areas and lines that pass the given matcher to the sub-atlas, using the given * {@link PackedAtlasBuilder}. * * @param matcher * The matcher to consider * @param builder * The {@link PackedAtlasBuilder} used to build the sub-atlas */ private void indexPointsAreasLines(final Predicate<AtlasEntity> matcher, final PackedAtlasBuilder builder) { for (final Point point : this.atlas.points(matcher::test)) { builder.addPoint(point.getIdentifier(), point.getLocation(), point.getTags()); } for (final Area area : this.atlas.areas(matcher::test)) { builder.addArea(area.getIdentifier(), area.asPolygon(), area.getTags()); } for (final Line line : this.atlas.lines(matcher::test)) { builder.addLine(line.getIdentifier(), line.asPolyLine(), line.getTags()); } } }