use of org.openstreetmap.atlas.geography.atlas.builder.RelationBean in project atlas by osmlab.
the class MissingMultiEntityRelationTest method testRelationsForMissingRelation.
@Test
public void testRelationsForMissingRelation() {
final PackedAtlasBuilder builderWithRelation = new PackedAtlasBuilder();
builderWithRelation.addPoint(1L, Location.forString("1,1"), Maps.hashMap("somePoint", "inTwoAtlases"));
final RelationBean bean = new RelationBean();
bean.addItem(1L, "some member point", ItemType.POINT);
builderWithRelation.addRelation(1, 1, bean, Maps.hashMap());
final RelationBean bean2 = new RelationBean();
bean2.addItem(1L, "parent relation of subrelation", ItemType.RELATION);
builderWithRelation.addRelation(2, 2, bean2, Maps.hashMap());
final PackedAtlasBuilder builderNoRelation = new PackedAtlasBuilder();
builderNoRelation.addPoint(1L, Location.forString("1,1"), Maps.hashMap("somePoint", "inTwoAtlases"));
final RelationBean bean3 = new RelationBean();
bean3.addItem(1L, "some member point", ItemType.POINT);
builderNoRelation.addRelation(1, 1, bean3, Maps.hashMap());
final PackedAtlas atlasWithRelation = (PackedAtlas) builderWithRelation.get();
final PackedAtlas atlasNoRelation = (PackedAtlas) builderNoRelation.get();
// 1 MiB resources
final ByteArrayResource resourceWithRelation = new ByteArrayResource(1024 * 1024);
final ByteArrayResource resourceNoRelation = new ByteArrayResource(1024 * 1024);
atlasWithRelation.save(resourceWithRelation);
atlasNoRelation.save(resourceNoRelation);
/*
* Here, we want to add the atlas without the relation first, since the MultiAtlas appends
* identical relations into the MultiRelation list. It then will always choose the first
* subRelation to get the parent relations. See the MultiAtlas.populateReferences() and
* MultiRelation.relations() to see what's happening.
*/
final Atlas multiAtlas = new AtlasResourceLoader().load(resourceNoRelation, resourceWithRelation);
Assert.assertFalse(multiAtlas.relation(1L).relations().isEmpty());
final Atlas multiAtlas2 = new AtlasResourceLoader().load(resourceWithRelation, resourceNoRelation);
Assert.assertFalse(multiAtlas2.relation(1L).relations().isEmpty());
}
use of org.openstreetmap.atlas.geography.atlas.builder.RelationBean in project atlas by osmlab.
the class PackedAtlasTest method testRelationMembersWithSameIdentifiersButDifferentTypes.
@Test
public void testRelationMembersWithSameIdentifiersButDifferentTypes() {
final PackedAtlasBuilder builder = new PackedAtlasBuilder();
builder.addArea(0, Polygon.SILICON_VALLEY, Maps.hashMap());
builder.addLine(0, PolyLine.TEST_POLYLINE, Maps.hashMap());
final RelationBean bean = new RelationBean();
bean.addItem(0L, "Role of the Area", ItemType.AREA);
bean.addItem(0L, "Role of the Line", ItemType.LINE);
builder.addRelation(0, 0, bean, Maps.hashMap());
final Atlas result = builder.get();
Assert.assertEquals(2, result.relation(0).members().size());
}
use of org.openstreetmap.atlas.geography.atlas.builder.RelationBean in project atlas by osmlab.
the class RelationToMultiPolygonMemberConverterTest method init.
@Before
public void init() {
final PackedAtlasBuilder builder = new PackedAtlasBuilder();
builder.addLine(0, new PolyLine(ONE, TWO), Maps.hashMap());
builder.addLine(1, new PolyLine(TWO, THR), Maps.hashMap());
builder.addLine(2, new PolyLine(THR, FOR), Maps.hashMap());
builder.addLine(3, new PolyLine(FOR, FVE), Maps.hashMap());
builder.addLine(4, new PolyLine(FVE, ONE), Maps.hashMap());
builder.addLine(5, new PolyLine(SIX, SVN), Maps.hashMap());
builder.addLine(6, new PolyLine(SVN, EIT), Maps.hashMap());
builder.addLine(7, new PolyLine(EIT, SIX), Maps.hashMap());
builder.addArea(0, INNER_LOOP, Maps.hashMap());
final RelationBean bean = new RelationBean();
bean.addItem(0L, RelationTypeTag.MULTIPOLYGON_ROLE_OUTER, ItemType.AREA);
bean.addItem(0L, RelationTypeTag.MULTIPOLYGON_ROLE_OUTER, ItemType.LINE);
bean.addItem(1L, RelationTypeTag.MULTIPOLYGON_ROLE_OUTER, ItemType.LINE);
bean.addItem(2L, RelationTypeTag.MULTIPOLYGON_ROLE_OUTER, ItemType.LINE);
bean.addItem(3L, RelationTypeTag.MULTIPOLYGON_ROLE_OUTER, ItemType.LINE);
bean.addItem(4L, RelationTypeTag.MULTIPOLYGON_ROLE_OUTER, ItemType.LINE);
bean.addItem(5L, RelationTypeTag.MULTIPOLYGON_ROLE_INNER, ItemType.LINE);
bean.addItem(6L, RelationTypeTag.MULTIPOLYGON_ROLE_INNER, ItemType.LINE);
bean.addItem(7L, RelationTypeTag.MULTIPOLYGON_ROLE_INNER, ItemType.LINE);
builder.addRelation(0, 0, bean, Maps.hashMap(RelationTypeTag.KEY, RelationTypeTag.MULTIPOLYGON_TYPE));
this.atlas = builder.get();
}
Aggregations