Changeset 29814 in osm for applications/editors/josm/plugins/mirrored_download/src
- Timestamp:
- 2013-08-02T17:08:41+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mirrored_download/src/mirrored_download/OverpassDownloadAction.java
r29648 r29814 110 110 return url; 111 111 } 112 113 private String completeOverpassQuery(String query) 114 { 115 int firstColon = query.indexOf(";"); 116 if (firstColon == -1) 117 return "[bbox];" + query; 118 int bboxPos = query.indexOf("[bbox"); 119 if (bboxPos > -1 && bboxPos < firstColon) 120 return query; 121 122 int bracketCount = 0; 123 int pos = 0; 124 for (; pos < firstColon; ++pos) 125 { 126 if (query.charAt(pos) == '[') 127 ++bracketCount; 128 else if (query.charAt(pos) == '[') 129 --bracketCount; 130 else if (bracketCount == 0) 131 { 132 if (!Character.isWhitespace(query.charAt(pos))) 133 break; 134 } 135 } 136 137 if (pos < firstColon) 138 // We start with a statement, not with declarations 139 return "[bbox];" + query; 140 141 // We start with declarations. Add just one more declaration in this case. 142 return "[bbox]" + query; 143 } 112 144 113 145 @Override 114 146 protected String getRequestForBbox(double lon1, double lat1, double lon2, double lat2) { 115 147 if (overpassQuery.isEmpty()) 116 return " xapi?" + super.getRequestForBbox(lon1, lat1, lon2, lat2);148 return "" + super.getRequestForBbox(lon1, lat1, lon2, lat2); 117 149 else 118 150 { 119 String url = "interpreter?data=" + overpassQuery + "&bbox=" + lon1 + "," + lat1 + "," + lon2 + "," + lat2;120 151 String realQuery = completeOverpassQuery(overpassQuery); 152 String url = "interpreter?data=" + realQuery + "&bbox=" + lon1 + "," + lat1 + "," + lon2 + "," + lat2; 121 153 try 122 154 { 123 url = "interpreter?data=" + URLEncoder.encode( overpassQuery, "UTF-8") + "&bbox=" + lon1 + "," + lat1 + "," + lon2 + "," + lat2;155 url = "interpreter?data=" + URLEncoder.encode(realQuery, "UTF-8") + "&bbox=" + lon1 + "," + lat1 + "," + lon2 + "," + lat2; 124 156 } 125 157 catch (UnsupportedEncodingException e) {}
Note:
See TracChangeset
for help on using the changeset viewer.