new String[] { "-1", "no" } ) );
// create new way, if no name given create an empty one
String wayName;
wayName = currentAttributes.get( "name" );
WayModel way = null;
if(wayName == null){ way = new WayModel(""); }
else{ way = new WayModel(wayName); }
String onewayAttribute;
onewayAttribute = currentAttributes.get( "oneway" );
if(
( onewayAttribute == null )
|| (
( onewayAttribute != null )
&& ( oneway_forward.contains( onewayAttribute ) )
&& ( oneway_backward.contains( onewayAttribute ) )
)
) {
// generate way toward and backward
EdgeModel fwdEdge;
EdgeModel bwdEdge;
for( int i = 0; i < currentWay.size() - 1; i++ ) {
if (filterCyclicEdges && currentWay.get(i) == currentWay.get(i + 1)) {
continue;
}
fwdEdge = createEdge( currentWay.get( i ), currentWay.get( i + 1 ), way );
bwdEdge = createEdge( currentWay.get( i + 1 ), currentWay.get( i ), way );
if(bwdEdge == null || fwdEdge == null){
//
logger.error("Error while creating way, skipping...");
continue;
}
way.addForwardEdge( fwdEdge );
way.addBackwardEdge( bwdEdge );
// set complementary edges
fwdEdge.setComplementaryEdge( bwdEdge );
bwdEdge.setComplementaryEdge( fwdEdge );
}
} else if( oneway_forward.contains( onewayAttribute ) ) {
EdgeModel edge = null;
EdgeModel lastEdge = null;
// generates way toward if one-way in oneway_forward or not set or no
for( int i = 0; i < currentWay.size() - 1; i++ ) {
edge = createEdge( currentWay.get( i ), currentWay.get( i + 1 ), way );
// references
if(edge == null){
//
logger.error("Error while creating way, skipping...");
continue;
}
// references
if(lastEdge != null){
lastEdge.setNextEdge( edge );
edge.setPreviousEdge( lastEdge );
}
// update way
way.addForwardEdge( edge );
// remember
lastEdge = edge;
}
} else if( oneway_backward.contains( onewayAttribute ) ) {
EdgeModel edge = null;
EdgeModel lastEdge = null;
// generates way back if one-way = no or not set or -1
for( int i = currentWay.size() - 1; i > 0; i-- ) {
edge = createEdge( currentWay.get( i ), currentWay.get( i - 1 ), way );
if(edge == null){
logger.error("Error while creating way, skipping...");
continue;
}
// references
//lastEdge.setNextEdge( edge );
//edge.setPreviousEdge( lastEdge );
if(lastEdge != null){
lastEdge.setNextEdge( edge );
edge.setPreviousEdge( lastEdge );
}
// update way
way.addBackwardEdge( edge );
// quick dirty fix for the problem of the first point of a way
// see in the wayItem.java constructor
// - currently solved through the first node of the firstForwardEdge,
// but what is if no forwardEdge exists like in this case (oneway-backward) -
// if no forwardEdge is given there would be occur an error
if (i == 1) {
way.addForwardEdge(edge);
}
// remember
lastEdge = edge;
}