protected ComplexEntity(final AtlasEntity source) { this.source = source; this.atlas = source.getAtlas(); }
/** * For comparison, we require the AtlasEntities to be from the same instance of Atlas. Edges * with same attributes from two instances of Atlas (with same data) are considered different */ @Override public boolean equals(final Object other) { if (this == other) { return true; } if (other != null && this.getClass() == other.getClass()) { final AtlasEntity that = (AtlasEntity) other; // Do not call atlas.equals() which would browse all the items and create a stack // overflow return this.getAtlas() == that.getAtlas() && this.getIdentifier() == that.getIdentifier(); } return false; }
private void output(final AtlasEntity item) { Rectangle rectangle = item.bounds(); if (this.distanceInMeters.isPresent()) { rectangle = rectangle.expand(Distance.meters(this.distanceInMeters.get())); } item.getAtlas().subAtlas(rectangle, AtlasCutType.SOFT_CUT).ifPresent(this.subAtlases::add); } }
/** * A method that creates properties for a GeoJSON Feature from the tags. * * @return A GeoJSON properties object that is to be put in a Feature. */ public JsonObject geoJsonProperties() { final JsonObject properties = new JsonObject(); getTags().forEach(properties::addProperty); properties.addProperty(GeoJsonUtils.IDENTIFIER, getIdentifier()); properties.addProperty(GeoJsonUtils.OSM_IDENTIFIER, getOsmIdentifier()); properties.addProperty(GeoJsonUtils.ITEM_TYPE, String.valueOf(getType())); final Optional<String> shardName = getAtlas().metaData().getShardName(); shardName.ifPresent(shard -> properties.addProperty("shard", shard)); final Set<Relation> relations = relations(); if (relations.size() > 0) { final JsonArray relationsArray = new JsonArray(); properties.add("relations", relationsArray); for (final Relation relation : relations) { final JsonObject relationObject = relation.geoJsonProperties(); relationsArray.add(relationObject); } } return properties; }
/** * 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()); } }