Skip to content

Commit

Permalink
Performance increase and other goodies
Browse files Browse the repository at this point in the history
- Performance increase on processing duplicates
- Automated OSM login (fixes #2 kind of)
- Info on what is processing in duplicates
  • Loading branch information
james2432 committed Sep 28, 2016
1 parent 7f3722f commit 8258269
Show file tree
Hide file tree
Showing 8 changed files with 471 additions and 879 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}


}
21 changes: 18 additions & 3 deletions OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JFMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @author Jamie Nadeau
*/
public class JFMain extends javax.swing.JFrame {

static JPInfoBox jib = new JPInfoBox();
/**
* Creates new form JFMain
*/
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
});
Expand Down
55 changes: 55 additions & 0 deletions OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[623, 150]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jlProcessing" pref="426" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jlProcessing" alignment="3" min="-2" pref="47" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="78" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Currently Processing:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jlProcessing">
</Component>
</SubComponents>
</Form>
73 changes: 73 additions & 0 deletions OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPInfoBox.java
Original file line number Diff line number Diff line change
@@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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
}
42 changes: 21 additions & 21 deletions OSVUploadr/src/main/java/ca/osmcanada/osvuploadr/JPMain.form
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="24" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jButton1" max="32767" attributes="0"/>
<Component id="jButton5" max="32767" attributes="0"/>
<Component id="jbAdd" max="32767" attributes="0"/>
<Component id="jbRemove" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jButton2" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jButton3" alignment="1" min="-2" pref="123" max="-2" attributes="0"/>
<Component id="jButton4" alignment="1" min="-2" pref="123" max="-2" attributes="0"/>
<Component id="jbRemoveDup" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jbUpload" alignment="1" min="-2" pref="123" max="-2" attributes="0"/>
<Component id="jbExit" alignment="1" min="-2" pref="123" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
Expand All @@ -53,16 +53,16 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="listDir" min="-2" pref="222" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jbAdd" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButton5" min="-2" max="-2" attributes="0"/>
<Component id="jbRemove" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
<Component id="jbRemoveDup" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButton3" min="-2" max="-2" attributes="0"/>
<Component id="jbUpload" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jButton4" min="-2" max="-2" attributes="0"/>
<Component id="jbExit" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="41" max="32767" attributes="0"/>
Expand All @@ -71,7 +71,7 @@
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Component class="javax.swing.JButton" name="jbAdd">
<Properties>
<Property name="text" type="java.lang.String" value="Add Folder"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
Expand All @@ -85,7 +85,7 @@
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbAddActionPerformed"/>
</Events>
</Component>
<Component class="java.awt.List" name="listDir">
Expand All @@ -101,15 +101,15 @@
<Property name="text" type="java.lang.String" value="Directories"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jButton2">
<Component class="javax.swing.JButton" name="jbRemoveDup">
<Properties>
<Property name="text" type="java.lang.String" value="Remove Duplicates"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbRemoveDupActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton3">
<Component class="javax.swing.JButton" name="jbUpload">
<Properties>
<Property name="text" type="java.lang.String" value="Upload"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
Expand All @@ -120,10 +120,10 @@
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbUploadActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton4">
<Component class="javax.swing.JButton" name="jbExit">
<Properties>
<Property name="text" type="java.lang.String" value="Exit"/>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
Expand All @@ -134,15 +134,15 @@
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbExitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jButton5">
<Component class="javax.swing.JButton" name="jbRemove">
<Properties>
<Property name="text" type="java.lang.String" value="Remove Folder"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton5ActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbRemoveActionPerformed"/>
</Events>
</Component>
</SubComponents>
Expand Down
Loading

0 comments on commit 8258269

Please sign in to comment.