Index: src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java
===================================================================
--- src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(revision 3994)
+++ src/uk/me/parabola/mkgmap/osmstyle/StyledConverter.java	(working copy)
@@ -1892,8 +1892,10 @@
 	}
 
 	/**
-	 * Detect roads that do not share any node with another road.
-	 * If such a road has the mkgmap:set_unconnected_type tag, add it as line, not as a road. 
+	 * Detect roads that do not share any node with another road. 
+	 * If such a road has the mkgmap:set_unconnected_type tag, add it as line, not as a road.
+	 * Detect also roads which are only connected in one point, so that they don't lead to other roads.
+	 * If such a road has the mkgmap:set_semi_connected_type tag, add it as line, not as a road. 
 	 */
 	private void findUnconnectedRoads(){
 		Map<Coord, HashSet<Way>> connectors = new IdentityHashMap<>(roads.size()*2);
@@ -1922,8 +1924,6 @@
 			}
 		}
 		
-		// find roads that are not connected
-		// count downwards because we are removing elements
 		Iterator<ConvertedWay> iter = roads.iterator();
 		while(iter.hasNext()){
 			ConvertedWay cw = iter.next();
@@ -1931,127 +1931,160 @@
 				continue;
 			Way way = cw.getWay();
 			if(reportDeadEnds > 0){
-				// report dead ends of oneway roads 
-				if (cw.isOneway() && !way.tagIsLikeNo("mkgmap:dead-end-check")) {
-					List<Coord> points = way.getPoints();
-					int[] pointsToCheck = {0, points.size()-1};
-					if (points.get(pointsToCheck[0]) == points.get(pointsToCheck[1]))
-						continue; // skip closed way
-					for (int pos: pointsToCheck ){
-						boolean isDeadEnd = true;
-						boolean isDeadEndOfMultipleWays = true;
-						Coord p = points.get(pos);
-						if (bbox.contains(p) == false || p.getOnBoundary())
-							isDeadEnd = false;  // we don't know enough about possible connections 
-						else if (p.getHighwayCount() < 2){
-							isDeadEndOfMultipleWays = false;
-						} else {
-							HashSet<Way> ways = connectors.get(p);
-							if (ways.size() <= 1)
-								isDeadEndOfMultipleWays = false;
-							for (Way connectedWay: ways){
-								if (!isDeadEnd)
-									break;
-								if (way == connectedWay){
-									if (selfConnectors.contains(way)){
-										// this might be a P-shaped oneway,
-										// check if it has other exists in the loop part
-										if (pos == 0){
-											for (int k = pos+1; k < points.size()-1; k++){
-												Coord pTest = points.get(k);
-												if (pTest == p)
-													break; // found no other exit
-												if (pTest.getHighwayCount() > 1){
-													isDeadEnd = false;
-													break;
-												}
-											} 
-
-										}else {
-											for (int k = pos-1; k >= 0; k--){
-												Coord pTest = points.get(k);
-												if (pTest == p)
-													break; // found no other exit
-												if (pTest.getHighwayCount() > 1){
-													isDeadEnd = false;
-													break;
-												}
-											} 
-										}
-									}
-									continue;
-								}
-								List<Coord> otherPoints = connectedWay.getPoints();
-								Coord otherFirst = otherPoints.get(0);
-								Coord otherLast = otherPoints.get(otherPoints.size()-1);
-								if (otherFirst == otherLast || connectedWay.tagIsLikeYes(onewayTagKey) == false)
-									isDeadEnd = false;  
-								else {
-									Coord pOther;
-									if (pos != 0)
-										pOther = otherLast;
-									else
-										pOther = otherFirst;
-									if (p != pOther){
-										// way is connected to a point on a oneway which allows going on
-										isDeadEnd = false;
-									}
-								}
-							}
-						}
-						
-						if (isDeadEnd && (isDeadEndOfMultipleWays || reportDeadEnds > 1)){
-							log.warn("Oneway road " + way.getId() + " with tags " + way.toTagString() + ((pos==0) ? " comes from":" goes to") + " nowhere at " + p.toOSMURL());
-						}
+				reportDeadEnds(cw, connectors, selfConnectors);
+			}
+			boolean onBoundary = false;
+			int countCon = 0;
+			for (Coord p:way.getPoints()){
+				if (p.getOnBoundary())
+					onBoundary = true;
+				if (p.getHighwayCount() > 1){
+					HashSet<Way> ways = connectors.get(p);
+					if (ways != null && ways.size() > 1){
+						++countCon;
 					}
 				}
 			}
-  			String replType = way.getTag("mkgmap:set_unconnected_type");
-			if (replType != null){
-				boolean isConnected = false;
-				boolean onBoundary = false;
-				for (Coord p:way.getPoints()){
-					if (p.getOnBoundary())
-						onBoundary = true;
-					if (p.getHighwayCount() > 1){
-						HashSet<Way> ways = connectors.get(p);
-						if (ways != null && ways.size() > 1){
-							isConnected = true;
-							break;
+			boolean remove = false;
+			if (countCon == 0) {
+				remove = handlePoorConnection("mkgmap:set_unconnected_type", cw, onBoundary);
+			} else if (countCon == 1) {
+				remove = handlePoorConnection("mkgmap:set_semi_connected_type", cw, onBoundary);
+			}
+			if (remove)
+				iter.remove();
+		}
+	}
+	
+	/**
+	 * When called, the way is either not connected to other roads or that it is only connected in one point.
+	 * Check if special tags exist which change the type.   
+	 * @param tagKey the tag key to check
+	 * @param cw the converted way
+	 * @param onBoundary if true, we don't don't change anything
+	 * @return true if the road should not be added to the map
+	 */
+	private boolean handlePoorConnection(String tagKey, ConvertedWay cw, boolean onBoundary) {
+		Way way = cw.getWay();
+		String replType = way.getTag(tagKey);
+		if (replType != null){
+			String msgStub;
+			if ("mkgmap:set_unconnected_type".equals(tagKey))
+				msgStub = "road not connected";
+			else 
+				msgStub = "road doesn't go";
+			if (onBoundary){
+				log.info(msgStub, "to other roads but is on boundary:", way.toBrowseURL());
+			} else {
+				if ("none".equals(replType))
+					log.info(msgStub, "to other roads, is ignored:", way.toBrowseURL());
+				else {
+					int typeNoConnection = -1;
+					try{
+						typeNoConnection = Integer.decode(replType);
+						if (GType.isRoutableLineType(typeNoConnection)){
+							typeNoConnection = -1;
+							log.error("type value in", tagKey, "should not be a routable type:" + replType);
 						}
+					} catch (NumberFormatException e){
+						log.warn("invalid type value in", tagKey+ ":", replType);
 					}
+					if (typeNoConnection != -1 ){
+						log.info(msgStub, "to other roads, added as line with type", replType + ":", way.toBrowseURL());
+						addLine(way, cw.getGType(), typeNoConnection);
+					} else {
+						log.warn(msgStub, "to other roads, but replacement type is invalid. Dropped:", way.toBrowseURL());
+					}
 				}
-				if (!isConnected){
-					if (onBoundary){
-						log.info("road not connected to other roads but is on boundary:", way.toBrowseURL());
-					} else {
-						if ("none".equals(replType))
-							log.info("road not connected to other roads, is ignored:", way.toBrowseURL());
-						else {
-							int typeNoConnection = -1;
-							try{
-								typeNoConnection = Integer.decode(replType);
-								if (GType.isRoutableLineType(typeNoConnection)){
-									typeNoConnection = -1;
-									log.error("type value in mkgmap:set_unconnected_type should not be a routable type:" + replType);
+				return true; // don't add road to map
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Check if oneway roads don't allow to continue at the end.  
+	 * @param cw the converted way
+	 * @param connectors set of nodes where roads are connected
+	 * @param selfConnectors set of nodes where roads have loops (rings or p-shapes)
+	 */
+	private void reportDeadEnds(ConvertedWay cw, Map<Coord, HashSet<Way>> connectors, HashSet<Way> selfConnectors) {
+		Way way = cw.getWay();
+		// report dead ends of oneway roads 
+		if (cw.isOneway() && !way.tagIsLikeNo("mkgmap:dead-end-check")) {
+			List<Coord> points = way.getPoints();
+			int[] pointsToCheck = {0, points.size()-1};
+			if (points.get(pointsToCheck[0]) == points.get(pointsToCheck[1]))
+				return; // skip closed way
+			for (int pos: pointsToCheck ){
+				boolean isDeadEnd = true;
+				boolean isDeadEndOfMultipleWays = true;
+				Coord p = points.get(pos);
+				if (bbox.contains(p) == false || p.getOnBoundary())
+					isDeadEnd = false;  // we don't know enough about possible connections 
+				else if (p.getHighwayCount() < 2){
+					isDeadEndOfMultipleWays = false;
+				} else {
+					HashSet<Way> ways = connectors.get(p);
+					if (ways.size() <= 1)
+						isDeadEndOfMultipleWays = false;
+					for (Way connectedWay: ways){
+						if (!isDeadEnd)
+							break;
+						if (way == connectedWay){
+							if (selfConnectors.contains(way)){
+								// this might be a P-shaped oneway,
+								// check if it has other exists in the loop part
+								if (pos == 0){
+									for (int k = pos+1; k < points.size()-1; k++){
+										Coord pTest = points.get(k);
+										if (pTest == p)
+											break; // found no other exit
+										if (pTest.getHighwayCount() > 1){
+											isDeadEnd = false;
+											break;
+										}
+									} 
+
+								}else {
+									for (int k = pos-1; k >= 0; k--){
+										Coord pTest = points.get(k);
+										if (pTest == p)
+											break; // found no other exit
+										if (pTest.getHighwayCount() > 1){
+											isDeadEnd = false;
+											break;
+										}
+									} 
 								}
-							} catch (NumberFormatException e){
-								log.warn("invalid type value in mkgmap:set_unconnected_type:", replType);
 							}
-							if (typeNoConnection != -1 ){
-								log.info("road not connected to other roads, added as line with type", replType + ":", way.toBrowseURL());
-								addLine(way, cw.getGType(), typeNoConnection);
-							} else {
-								log.warn("road not connected to other roads, but replacement type is invalid. Dropped:", way.toBrowseURL());
+							continue;
+						}
+						List<Coord> otherPoints = connectedWay.getPoints();
+						Coord otherFirst = otherPoints.get(0);
+						Coord otherLast = otherPoints.get(otherPoints.size()-1);
+						if (otherFirst == otherLast || connectedWay.tagIsLikeYes(onewayTagKey) == false)
+							isDeadEnd = false;  
+						else {
+							Coord pOther;
+							if (pos != 0)
+								pOther = otherLast;
+							else
+								pOther = otherFirst;
+							if (p != pOther){
+								// way is connected to a point on a oneway which allows going on
+								isDeadEnd = false;
 							}
 						}
-						iter.remove();
 					}
 				}
+				
+				if (isDeadEnd && (isDeadEndOfMultipleWays || reportDeadEnds > 1)){
+					log.warn("Oneway road " + way.getId() + " with tags " + way.toTagString() + ((pos==0) ? " comes from":" goes to") + " nowhere at " + p.toOSMURL());
+				}
 			}
-		}
+		}	
 	}
-	
 	/**
 	 * Make sure that only CoordPOI which affect routing will be treated as
 	 * nodes in the following routines.
