@Test public void testAddRelation() throws Exception { Relation testRelation = new Relation(1, 0, new Date(), null, 0); Assert.assertEquals(0, this.myTestBaseDataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD1DataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD2DataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD3DataSet.getRelationsCount()); mySubject.addRelation(testRelation); Assert.assertEquals(1, this.myTestBaseDataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD1DataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD2DataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD3DataSet.getRelationsCount()); testRelation = new Relation(1, 0, new Date(), null, 0); testRelation.getTags().add(new Tag("type", "street")); mySubject.addRelation(testRelation); Assert.assertEquals(1, this.myTestBaseDataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD1DataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD2DataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD3DataSet.getRelationsCount()); mySubject.removeRelation(testRelation); Assert.assertEquals(0, this.myTestBaseDataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD1DataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD2DataSet.getRelationsCount()); Assert.assertEquals(0, this.myTestLOD3DataSet.getRelationsCount()); testRelation = new Relation(2, 0, new Date(), OsmUser.NONE, 0); testRelation.getTags().add(new Tag("type", "street")); testRelation.getMembers().add(new RelationMember(1L, EntityType.Way, LODDataSet.SIMPLIFIEDWAYRELATIONROLE)); mySubject.addRelation(testRelation); Assert.assertEquals(1, this.myTestBaseDataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD1DataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD2DataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD3DataSet.getRelationsCount()); Assert.assertEquals(1, this.myTestLOD1DataSet.getRelationByID(2).getMembers().size()); }
public void addRelation(final Relation aR) { getBaseDataSet().addRelation(aR); if (isCompoundWay(aR)) { if (!isAutoGenerated(aR.getTags())) { List<RelationMember> toAdd = aR.getMembers(); for (RelationMember relationMember : toAdd) { if (relationMember.getMemberType() != EntityType.Way) { continue; } if (relationMember.getMemberRole() != null && relationMember.getMemberRole().equalsIgnoreCase(SIMPLIFIEDWAYRELATIONROLE)) { continue; } Way memberWay = getLOD1DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD1DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD1DataSet().removeRelation(otherRelation); } } memberWay = getLOD2DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD2DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD2DataSet().removeRelation(otherRelation); } } memberWay = getLOD3DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD3DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD3DataSet().removeRelation(otherRelation); } } } } RelationBuilder compoundWayRelationWithSimplifiedRoles = null; WayBuilder[] compoundWaysBaseLOD = null; compoundWayRelationWithSimplifiedRoles = new RelationBuilder(aR); compoundWaysBaseLOD = combineCompoundWay(compoundWayRelationWithSimplifiedRoles, null); combineSpitWays(getLOD1DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD1, aR, simplificationThresholdLOD1, nodeDistanceThresholdLOD1, myLOD1Selector); getLOD1DataSet().addRelation(aR); combineSpitWays(getLOD2DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD2, aR, simplificationThresholdLOD2, nodeDistanceThresholdLOD2, myLOD2Selector); getLOD2DataSet().addRelation(aR); combineSpitWays(getLOD3DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD3, aR, simplificationThresholdLOD3, nodeDistanceThresholdLOD3, myLOD3Selector); getLOD3DataSet().addRelation(aR); } else { if (myLOD1Selector.isAllowed(getLOD1DataSet(), aR)) { getLOD1DataSet().addRelation(aR); } if (myLOD2Selector.isAllowed(getLOD2DataSet(), aR)) { getLOD2DataSet().addRelation(aR); } if (myLOD3Selector.isAllowed(getLOD3DataSet(), aR)) { getLOD3DataSet().addRelation(aR); } } }
LODDataSet implements IHintableDataSet, IDataSet { public void addRelation(final Relation aR) { getBaseDataSet().addRelation(aR); if (isCompoundWay(aR)) { if (!isAutoGenerated(aR.getTags())) { List<RelationMember> toAdd = aR.getMembers(); for (RelationMember relationMember : toAdd) { if (relationMember.getMemberType() != EntityType.Way) { continue; } if (relationMember.getMemberRole() != null && relationMember.getMemberRole().equalsIgnoreCase(SIMPLIFIEDWAYRELATIONROLE)) { continue; } Way memberWay = getLOD1DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD1DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD1DataSet().removeRelation(otherRelation); } } memberWay = getLOD2DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD2DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD2DataSet().removeRelation(otherRelation); } } memberWay = getLOD3DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD3DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD3DataSet().removeRelation(otherRelation); } } } } RelationBuilder compoundWayRelationWithSimplifiedRoles = null; WayBuilder[] compoundWaysBaseLOD = null; compoundWayRelationWithSimplifiedRoles = new RelationBuilder(aR); compoundWaysBaseLOD = combineCompoundWay(compoundWayRelationWithSimplifiedRoles, null); combineSpitWays(getLOD1DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD1, aR, simplificationThresholdLOD1, nodeDistanceThresholdLOD1, myLOD1Selector); getLOD1DataSet().addRelation(aR); combineSpitWays(getLOD2DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD2, aR, simplificationThresholdLOD2, nodeDistanceThresholdLOD2, myLOD2Selector); getLOD2DataSet().addRelation(aR); combineSpitWays(getLOD3DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD3, aR, simplificationThresholdLOD3, nodeDistanceThresholdLOD3, myLOD3Selector); getLOD3DataSet().addRelation(aR); } else { if (myLOD1Selector.isAllowed(getLOD1DataSet(), aR)) { getLOD1DataSet().addRelation(aR); } if (myLOD2Selector.isAllowed(getLOD2DataSet(), aR)) { getLOD2DataSet().addRelation(aR); } if (myLOD3Selector.isAllowed(getLOD3DataSet(), aR)) { getLOD3DataSet().addRelation(aR); } } } }
LODDataSet implements IHintableDataSet, IDataSet { public void addRelation(final Relation aR) { getBaseDataSet().addRelation(aR); if (isCompoundWay(aR)) { if (!isAutoGenerated(aR.getTags())) { List<RelationMember> toAdd = aR.getMembers(); for (RelationMember relationMember : toAdd) { if (relationMember.getMemberType() != EntityType.Way) { continue; } if (relationMember.getMemberRole() != null && relationMember.getMemberRole().equalsIgnoreCase(SIMPLIFIEDWAYRELATIONROLE)) { continue; } Way memberWay = getLOD1DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD1DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD1DataSet().removeRelation(otherRelation); } } memberWay = getLOD2DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD2DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD2DataSet().removeRelation(otherRelation); } } memberWay = getLOD3DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD3DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD3DataSet().removeRelation(otherRelation); } } } } RelationBuilder compoundWayRelationWithSimplifiedRoles = null; WayBuilder[] compoundWaysBaseLOD = null; compoundWayRelationWithSimplifiedRoles = new RelationBuilder(aR); compoundWaysBaseLOD = combineCompoundWay(compoundWayRelationWithSimplifiedRoles, null); combineSpitWays(getLOD1DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD1, aR, simplificationThresholdLOD1, nodeDistanceThresholdLOD1, myLOD1Selector); getLOD1DataSet().addRelation(aR); combineSpitWays(getLOD2DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD2, aR, simplificationThresholdLOD2, nodeDistanceThresholdLOD2, myLOD2Selector); getLOD2DataSet().addRelation(aR); combineSpitWays(getLOD3DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD3, aR, simplificationThresholdLOD3, nodeDistanceThresholdLOD3, myLOD3Selector); getLOD3DataSet().addRelation(aR); } else { if (myLOD1Selector.isAllowed(getLOD1DataSet(), aR)) { getLOD1DataSet().addRelation(aR); } if (myLOD2Selector.isAllowed(getLOD2DataSet(), aR)) { getLOD2DataSet().addRelation(aR); } if (myLOD3Selector.isAllowed(getLOD3DataSet(), aR)) { getLOD3DataSet().addRelation(aR); } } }  }
LODDataSet implements IHintableDataSet, IDataSet { public void addRelation(final Relation aR) { getBaseDataSet().addRelation(aR); if (isCompoundWay(aR)) { if (!isAutoGenerated(aR.getTags())) { List<RelationMember> toAdd = aR.getMembers(); for (RelationMember relationMember : toAdd) { if (relationMember.getMemberType() != EntityType.Way) { continue; } if (relationMember.getMemberRole() != null && relationMember.getMemberRole().equalsIgnoreCase(SIMPLIFIEDWAYRELATIONROLE)) { continue; } Way memberWay = getLOD1DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD1DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD1DataSet().removeRelation(otherRelation); } } memberWay = getLOD2DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD2DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD2DataSet().removeRelation(otherRelation); } } memberWay = getLOD3DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD3DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD3DataSet().removeRelation(otherRelation); } } } } RelationBuilder compoundWayRelationWithSimplifiedRoles = null; WayBuilder[] compoundWaysBaseLOD = null; compoundWayRelationWithSimplifiedRoles = new RelationBuilder(aR); compoundWaysBaseLOD = combineCompoundWay(compoundWayRelationWithSimplifiedRoles, null); combineSpitWays(getLOD1DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD1, aR, simplificationThresholdLOD1, nodeDistanceThresholdLOD1, myLOD1Selector); getLOD1DataSet().addRelation(aR); combineSpitWays(getLOD2DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD2, aR, simplificationThresholdLOD2, nodeDistanceThresholdLOD2, myLOD2Selector); getLOD2DataSet().addRelation(aR); combineSpitWays(getLOD3DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD3, aR, simplificationThresholdLOD3, nodeDistanceThresholdLOD3, myLOD3Selector); getLOD3DataSet().addRelation(aR); } else { if (myLOD1Selector.isAllowed(getLOD1DataSet(), aR)) { getLOD1DataSet().addRelation(aR); } if (myLOD2Selector.isAllowed(getLOD2DataSet(), aR)) { getLOD2DataSet().addRelation(aR); } if (myLOD3Selector.isAllowed(getLOD3DataSet(), aR)) { getLOD3DataSet().addRelation(aR); } } }  String toString(); void addNode(final Node aW); void addRelation(final Relation aR); void addWay(final Way aW); boolean containsNode(final Node aW); boolean containsRelation(final Relation aR); boolean containsWay(final Way aW); Node getNearestNode(final LatLon aLastGPSPos, final Selector aSelector); Node getNodeByID(final long aNodeID); Iterator<Node> getNodes(final Bounds aBoundingBox); Iterator<Node> getNodesByName(final String aLookFor); Iterator<Node> getNodesByTag(final String aKey, final String aValue); Relation getRelationByID(final long aRelationID); Iterator<Relation> getRelations(final Bounds aBoundingBox); WayHelper getWayHelper(); Iterator<Way> getWays(final Bounds aBoundingBox); Way getWaysByID(final long aWayID); Iterator<Way> getWaysByName(final String aLookFor, final Bounds aBoundingBox); Iterator<Way> getWaysByTag(final String aKey, final String aValue); Iterator<Way> getWaysForNode(final long aNodeID); void removeNode(final Node aW); void removeRelation(final Relation aR); void removeWay(final Way aW); IDataSet getLOD1DataSet(); void setLOD1DataSet(final IDataSet aDataSet); IDataSet getBaseDataSet(); void setBaseDataSet(final IDataSet aBaseDataSet); IDataSet getLOD2DataSet(); void setLOD2DataSet(final IDataSet aDataSet); IDataSet getLOD3DataSet(); void setLOD3DataSet(final IDataSet aDataSet); @Override void shutdown(); @Override ConfigurationSection getSettings(); @Override void hintImportEnded(); @Override void hintImportStarting(); }
LODDataSet implements IHintableDataSet, IDataSet { public void addRelation(final Relation aR) { getBaseDataSet().addRelation(aR); if (isCompoundWay(aR)) { if (!isAutoGenerated(aR.getTags())) { List<RelationMember> toAdd = aR.getMembers(); for (RelationMember relationMember : toAdd) { if (relationMember.getMemberType() != EntityType.Way) { continue; } if (relationMember.getMemberRole() != null && relationMember.getMemberRole().equalsIgnoreCase(SIMPLIFIEDWAYRELATIONROLE)) { continue; } Way memberWay = getLOD1DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD1DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD1DataSet().removeRelation(otherRelation); } } memberWay = getLOD2DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD2DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD2DataSet().removeRelation(otherRelation); } } memberWay = getLOD3DataSet().getWaysByID(relationMember.getMemberId()); if (memberWay != null) { Relation otherRelation = getCompoundRelation(memberWay, getLOD3DataSet()); if (otherRelation != null && isAutoGenerated(otherRelation.getTags())) { getLOD3DataSet().removeRelation(otherRelation); } } } } RelationBuilder compoundWayRelationWithSimplifiedRoles = null; WayBuilder[] compoundWaysBaseLOD = null; compoundWayRelationWithSimplifiedRoles = new RelationBuilder(aR); compoundWaysBaseLOD = combineCompoundWay(compoundWayRelationWithSimplifiedRoles, null); combineSpitWays(getLOD1DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD1, aR, simplificationThresholdLOD1, nodeDistanceThresholdLOD1, myLOD1Selector); getLOD1DataSet().addRelation(aR); combineSpitWays(getLOD2DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD2, aR, simplificationThresholdLOD2, nodeDistanceThresholdLOD2, myLOD2Selector); getLOD2DataSet().addRelation(aR); combineSpitWays(getLOD3DataSet(), compoundWayRelationWithSimplifiedRoles, compoundWaysBaseLOD, null, minSizeLOD3, aR, simplificationThresholdLOD3, nodeDistanceThresholdLOD3, myLOD3Selector); getLOD3DataSet().addRelation(aR); } else { if (myLOD1Selector.isAllowed(getLOD1DataSet(), aR)) { getLOD1DataSet().addRelation(aR); } if (myLOD2Selector.isAllowed(getLOD2DataSet(), aR)) { getLOD2DataSet().addRelation(aR); } if (myLOD3Selector.isAllowed(getLOD3DataSet(), aR)) { getLOD3DataSet().addRelation(aR); } } }  String toString(); void addNode(final Node aW); void addRelation(final Relation aR); void addWay(final Way aW); boolean containsNode(final Node aW); boolean containsRelation(final Relation aR); boolean containsWay(final Way aW); Node getNearestNode(final LatLon aLastGPSPos, final Selector aSelector); Node getNodeByID(final long aNodeID); Iterator<Node> getNodes(final Bounds aBoundingBox); Iterator<Node> getNodesByName(final String aLookFor); Iterator<Node> getNodesByTag(final String aKey, final String aValue); Relation getRelationByID(final long aRelationID); Iterator<Relation> getRelations(final Bounds aBoundingBox); WayHelper getWayHelper(); Iterator<Way> getWays(final Bounds aBoundingBox); Way getWaysByID(final long aWayID); Iterator<Way> getWaysByName(final String aLookFor, final Bounds aBoundingBox); Iterator<Way> getWaysByTag(final String aKey, final String aValue); Iterator<Way> getWaysForNode(final long aNodeID); void removeNode(final Node aW); void removeRelation(final Relation aR); void removeWay(final Way aW); IDataSet getLOD1DataSet(); void setLOD1DataSet(final IDataSet aDataSet); IDataSet getBaseDataSet(); void setBaseDataSet(final IDataSet aBaseDataSet); IDataSet getLOD2DataSet(); void setLOD2DataSet(final IDataSet aDataSet); IDataSet getLOD3DataSet(); void setLOD3DataSet(final IDataSet aDataSet); @Override void shutdown(); @Override ConfigurationSection getSettings(); @Override void hintImportEnded(); @Override void hintImportStarting();  }