1.0 Release
This commit is contained in:
commit
8bf67d2af0
6
KMLConverter/.classpath
Normal file
6
KMLConverter/.classpath
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
13
KMLConverter/.externalToolBuilders/New_Builder (4).launch
Normal file
13
KMLConverter/.externalToolBuilders/New_Builder (4).launch
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
|
||||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="KMLConverter"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/KMLConverter/projectBuilder.xml}"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/>
|
||||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
|
||||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/KMLConverter}"/>
|
||||
</launchConfiguration>
|
27
KMLConverter/.project
Normal file
27
KMLConverter/.project
Normal file
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>KMLConverter</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
|
||||
<triggers>full,incremental,</triggers>
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/New_Builder (4).launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
11
KMLConverter/.settings/org.eclipse.jdt.core.prefs
Normal file
11
KMLConverter/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,11 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
BIN
KMLConverter/KMLConverter.jar
Normal file
BIN
KMLConverter/KMLConverter.jar
Normal file
Binary file not shown.
1
KMLConverter/bin/.gitignore
vendored
Normal file
1
KMLConverter/bin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/sig/
|
2
KMLConverter/input.txt
Normal file
2
KMLConverter/input.txt
Normal file
@ -0,0 +1,2 @@
|
||||
-97.998046875,31.503629305773032
|
||||
-96.998046875ABCDEFG31.503629305773032
|
16
KMLConverter/map_locations.txt
Normal file
16
KMLConverter/map_locations.txt
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://earth.google.com/kml/2.2">
|
||||
<Placemark>
|
||||
<Point>
|
||||
<coordinates>-97.998046875,31.503629305773032,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
|
||||
|
||||
<Placemark>
|
||||
<Point>
|
||||
<coordinates>-96.998046875,31.503629305773032,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
|
||||
</kml>
|
16
KMLConverter/output.txt
Normal file
16
KMLConverter/output.txt
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kml xmlns="http://earth.google.com/kml/2.2">
|
||||
<Placemark>
|
||||
<Point>
|
||||
<coordinates>-97.998046875,31.503629305773032,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
|
||||
|
||||
<Placemark>
|
||||
<Point>
|
||||
<coordinates>-96.998046875,31.503629305773032,0</coordinates>
|
||||
</Point>
|
||||
</Placemark>
|
||||
|
||||
</kml>
|
18
KMLConverter/projectBuilder.xml
Normal file
18
KMLConverter/projectBuilder.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project default="create_run_jar" name="Create Runnable Jar for Project KML Converter">
|
||||
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
|
||||
<!--ANT 1.7 is required -->
|
||||
<!--define folder properties-->
|
||||
<property name="dir.buildfile" value="."/>
|
||||
<property name="dir.workspace" value="${dir.buildfile}/.."/>
|
||||
<property name="dir.jarfile" value="${dir.buildfile}"/>
|
||||
<target name="create_run_jar">
|
||||
<jar destfile="${dir.jarfile}/KMLConverter.jar" filesetmanifest="mergewithoutmain">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="sig.kml.KMLConverter"/>
|
||||
<attribute name="Class-Path" value="."/>
|
||||
</manifest>
|
||||
<fileset dir="${dir.jarfile}/bin"/>
|
||||
</jar>
|
||||
</target>
|
||||
</project>
|
99
KMLConverter/src/sig/kml/KMLConverter.java
Normal file
99
KMLConverter/src/sig/kml/KMLConverter.java
Normal file
@ -0,0 +1,99 @@
|
||||
package sig.kml;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class KMLConverter {
|
||||
final static String TEMPLATE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
|
||||
+ "<kml xmlns=\"http://earth.google.com/kml/2.2\">\n"
|
||||
+ "{MARKERS}"
|
||||
+ "</kml>\n";
|
||||
final static String MARKER_TEMPLATE = "<Placemark>\n"
|
||||
+ "<Point>\n"
|
||||
+ "<coordinates>{COORDINATES}</coordinates>\n"
|
||||
+ "</Point>\n"
|
||||
+ "</Placemark>\n";
|
||||
|
||||
static KMLWindow window;
|
||||
|
||||
KMLConverter(String input_fileloc, String output_fileloc) {
|
||||
String markers = "";
|
||||
|
||||
File f = new File(input_fileloc);
|
||||
Scanner reader;
|
||||
int datapoints = 0;
|
||||
try {
|
||||
reader = new Scanner(f);
|
||||
double numb1,numb2;
|
||||
window.addStatusMessage("Reading file from "+input_fileloc+"...");
|
||||
while (reader.hasNextLine()) {
|
||||
String nextLine = reader.nextLine();
|
||||
try {
|
||||
Point2D.Double vals = SplitLine(nextLine);
|
||||
numb1 = vals.x;
|
||||
numb2 = vals.y;
|
||||
window.addStatusMessage("Read coords ("+(datapoints+1)+"): ["+numb1+","+numb2+"]");
|
||||
markers = ((markers.length()>0)?markers+"\n":"")+MARKER_TEMPLATE.replace("{COORDINATES}", numb1+","+numb2+",0")+"\n";
|
||||
datapoints++;
|
||||
} catch (NumberFormatException e) {}
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
String output = TEMPLATE.replace("{MARKERS}", markers);
|
||||
|
||||
window.addStatusMessage("File written to "+output_fileloc+".");
|
||||
window.addStatusMessage("Conversion is complete! Translated file with "+datapoints+" coordinates. Copied to clipboard.");
|
||||
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
StringSelection output_selection = new StringSelection(output);
|
||||
c.setContents(output_selection, null);
|
||||
File f_out = new File(output_fileloc);
|
||||
try {
|
||||
FileWriter fw = new FileWriter(f_out);
|
||||
fw.write(output);
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
javax.swing.SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
window = new KMLWindow();
|
||||
}
|
||||
});
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
static Point2D.Double SplitLine(String str) throws NumberFormatException{
|
||||
double numb1=0,numb2=0;
|
||||
Pattern regex = Pattern.compile("(-?\\d+\\.\\d+)[^\\d-]*(-?\\d+\\.\\d+)");
|
||||
Matcher m = regex.matcher(str);
|
||||
if (m.find()) {
|
||||
numb1 = Double.valueOf(m.group(1));
|
||||
numb2 = Double.valueOf(m.group(2));
|
||||
} else {
|
||||
//This is bad.
|
||||
}
|
||||
return new Point2D.Double(numb1,numb2);
|
||||
}
|
||||
|
||||
static boolean isNumeric(char c) {
|
||||
return c=='-' || c=='.' || (c>='0' && c<='9');
|
||||
}
|
||||
}
|
173
KMLConverter/src/sig/kml/KMLWindow.java
Normal file
173
KMLConverter/src/sig/kml/KMLWindow.java
Normal file
@ -0,0 +1,173 @@
|
||||
package sig.kml;
|
||||
|
||||
import java.awt.Button;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.Box;
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JTextArea;
|
||||
|
||||
public class KMLWindow extends JFrame{
|
||||
JFrame f = new JFrame("KMLConverter 1.0");
|
||||
String input_fileloc="./input.txt", output_fileloc="./output.txt";
|
||||
ButtonLabel input = null,output = null;
|
||||
JTextArea status_window = null;
|
||||
JScrollPane pane;
|
||||
JPanel panel = new JPanel();
|
||||
KMLWindow() {
|
||||
try {
|
||||
input=new ButtonLabel("Browse...",new File(".").getCanonicalPath(),"Input",this);
|
||||
output=new ButtonLabel("Browse...",new File(".").getCanonicalPath(),"Output",this);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
ActionListener convert_action = new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
new KMLConverter(input_fileloc,output_fileloc);
|
||||
}
|
||||
};
|
||||
|
||||
JButton convert_but = new JButton("Convert");
|
||||
convert_but.setMinimumSize(new Dimension(128,24));
|
||||
convert_but.addActionListener(convert_action);
|
||||
|
||||
|
||||
status_window = new JTextArea(8,32);
|
||||
status_window.setAutoscrolls(true);
|
||||
status_window.setEditable(false);
|
||||
status_window.setLineWrap(true);
|
||||
status_window.setWrapStyleWord(true);
|
||||
status_window.setBackground(new Color(0,0,96));
|
||||
status_window.setForeground(new Color(220,220,220));
|
||||
|
||||
pane = new JScrollPane(status_window);
|
||||
pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
pane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
pane.setPreferredSize(new Dimension(320,64));
|
||||
panel.setLayout(new BoxLayout(panel,BoxLayout.PAGE_AXIS));
|
||||
input.Initialize(panel);
|
||||
output.Initialize(panel);
|
||||
panel.add(Box.createVerticalStrut(6));
|
||||
panel.add(new JSeparator());
|
||||
panel.add(Box.createVerticalStrut(6));
|
||||
JPanel window_panel = new JPanel();
|
||||
window_panel.setLayout(new BoxLayout(window_panel,BoxLayout.LINE_AXIS));
|
||||
window_panel.add(pane);
|
||||
|
||||
panel.add(window_panel);
|
||||
panel.add(Box.createVerticalStrut(6));
|
||||
panel.add(new JSeparator());
|
||||
panel.add(Box.createVerticalStrut(6));
|
||||
panel.add(convert_but);
|
||||
panel.setBackground(new Color(170,180,200));
|
||||
|
||||
f.add(panel);
|
||||
f.pack();
|
||||
f.setLocationByPlatform(true);
|
||||
f.setSize(640, 240);
|
||||
f.setVisible(true);
|
||||
}
|
||||
|
||||
public void addStatusMessage(String msg) {
|
||||
status_window.setText(status_window.getText()+"\n"+msg);
|
||||
}
|
||||
}
|
||||
|
||||
class ButtonLabel{
|
||||
private KMLWindow parent;
|
||||
private JButton b = new JButton();
|
||||
private JLabel l = new JLabel();
|
||||
private JPanel panel = new JPanel();
|
||||
private String label_type = "";
|
||||
private String label_header = "";
|
||||
private ActionListener listener;
|
||||
ButtonLabel(String button_label,String label_text, String label_type,KMLWindow parent) {
|
||||
this.parent=parent;
|
||||
listener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser browse = new JFileChooser();
|
||||
browse.setDialogTitle("Select "+e.getActionCommand()+" File");
|
||||
switch (e.getActionCommand()) {
|
||||
case "Input":{
|
||||
File f = new File(parent.input_fileloc);
|
||||
if (!f.exists()) {
|
||||
try {
|
||||
f.createNewFile();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}}
|
||||
browse.setCurrentDirectory(f);
|
||||
}break;
|
||||
case "Output":{
|
||||
File f = new File(parent.output_fileloc);
|
||||
if (!f.exists()) {
|
||||
try {
|
||||
f.createNewFile();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}}
|
||||
browse.setCurrentDirectory(f);
|
||||
}break;
|
||||
}
|
||||
if (browse.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||
String fileloc = browse.getSelectedFile().getAbsolutePath();
|
||||
try {
|
||||
String path = new File(fileloc).getCanonicalPath();
|
||||
l.setText(label_header+path);
|
||||
switch (e.getActionCommand()) {
|
||||
case "Input":{
|
||||
parent.input_fileloc = fileloc;
|
||||
parent.addStatusMessage("New Input File Location: "+fileloc);
|
||||
}break;
|
||||
case "Output":{
|
||||
parent.output_fileloc = fileloc;
|
||||
parent.addStatusMessage("New Output File Location: "+fileloc);
|
||||
}break;
|
||||
}
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
label_header = label_type+": ";
|
||||
b.setText(button_label);
|
||||
b.setActionCommand(label_type);
|
||||
b.addActionListener(listener);
|
||||
l.setText(label_header+label_text);
|
||||
panel.setLayout(new BoxLayout(panel,BoxLayout.LINE_AXIS));
|
||||
panel.setBackground(new Color(170,180,200));
|
||||
l.setBackground(new Color(170,180,200));
|
||||
this.label_type = label_type;
|
||||
}
|
||||
|
||||
JButton getButton() {
|
||||
return b;
|
||||
}
|
||||
JLabel getLabel() {
|
||||
return l;
|
||||
}
|
||||
|
||||
void Initialize(JPanel p) {
|
||||
panel.add(Box.createHorizontalStrut(32));
|
||||
panel.add(l);
|
||||
panel.add(Box.createHorizontalStrut(64));
|
||||
panel.add(b);
|
||||
p.add(panel);
|
||||
}
|
||||
}
|
2
KMLConverter/test.txt
Normal file
2
KMLConverter/test.txt
Normal file
@ -0,0 +1,2 @@
|
||||
-97.998046875,31.503629305773032
|
||||
-96.998046875ABCDEFG31.503629305773032
|
Loading…
x
Reference in New Issue
Block a user