@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())); tags.put("relation", this.toSimpleString()); final Optional<String> shardName = getAtlas().metaData().getShardName(); shardName.ifPresent(shard -> tags.put("shard", shard)); return new GeoJsonBuilder.LocationIterableProperties(bounds().center(), tags); }
public static CompleteRelation from(final Relation relation) { return new CompleteRelation(relation.getIdentifier(), relation.getTags(), relation.bounds(), relation.members().asBean(), relation.allRelationsWithSameOsmIdentifier().stream().map(Relation::getIdentifier) .collect(Collectors.toList()), relation.allKnownOsmMembers().asBean(), relation.osmRelationIdentifier(), relation.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); }
public static CompleteRelation shallowFrom(final Relation relation) { return new CompleteRelation(relation.getIdentifier()).withInitialBounds(relation.bounds()); }
@Override public GeometryPrintable convert(final AtlasEntity source) { GeometryPrintable result = null; if (source instanceof Area) { result = ((Area) source).asPolygon(); } else if (source instanceof LineItem) { result = ((LineItem) source).asPolyLine(); } else if (source instanceof LocationItem) { result = ((LocationItem) source).getLocation(); } else { // Relation result = ((Relation) source).bounds(); } if (result == null) { result = source.bounds(); } return result; } }
@Test public void testFull() { final Atlas atlas = this.rule.getAtlas(); final Relation source = atlas.relation(22); final CompleteRelation result = CompleteRelation.from(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); Assert.assertEquals(source.members().asBean(), result.members().asBean()); Assert.assertEquals(source.allKnownOsmMembers().asBean(), result.allKnownOsmMembers().asBean()); Assert.assertEquals(source.osmRelationIdentifier(), result.osmRelationIdentifier()); Assert.assertEquals( source.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet()), result.relations().stream().map(Relation::getIdentifier) .collect(Collectors.toSet())); }
@Test public void testShallow() { final Atlas atlas = this.rule.getAtlas(); final Relation source = atlas.relation(22); final CompleteRelation result = CompleteRelation.shallowFrom(source); Assert.assertEquals(source.getIdentifier(), result.getIdentifier()); Assert.assertEquals(source.bounds(), result.bounds()); result.withMembersAndSource(new RelationMemberList(source.members()), source); Assert.assertEquals(source.members().asBean(), result.members().asBean()); result.withMembersAndSource(source.members().asBean(), source, source.bounds()); Assert.assertEquals(source.bounds(), result.bounds()); Assert.assertEquals(source.members().asBean(), result.members().asBean()); result.withAllKnownOsmMembers(source.allKnownOsmMembers().asBean()); Assert.assertEquals(source.allKnownOsmMembers().asBean(), result.allKnownOsmMembers().asBean()); result.withOsmRelationIdentifier(source.osmRelationIdentifier()); Assert.assertEquals(source.osmRelationIdentifier(), result.osmRelationIdentifier()); 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) .collect(Collectors.toSet())); } }
if (relation.members().size() > 0 && relation.bounds() != null)
private AtlasPrimitiveRelation convert(final Relation relation) { final RelationBean bean = new RelationBean(); for (final RelationMember member : relation.members()) { bean.addItem(member.getEntity().getIdentifier(), member.getRole(), member.getEntity().getType()); } return new AtlasPrimitiveRelation(relation.getIdentifier(), relation.getIdentifier(), bean, relation.getTags(), relation.bounds()); }
changeBuilder.add( new FeatureChange(ChangeType.ADD, new CompleteRelation(41862000000L, Maps.hashMap(), atlas.relation(41861000000L).bounds(), newBean, null, null, null, null)));