if(res != null)
{
if (c == null) {
c = new Relation(r);
}
c.addMember(new RelationMember(role, res));
c.removeMembersFor(way);
insert = false;
}
} else {
insert = false;
}
}
else if(!"via".equals(role)) {
warnme = true;
}
}
else if (!("route".equals(type)) && !("multipolygon".equals(type))) {
warnme = true;
}
if (c == null) {
c = new Relation(r);
}
if(insert)
{
if (rm.hasRole() && !nowarnroles.contains(rm.getRole())) {
warnmerole = true;
}
Boolean backwards = null;
int k = 1;
while (i_r - k >= 0 || i_r + k < relationMembers.size()) {
if ((i_r - k >= 0) && relationMembers.get(i_r - k).isWay()){
Way w = relationMembers.get(i_r - k).getWay();
if ((w.lastNode() == way.firstNode()) || w.firstNode() == way.firstNode()) {
backwards = false;
} else if ((w.firstNode() == way.lastNode()) || w.lastNode() == way.lastNode()) {
backwards = true;
}
break;
}
if ((i_r + k < relationMembers.size()) && relationMembers.get(i_r + k).isWay()){
Way w = relationMembers.get(i_r + k).getWay();
if ((w.lastNode() == way.firstNode()) || w.firstNode() == way.firstNode()) {
backwards = true;
} else if ((w.firstNode() == way.lastNode()) || w.lastNode() == way.lastNode()) {
backwards = false;
}
break;
}
k++;
}
int j = i_c;
for (Way wayToAdd : newWays) {
RelationMember em = new RelationMember(rm.getRole(), wayToAdd);
j++;
if ((backwards != null) && backwards) {
c.addMember(i_c, em);
} else {
c.addMember(j, em);