public void recordPoint(final Point point) { this.pointsToStayPoints.add(point.getIdentifier()); } }
private DynamicPoint newPoint(final Point point) { return new DynamicPoint(this, point.getIdentifier()); }
/** * Determines if the given raw atlas {@link Point} qualifies to be a {@link Node} in the final * atlas. This is a simple lookup to check if the previously discovered node list contains the * given point's identifier. * * @param changeSet * The {@link WaySectionChangeSet} to use * @param point * The {@link Point} to check * @return {@code true} if the given raw atlas {@link Point} qualifies to be a {@link Node} in * the final atlas. */ private boolean isAtlasNode(final WaySectionChangeSet changeSet, final Point point) { return changeSet.getPointsThatBecomeNodes().contains(point.getIdentifier()); }
/** * Takes a location, a list of points from the raw Atlas at that location, and a list of point * IDs. Ensures the tags for the point are updated, ensures the points are not removed from the * raw Atlas, and adds the points the list of points for the line. * * @param location * The location for the point(s) * @param rawAtlasPoints * The points from the raw Atlas * @param line * The List representing the points for the line to add the points to */ private void addRawAtlasPointsToLine(final Location location, final Iterable<Point> rawAtlasPoints, final List<Long> line) { final Map<String, String> pointTags = createPointTags(location, true); for (final Point rawAtlasPoint : rawAtlasPoints) { this.pointsMarkedForRemoval.remove(rawAtlasPoint.getIdentifier()); this.slicedPointAndLineChanges.updatePointTags(rawAtlasPoint.getIdentifier(), pointTags); line.add(rawAtlasPoint.getIdentifier()); } }
@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())); }
/** * Given a slice, that is outside the working bound, mark all shape points for this slice for * removal from the final atlas. Since we are removing the slice, we don't need its shape * points. * * @param slice * The {@link Geometry} slice being filtered */ private void removeShapePointsFromFilteredSliced(final Geometry slice) { final Coordinate[] jtsSliceCoordinates = slice.getCoordinates(); for (final Coordinate coordinate : jtsSliceCoordinates) { final Location location = JTS_LOCATION_CONVERTER.backwardConvert(coordinate); final Iterable<Point> existingRawAtlasPoints = this.rawAtlas.pointsAt(location); existingRawAtlasPoints .forEach(point -> this.pointsMarkedForRemoval.add(point.getIdentifier())); } }
@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()))); }
public static CompletePoint shallowFrom(final Point point) { return new CompletePoint(point.getIdentifier()) .withInitialBounds(point.getLocation().bounds()); }
/** * Marks a line for deletion, if that line is being removed as a relation member. This is safe * to do when the line member was merged with another member to maintain a valid relation and * the merged line is not part of any other relation. * * @param line * The relation member {@link Line} * @param relationIdentifier * The parent {@link Relation} identifier */ private void markRemovedMemberLineForDeletion(final Line line, final long relationIdentifier) { // Only mark this line for deletion if this line isn't part of any other relations final boolean isPartOfOtherRelations = line.relations().stream() .anyMatch(partOf -> partOf.getIdentifier() != relationIdentifier); if (!isPartOfOtherRelations) { // Delete Line and all of its points this.slicedRelationChanges.deleteLine(line.getIdentifier()); this.partiallySlicedRawAtlas.line(line.getIdentifier()).asPolyLine() .forEach(location -> this.partiallySlicedRawAtlas.pointsAt(location).forEach( point -> this.pointCandidatesForRemoval.add(point.getIdentifier()))); } }
/** * 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 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()); } }); }
/** * Updates all of the given {@link Line}'s shape points' tags. Under the covers, uses * {@link CountryBoundaryMap} spatial index call. * * @param line * The {@link Line} whose shape points to update */ private void updateLineShapePoints(final Line line) { for (final Location location : line.asPolyLine()) { for (final Point point : this.rawAtlas.pointsAt(location)) { getStatistics().recordProcessedPoint(); this.slicedPointAndLineChanges.updatePointTags(point.getIdentifier(), createPointTags(location, true)); } } }
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); }
@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())); }
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); }
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);
/** * 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()); } } }
protected void populateReferences(final Atlas atlas, final int atlasIndex) { for (final Node node : atlas.nodes()) { this.nodeIdentifierToAtlasIndices.add(node.getIdentifier(), atlasIndex); } for (final Edge edge : atlas.edges()) { this.edgeIdentifierToAtlasIndex.put(edge.getIdentifier(), atlasIndex); } for (final Area area : atlas.areas()) { this.areaIdentifierToAtlasIndices.add(area.getIdentifier(), atlasIndex); } for (final Line line : atlas.lines()) { this.lineIdentifierToAtlasIndices.add(line.getIdentifier(), atlasIndex); } for (final Point point : atlas.points()) { this.pointIdentifierToAtlasIndices.add(point.getIdentifier(), atlasIndex); } for (final Relation relation : atlas.relations()) { this.relationIdentifierToAtlasIndices.add(relation.getIdentifier(), atlasIndex); } }