@Override public Set<Relation> relations() { return subArea().relations().stream() .map(relation -> new DynamicRelation(dynamicAtlas(), relation.getIdentifier())) .collect(Collectors.toSet()); }
public static CompleteArea from(final Area area) { return new CompleteArea(area.getIdentifier(), area.asPolygon(), area.getTags(), area.relations().stream().map(Relation::getIdentifier).collect(Collectors.toSet())); }
@Override public LocationIterableProperties toGeoJsonBuildingBlock() { final Map<String, String> tags = getTags(); tags.put("identifier", String.valueOf(getIdentifier())); tags.put("osmIdentifier", String.valueOf(getOsmIdentifier())); tags.put("itemType", String.valueOf(getType())); final Optional<String> shardName = getAtlas().metaData().getShardName(); shardName.ifPresent(shard -> tags.put("shard", shard)); final StringList parentRelations = new StringList(); this.relations().forEach(relation -> { final RelationMember member = relation.members().get(getIdentifier(), getType()); parentRelations.add(member.getRelationIdentifier() + "-" + member.getRole()); }); if (!parentRelations.isEmpty()) { tags.put("parentRelations", parentRelations.join(", ")); } return new GeoJsonBuilder.LocationIterableProperties(getClosedGeometry(), tags); }
@Test public void testFull() { final Atlas atlas = this.rule.getAtlas(); final Area source = atlas.area(27); final CompleteArea result = CompleteArea.from(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); Assert.assertEquals(source.asPolygon(), result.asPolygon()); 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())); }
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)
resourceNoRelation); Assert.assertTrue(!multiAtlas.area(1L).relations().isEmpty());