@Override public boolean equals(final Object other) { if (other instanceof ComplexEntity) { return other.getClass().equals(this.getClass()) && this.getSource().equals(((ComplexEntity) other).getSource()); } return false; }
protected void validateRelationsPresent() { for (final AtlasEntity entity : this.atlas.entities()) { for (final Relation relation : entity.relations()) { if (relation == null) { throw new CoreException( "Entity {} {} lists some parent relation that is not present: {}", entity.getType(), entity.getIdentifier(), entity.relations().stream() .map(parent -> parent == null ? "null" : String.valueOf(parent.getIdentifier())) .collect(Collectors.toSet())); } } } }
/** * Creates an informative {@link String} for an {@link AtlasEntity} and the {@link Atlas} that * contains it. * * @param entity * {@link AtlasEntity} to create the string for * @return formatted string */ private String formatAtlasObject(final AtlasEntity entity) { final String shardName = entity.getAtlas().metaData().getShardName().orElse("UNKNOWN"); return String.format("[%s] [%d] [%d] --> [%s:%s] Tags: [%s]\n", entity.getType(), entity.getOsmIdentifier(), entity.getIdentifier(), shardName, entity.getAtlas().getName(), entity.getTags()); } }
static boolean basicEqual(final AtlasEntity left, final AtlasEntity right) { return left.getIdentifier() == right.getIdentifier() && Objects.equals(left.getTags(), right.getTags()) && Objects.equals(left.relations(), right.relations()); }
@Override public String toString() { return "FeatureChange [changeType=" + this.changeType + ", reference={" + this.reference.getType() + "," + this.reference.getIdentifier() + "}, bounds=" + bounds() + "]"; }
protected void validateTagsPresent() { for (final AtlasEntity entity : this.atlas.entities()) { final Map<String, String> tags = entity.getTags(); if (tags == null) { throw new CoreException("Entity {} {} is missing tags.", entity.getType(), entity.getIdentifier()); } } } }
properties.addProperty("entityType", source.getType().toString()); properties.addProperty("class", source.getClass().getName()); properties.addProperty("identifier", source.getIdentifier()); add(properties, "tags", source.getTags(), tagPrinter); add(properties, "relations", source.relations(), identifierMapper);
@Override protected Long compress(final M item) { return item.getIdentifier(); }
public static ItemType forEntity(final AtlasEntity entity) { return entity.getType(); }
protected String formatAtlasObject(final String type, final Atlas atlas, final AtlasEntity entity) { final String shardName = atlas.metaData().getShardName().orElse("UNKNOWN"); return String.format("[%10s] [%d] [%d] --> [%s:%s] Tags: [%s]\n", type, entity.getOsmIdentifier(), entity.getIdentifier(), shardName, atlas.getName(), entity.getTags()); }
public CompleteRelation withExtraMember(final AtlasEntity newMember, final String role) { this.members.addItem( new RelationBeanItem(newMember.getIdentifier(), role, newMember.getType())); this.updateBounds(newMember.bounds()); return this; }
final Optional<String> countryCodeString = entity.getTag(ISOCountryTag.KEY); if (countryCodeString.isPresent()) .getUpdatedRelationTags(); final Map<String, String> newTagsForEntity = entityIdToChangedTags .getOrDefault(entity.getIdentifier(), new HashMap<>()); entity.getType(), entity.getIdentifier());
private static List<Taggable> children(final AtlasEntity entity) { final List<Taggable> taggables = new ArrayList<>(); taggables.add(entity); final List<Relation> relations = new ArrayList<>(entity.relations()); relations.sort(RELATION_ID_COMPARATOR); Iterables.addAll(taggables, relations); return taggables; }
/** * @return The building part's top height */ public Optional<Distance> topHeight() { final Map<String, String> tags = getSource().getTags(); final String heightTag = tags.get("height"); try { if (heightTag != null) { return Optional.of(HEIGHT_CONVERTER.convert(heightTag)); } } catch (final Exception e) { logger.warn("Invalid height {} for building part id {}", heightTag, getSource().getIdentifier()); } return Optional.empty(); }
final Set<Relation> parentRelations = entity.relations(); for (final Relation parentRelation : parentRelations) && childEntity.getIdentifier() == entity.getIdentifier())
/** * Checks if an {@link AtlasObject} is a outline or part member of a building relation. This is * an equivalent tagging to building=* or building:part=yes. * * @param object * {@link AtlasObject} to check * @return true if the object is part of any relation where it has role outline or part */ private boolean isBuildingRelationMember(final AtlasObject object) { return object instanceof AtlasEntity && ((AtlasEntity) object).relations().stream() .anyMatch(relation -> Validators.isOfType(relation, RelationTypeTag.class, RelationTypeTag.BUILDING) && relation.members().stream() .anyMatch(member -> member.getEntity().equals(object) && (member.getRole().equals("outline")) || member.getRole().equals("part"))); }
final Set<Long> beforeRelationIdentifiers = beforeEntity.relations().stream() .map(Relation::getIdentifier).collect(Collectors.toSet()); final Set<Long> afterRelationIdentifiers = afterEntity.relations().stream() .map(Relation::getIdentifier).collect(Collectors.toSet()); switch (afterEntity.getType()) break; default: throw new CoreException("Unknown item type {}", afterEntity.getType());
@Override public String toString() { return MoreObjects.toStringHelper(this).add("osm", getSource().getOsmIdentifier()) .add("atlas", getSource().getIdentifier()).add("boundary", this.boundary) .toString(); }
@Override public Optional<String> getTag(final String key) { return Optional.ofNullable(getTags().get(key)); }
if (beforeEntity.getTags().equals(afterEntity.getTags())) switch (afterEntity.getType()) .withTags(afterEntity.getTags()); if (saveAllGeometries) case EDGE: CompleteEdge edge = CompleteEdge.shallowFrom((Edge) afterEntity) .withTags(afterEntity.getTags()); if (saveAllGeometries) case LINE: CompleteLine line = CompleteLine.shallowFrom((Line) afterEntity) .withTags(afterEntity.getTags()); if (saveAllGeometries) case NODE: CompleteNode node = CompleteNode.shallowFrom((Node) afterEntity) .withTags(afterEntity.getTags()); if (saveAllGeometries) case POINT: CompletePoint point = CompletePoint.shallowFrom((Point) afterEntity) .withTags(afterEntity.getTags()); if (saveAllGeometries) case RELATION: final CompleteRelation relation = CompleteRelation