From dae7a40dff46cfb0990bec5448d06b63f678dcb5 Mon Sep 17 00:00:00 2001 From: biswesh456 Date: Wed, 22 Aug 2018 16:16:57 +0530 Subject: [PATCH] Change query --- .../actions/MendRelationAction.java | 53 +++++++++++-------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/src/org/openstreetmap/josm/plugins/pt_assistant/actions/MendRelationAction.java b/src/org/openstreetmap/josm/plugins/pt_assistant/actions/MendRelationAction.java index 9d789970..30f9328a 100644 --- a/src/org/openstreetmap/josm/plugins/pt_assistant/actions/MendRelationAction.java +++ b/src/org/openstreetmap/josm/plugins/pt_assistant/actions/MendRelationAction.java @@ -122,18 +122,19 @@ public MendRelationAction(IRelationEditorActionAccess editorAccess) { OsmDataLayer layer = editor.getLayer(); this.relation = editor.getRelation(); editor.addWindowListener(new WindowEventHandler()); -// QUERY = "[out:xml][timeout:180][bbox:{{bbox}}];\n" + "(\n" + " (\n" -// + " way[\"highway\"][\"highway\"!=\"footway\"][\"highway\"!=\"path\"][\"highway\"!=\"cycleway\"];\n" -// + " );\n" + " ._;<;\n" + ");\n" + "(._;>>;>;);\n" + "out meta;"; + // QUERY = "[out:xml][timeout:180][bbox:{{bbox}}];\n" + "(\n" + " (\n" + // + " + // way[\"highway\"][\"highway\"!=\"footway\"][\"highway\"!=\"path\"][\"highway\"!=\"cycleway\"];\n" + // + " );\n" + " ._;<;\n" + ");\n" + "(._;>>;>;);\n" + "out meta;"; } private String getQuery() { - String str = "[out:xml][timeout:200];\n" + "(\n" + " (\n"; + String str = "[timeout:100];\n" + "(\n" + " (\n"; - String str2 = " [\"highway\"]\n" + " [\"highway\"!=\"footway\"]\n" + " [\"highway\"!=\"path\"]\n" - + " [\"highway\"!=\"cycleway\"]\n" + " [\"highway\"!=\"service\"];\n" + "\n"; + String str2 = " [\"highway\"]" + "[\"highway\"!=\"footway\"]" + "[\"highway\"!=\"path\"]" + + "[\"highway\"!=\"cycleway\"]" + "\n"; - String str3 = " );\n" + " ._;<;\n" + ");\n" + "(._;>>;>;);\n" + "out meta;"; + String str3 = ");\n" + ");\n" + "(._;<;);\n" + "(._;>;);\n" + "out meta;"; List nodeList = getBrokenNodes(); @@ -225,7 +226,7 @@ void initialise() { halt = false; callNextWay(currentIndex); } -// callNextWay(currentIndex); + // callNextWay(currentIndex); } void downloadEntireArea() { @@ -380,7 +381,8 @@ Node checkValidityOfWays(Way way, int nextWayIndex) { } } - // check if there is a restricted relation that doesn't allow both the ways together + // check if there is a restricted relation that doesn't allow both the ways + // together if (node != null) { if (isRestricted(nextWay, way, node)) { nextWayDelete = true; @@ -1153,7 +1155,7 @@ void downloadAreaAroundWay(Way way, Node node1, Node node2) { if (abort) return; - if (downloadCounter > 160 || way.isOutsideDownloadArea() || way.isNew()){ + if (downloadCounter > 160 || way.isOutsideDownloadArea() || way.isNew()) { downloadCounter = 0; DownloadOsmTask task = new DownloadOsmTask(); @@ -1300,7 +1302,8 @@ void downloadAreaBeforeRemovalOption(List wayList, List Int) { boolean isRestricted(Way currentWay, Way previousWay, Node commonNode) { Set parentSet = previousWay.getParentRelations(previousWay.getNodes()); - if (parentSet == null || parentSet.isEmpty()) return false; + if (parentSet == null || parentSet.isEmpty()) + return false; List parentRelation = new ArrayList<>(parentSet); String[] restrictions = new String[] { "restriction", "restriction:bus", "restriction:trolleybus", @@ -1338,7 +1341,8 @@ else if (routeValue.equals(sub) && rel.hasKey("restriction:" + sub)) for (Relation r : parentRelation) { Collection prevMemberList = r.getMembersFor(Arrays.asList(previousWay)); Collection commonNodeList = r.getMembersFor(Arrays.asList(commonNode)); - // commonNode is not the node involved in the restriction relation then just continue + // commonNode is not the node involved in the restriction relation then just + // continue if (prevMemberList.isEmpty() || commonNodeList.isEmpty()) continue; @@ -1346,14 +1350,16 @@ else if (routeValue.equals(sub) && rel.hasKey("restriction:" + sub)) final String prevRole = prevMember.getRole(); if (prevRole.equals("from")) { - String[] acceptedTags = new String[] { "only_right_turn", "only_left_turn", "only_u_turn", "only_straight_on", - "only_entry", "only_exit" }; + String[] acceptedTags = new String[] { "only_right_turn", "only_left_turn", "only_u_turn", + "only_straight_on", "only_entry", "only_exit" }; for (String s : restrictions) { - // if we have any "only" type restrictions then the current way should be in the relation else it is restricted + // if we have any "only" type restrictions then the current way should be in the + // relation else it is restricted if (r.hasTag(s, acceptedTags)) { if (r.getMembersFor(Arrays.asList(currentWay)).isEmpty()) { for (String str : acceptedTags) { - if (r.hasTag(s,str)) notice = str + " restriction violated"; + if (r.hasTag(s, str)) + notice = str + " restriction violated"; } return true; } @@ -1381,7 +1387,8 @@ else if (routeValue.equals(sub) && rel.hasKey("restriction:" + sub)) for (String s : restrictions) if (r.hasTag(s, acceptedTags)) { for (String str : acceptedTags) { - if (r.hasTag(s,str)) notice = str + " restriction violated"; + if (r.hasTag(s, str)) + notice = str + " restriction violated"; } return true; } @@ -2203,13 +2210,15 @@ void drawVariants() { if (!shorterRoutes) drawFixVariantLetter("0 : turn-by-turn at next intersection", Color.ORANGE, letterX, letterY, 25); else - drawFixVariantLetter("0 : solutions based on other route relations", Color.PINK, letterX, letterY, 25); + drawFixVariantLetter("0 : solutions based on other route relations", Color.PINK, letterX, letterY, + 25); letterY = letterY + 60; } else if (showOption0) { if (!shorterRoutes) drawFixVariantLetter("W : turn-by-turn at next intersection", Color.ORANGE, letterX, letterY, 25); else - drawFixVariantLetter("W : solutions based on other route relations", Color.PINK, letterX, letterY, 25); + drawFixVariantLetter("W : solutions based on other route relations", Color.PINK, letterX, letterY, + 25); letterY = letterY + 60; } @@ -2294,13 +2303,15 @@ void drawMultipleVariants(HashMap> fixVariants) { if (!shorterRoutes) drawFixVariantLetter("0 : turn-by-turn at next intersection", Color.ORANGE, letterX, letterY, 25); else - drawFixVariantLetter("0 : solutions based on other route relations", Color.PINK, letterX, letterY, 25); + drawFixVariantLetter("0 : solutions based on other route relations", Color.PINK, letterX, letterY, + 25); letterY = letterY + 60; } else if (showOption0) { if (!shorterRoutes) drawFixVariantLetter("W : turn-by-turn at next intersection", Color.ORANGE, letterX, letterY, 25); else - drawFixVariantLetter("W : solutions based on other route relations", Color.PINK, letterX, letterY, 25); + drawFixVariantLetter("W : solutions based on other route relations", Color.PINK, letterX, letterY, + 25); letterY = letterY + 60; }