diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/API/OSMApi.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/API/OSMApi.java
index 3320e9e..d5a992e 100644
--- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/API/OSMApi.java
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/API/OSMApi.java
@@ -11,7 +11,7 @@
* @author Jamie Nadeau
*/
public class OSMApi extends DefaultApi10a {
- private static final String AUTHORIZE_URL = "http://www.openstreetmap.org/oauth/authorize?oauth_token=%s";
+ private static final String AUTHORIZE_URL = "https://www.openstreetmap.org/oauth/authorize?oauth_token=%s";
private static final String REQUEST_TOKEN_RESOURCE = "www.openstreetmap.org/oauth/request_token";
private static final String ACCESS_TOKEN_RESOURCE = "www.openstreetmap.org/oauth/access_token";
diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/FolderCleaner.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/FolderCleaner.java
index 05721b4..675e859 100644
--- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/FolderCleaner.java
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/FolderCleaner.java
@@ -32,6 +32,7 @@ public class FolderCleaner {
int dist_threshold = 4; // Minimum distance a photo should move to not be considered a duplicate (in meters)
int radius_threshold = 20; // Minimum turn radius a photo should move to not be considered a duplicate (degrees)
String duplicate_folder="duplicates";
+ JFMain info=null;
private double calc_distance(double lon1, double lat1, double lon2, double lat2){
//haversine formula
@@ -85,6 +86,9 @@ public int compare(File f1, File f2)
}});
for(File f:file_list){
+ if(info!=null){
+ info.SetInfoBoxText(f.getPath());
+ }
ImageProperties imp = Helper.getImageProperties(f);
if(is_first){
is_first=false;
@@ -151,10 +155,18 @@ public void RemoveDuplicates(){
}
}
do_science();
+ if(info!=null){
+ info.SetInfoBoxText("Done");
+ }
+ }
+
+ public void setInfoBox(JFMain frame){
+ info=frame;
}
public FolderCleaner(String Folder){
_folder=Folder;
}
+
}
diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JFMain.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JFMain.java
index 799f3ee..c1fb2db 100644
--- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JFMain.java
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JFMain.java
@@ -12,7 +12,7 @@
* @author Jamie Nadeau
*/
public class JFMain extends javax.swing.JFrame {
-
+ static JPInfoBox jib = new JPInfoBox();
/**
* Creates new form JFMain
*/
@@ -22,7 +22,20 @@ public JFMain() {
this.setSize(640,320);
this.setTitle("OSVUploadr");
}
-
+
+ public void ShowInfoBox(){
+ jib.setVisible(true);
+ this.setSize(640,470);
+ this.pack();
+ }
+ public void HideInfoBox(){
+ jib.setVisible(false);
+ this.setSize(640,320);
+ }
+
+ public void SetInfoBoxText(String str){
+ jib.SetProcessingText(str);
+ }
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
@@ -81,7 +94,9 @@ public void run() {
JFMain jf =new JFMain();
JPMain jp = new JPMain();
jp.setVisible(true);
- jf.add(jp,BorderLayout.CENTER);
+ jib.setVisible(false);
+ jf.add(jp,BorderLayout.NORTH);
+ jf.add(jib,BorderLayout.SOUTH);
jf.setVisible(true);
}
});
diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form
new file mode 100644
index 0000000..348d4e1
--- /dev/null
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form
@@ -0,0 +1,55 @@
+
+
+
diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java
new file mode 100644
index 0000000..0f1ac45
--- /dev/null
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java
@@ -0,0 +1,73 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package ca.osmcanada.osvuploadr;
+
+import javax.swing.UIManager;
+
+/**
+ *
+ * @author Nadeaj
+ */
+public class JPInfoBox extends javax.swing.JPanel {
+
+ /**
+ * Creates new form JPInfoBox
+ */
+ public JPInfoBox() {
+ try{
+ UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
+ }
+ catch(Exception ex){}
+ initComponents();
+ }
+
+ public void SetProcessingText(String str){
+ jlProcessing.setText(str);
+ }
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ jlProcessing = new javax.swing.JLabel();
+
+ setPreferredSize(new java.awt.Dimension(623, 150));
+
+ jLabel1.setText("Currently Processing:");
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel1)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jlProcessing, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
+ .addContainerGap())
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(jlProcessing, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(78, Short.MAX_VALUE))
+ );
+ }// //GEN-END:initComponents
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jlProcessing;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.form b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.form
index f8418b0..daddf51 100644
--- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.form
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.form
@@ -26,16 +26,16 @@
-
-
+
+
-
-
-
+
+
+
@@ -53,16 +53,16 @@
-
-
+
+
-
+
-
+
-
+
-
+
@@ -71,7 +71,7 @@
-
+
@@ -85,7 +85,7 @@
-
+
@@ -101,15 +101,15 @@
-
+
-
+
-
+
@@ -120,10 +120,10 @@
-
+
-
+
@@ -134,15 +134,15 @@
-
+
-
+
-
+
diff --git a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java
index e63e0e4..382d7ed 100644
--- a/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java
+++ b/OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.java
@@ -30,7 +30,6 @@
import java.util.Comparator;
import java.util.List;
import ca.osmcanada.osvuploadr.struct.ImageProperties;
-import com.drew.metadata.exif.ExifSubIFDDirectory;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -49,21 +48,25 @@
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import ca.osmcanada.osvuploadr.Utils.*;
import ca.osmcanada.osvuploadr.struct.PageContent;
+import java.nio.charset.Charset;
import org.apache.http.client.HttpClient;
-import org.apache.http.HttpException;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.CookieStore;
+import org.apache.http.cookie.Cookie;
+import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.HttpClientBuilder;
+
/**
*
* @author Jamie Nadeau
*/
public class JPMain extends javax.swing.JPanel {
- private final String BASE_URL="http://www.openstreetmap.org/";
+ private final String BASE_URL="https://www.openstreetmap.org/";
private final String URL_SEQUENCE = "http://openstreetview.com/1.0/sequence/";
private final String URL_PHOTO = "http://openstreetview.com/1.0/photo/";
private final String URL_FINISH = "http://openstreetview.com/1.0/sequence/finished-uploading/";
@@ -94,11 +97,95 @@ public String GetOSMUser(String usr, String psw)throws IOException{
//Automated grant and login***************************************
//Get logon form
- HttpClient client = HttpClientBuilder.create().build();
+ CookieStore httpCookieStore = new BasicCookieStore();
+ HttpClient client = HttpClientBuilder.create().setDefaultCookieStore(httpCookieStore).build();
//post.setHeader("User-Agent", USER_AGENT);
try{
PageContent pc = Helper.GetPageContent(url,client);
- System.out.println(pc.GetPage());
+
+ List cookies = httpCookieStore.getCookies();
+ System.out.println("Getting OSM Login page");
+ String page = pc.GetPage();
+
+ System.out.println("Sending username and password");
+
+ int start_indx = page.indexOf("value=\"",page.indexOf("name=\"authenticity_token\""))+7;
+ int end_indx = page.indexOf("\"",start_indx);
+
+ String utf8 = "✓";
+ String authenticity_token = page.substring(start_indx,end_indx);
+
+ start_indx = page.indexOf("value=\"",page.indexOf("name=\"referer\""))+7;
+ end_indx = page.indexOf("\"",start_indx);
+ String referer = page.substring(start_indx,end_indx);
+
+ Map arguments = new HashMap<>();
+ arguments.put("utf8", utf8);
+ arguments.put("authenticity_token", authenticity_token);
+ arguments.put("referer", referer);
+ arguments.put("username", usr);
+ arguments.put("password", psw);
+ arguments.put("commit", "Login");
+ arguments.put("openid_url", "");
+
+ System.out.println("Logging in");
+ page = sendForm(BASE_URL+"login",arguments,"POST",cookies);
+
+
+
+ //Proccessing grant access page
+ System.out.println("Processing Granting Access page");
+ start_indx = page.indexOf("