From d9a41a4f1492200abd637ca386f93a2153788f0a Mon Sep 17 00:00:00 2001 From: Andy Townsend Date: Wed, 15 Jan 2014 23:41:40 +0000 Subject: [PATCH] Added -id= parameter to support downloading one changset. --- README.md | 3 ++ src/Changeset1.java | 76 +++++++++++++++++++++++++++++++++++++++------ 2 files changed, 70 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3edebe5..f396a0d 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,9 @@ Specifies a user's display name to search for changesets for. It will be URLenc ### -user=112 Specifies a user's userid to search for changesets for. Useful for when display names change, or when they contain characters that can't easily be passed from the command line. +### -id=37428 +Specifies a changeset id to download. Use this instead of -display_name=, -user= or -time= to examine one specific changeset. + ### -time="2013-11-04T20:53" The time, specified in a way that the API will understand, to search for changesets from. diff --git a/src/Changeset1.java b/src/Changeset1.java index 2d6da1e..bb72dae 100644 --- a/src/Changeset1.java +++ b/src/Changeset1.java @@ -34,6 +34,7 @@ public class Changeset1 final static String param_output = "-output="; final static String param_display_name = "-display_name="; final static String param_uid = "-user="; + final static String param_id = "-id="; final static String param_time = "-time="; final static String param_dev = "-dev"; final static String param_debug = "-debug="; @@ -1336,6 +1337,24 @@ static void process_time( String passed_time, } + static void process_id( String passed_id, + String passed_min_lat_string, String passed_min_lon_string, String passed_max_lat_string, String passed_max_lon_string, + String passed_download_changeset, String passed_building, boolean passed_overlapnodes, String passed_download_nodes ) throws Exception + { + if ( arg_debug >= Log_Low_Routine_Start ) + { + System.out.println( "process_id" ); + } + + URL url; + url = new URL( api_path + "changeset/" + passed_id ); + + process_changesets_url_common( url, "Any User", "", + passed_min_lat_string, passed_min_lon_string, passed_max_lat_string, passed_max_lon_string, + passed_download_changeset, passed_building, passed_overlapnodes, passed_download_nodes ); + } + + /** * get_line_param * @@ -1397,6 +1416,7 @@ static String get_line_string_param( String passed_param, String passed_in_line * param_output = "-output="; * param_display_name = "-display_name="; * param_uid = "-user="; + * param_id = "-id="; * param_time = "-time="; * param_dev = "-dev"; * param_debug = "-debug="; @@ -1414,6 +1434,7 @@ public static void main(String[] args) throws Exception { String arg_display_name = ""; String arg_uid = ""; + String arg_id = ""; String arg_time = ""; /* ------------------------------------------------------------------------------ @@ -1521,7 +1542,7 @@ public static void main(String[] args) throws Exception } // -display_name /* ------------------------------------------------------------------------------ - * The user that we're interested in changesets for - userid + * The user that we're interested in changesets for - uid * ------------------------------------------------------------------------------ */ if ( args[i].startsWith( param_uid )) { @@ -1534,6 +1555,20 @@ public static void main(String[] args) throws Exception } } // -uid +/* ------------------------------------------------------------------------------ + * The changeset number that we're interested in changesets for - id + * ------------------------------------------------------------------------------ */ + if ( args[i].startsWith( param_id )) + { + arg_id = args[i].substring( param_id.length() ); + + if ( arg_debug >= Log_Informational_2 ) + { + System.out.println( "arg_id: " + arg_id ); + System.out.println( "arg_id length: " + arg_id.length() ); + } + } // -id + /* ------------------------------------------------------------------------------ * The time to start looking for changesets from * ------------------------------------------------------------------------------ */ @@ -1770,19 +1805,29 @@ public static void main(String[] args) throws Exception { if ( arg_time.length() == 0 ) { + if ( arg_id.length() == 0 ) + { /* ------------------------------------------------------------------------------ * None of the parameters that we would have expect to have been passed were, * so show the help screen, if we haven't already been asked to do so. * ------------------------------------------------------------------------------ */ - if ( arg_debug >= Log_Informational_2 ) - { - System.out.println( "None of display_name, user or time passed" ); - System.out.println( "" ); + if ( arg_debug >= Log_Informational_2 ) + { + System.out.println( "None of display_name, user, id or time passed" ); + System.out.println( "" ); + } + + if ( arg_help == false ) + { + show_help(); + } } - - if ( arg_help == false ) - { - show_help(); + else + { // We've been passed a specific changeset id + process_id( arg_id, arg_min_lat_string, arg_min_lon_string, + arg_max_lat_string, arg_max_lon_string, + arg_download_changeset, arg_building, + arg_overlapnodes, arg_download_nodes ); } } else @@ -1864,6 +1909,7 @@ public static void main(String[] args) throws Exception String in_line = ""; String line_display_name = ""; String line_uid = ""; + String line_id = ""; String line_time = ""; String line_bbox = ""; String line_min_lat_string = ""; @@ -1906,6 +1952,18 @@ public static void main(String[] args) throws Exception line_uid = arg_uid; } + line_id = get_line_string_param( param_id, in_line ); + + if ( arg_debug >= Log_Informational_2 ) + { + System.out.println( "line_id: " + line_id ); + } + + if ( line_id.equals( "" )) + { + line_id = arg_id; + } + line_time = get_line_string_param( param_time, in_line ); if ( arg_debug >= Log_Informational_2 )