forked from JOSM/josm-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://svn.openstreetmap.org/applications/editors/josm/plugins@16176 b9d5c4c9-76e1-0310-9c85-f3177eceb1e4
- Loading branch information
stoecker
committed
Jun 27, 2009
1 parent
a358dc4
commit 851eee9
Showing
10 changed files
with
701 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>dataimport</name> | ||
<comment></comment> | ||
<projects> | ||
<project>JOSM</project> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#Thu Jun 11 10:15:06 CEST 2009 | ||
eclipse.preferences.version=1 | ||
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true | ||
sp_cleanup.add_default_serial_version_id=true | ||
sp_cleanup.add_generated_serial_version_id=false | ||
sp_cleanup.add_missing_annotations=true | ||
sp_cleanup.add_missing_deprecated_annotations=true | ||
sp_cleanup.add_missing_nls_tags=false | ||
sp_cleanup.add_missing_override_annotations=true | ||
sp_cleanup.add_serial_version_id=false | ||
sp_cleanup.always_use_blocks=false | ||
sp_cleanup.always_use_parentheses_in_expressions=false | ||
sp_cleanup.always_use_this_for_non_static_field_access=false | ||
sp_cleanup.always_use_this_for_non_static_method_access=false | ||
sp_cleanup.convert_to_enhanced_for_loop=false | ||
sp_cleanup.format_source_code=false | ||
sp_cleanup.make_local_variable_final=false | ||
sp_cleanup.make_parameters_final=false | ||
sp_cleanup.make_private_fields_final=true | ||
sp_cleanup.make_variable_declarations_final=true | ||
sp_cleanup.never_use_blocks=false | ||
sp_cleanup.never_use_parentheses_in_expressions=true | ||
sp_cleanup.on_save_use_additional_actions=true | ||
sp_cleanup.organize_imports=true | ||
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false | ||
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true | ||
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true | ||
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false | ||
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false | ||
sp_cleanup.remove_private_constructors=true | ||
sp_cleanup.remove_trailing_whitespaces=true | ||
sp_cleanup.remove_trailing_whitespaces_all=true | ||
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false | ||
sp_cleanup.remove_unnecessary_casts=true | ||
sp_cleanup.remove_unnecessary_nls_tags=false | ||
sp_cleanup.remove_unused_imports=true | ||
sp_cleanup.remove_unused_local_variables=false | ||
sp_cleanup.remove_unused_private_fields=true | ||
sp_cleanup.remove_unused_private_members=false | ||
sp_cleanup.remove_unused_private_methods=true | ||
sp_cleanup.remove_unused_private_types=true | ||
sp_cleanup.sort_members=false | ||
sp_cleanup.sort_members_all=false | ||
sp_cleanup.use_blocks=true | ||
sp_cleanup.use_blocks_only_for_return_and_throw=true | ||
sp_cleanup.use_parentheses_in_expressions=false | ||
sp_cleanup.use_this_for_non_static_field_access=false | ||
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true | ||
sp_cleanup.use_this_for_non_static_method_access=false | ||
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Thu Jun 11 10:15:07 CEST 2009 | ||
eclipse.preferences.version=1 | ||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
README | ||
====== | ||
|
||
This plugin adds additional file formats into file open dialog. | ||
|
||
Following file formats are support: | ||
|
||
- TangoGPS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
** This is a template build file for a JOSM plugin. | ||
** | ||
** Maintaining versions | ||
** ==================== | ||
** see README.template | ||
** | ||
** Usage | ||
** ===== | ||
** To build it run | ||
** | ||
** > ant dist | ||
** | ||
** To install the generated plugin locally (in you default plugin directory) run | ||
** | ||
** > ant install | ||
** | ||
** The generated plugin jar is not automatically available in JOSMs plugin configuration | ||
** dialog. You have to check it in first. | ||
** | ||
--> | ||
<project name="dataimport" default="dist" basedir="."> | ||
<!-- | ||
************************************************ | ||
** should not be necessary to change the following properties | ||
--> | ||
<property name="josm" location="../../core/dist/josm-custom.jar"/> | ||
<property name="plugin.build.dir" value="build"/> | ||
<property name="plugin.src.dir" value="src"/> | ||
<!-- this is the directory where the plugin jar is copied to --> | ||
<property name="plugin.dist.dir" value="../../dist"/> | ||
<property name="ant.build.javac.target" value="1.5"/> | ||
<property name="plugin.dist.dir" value="../../dist"/> | ||
<property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/> | ||
|
||
<!-- | ||
********************************************************** | ||
** init - initializes the build | ||
********************************************************** | ||
--> | ||
<target name="init"> | ||
<mkdir dir="${plugin.build.dir}"/> | ||
</target> | ||
|
||
<!-- | ||
********************************************************** | ||
** compile - complies the source tree | ||
********************************************************** | ||
--> | ||
<target name="compile" depends="init"> | ||
<echo message="compiling sources for ${plugin.jar} ... "/> | ||
<javac srcdir="src" classpath="${josm}" debug="true" destdir="${plugin.build.dir}"> | ||
<compilerarg value="-Xlint:deprecation"/> | ||
<compilerarg value="-Xlint:unchecked"/> | ||
</javac> | ||
</target> | ||
|
||
<!-- | ||
********************************************************** | ||
** dist - creates the plugin jar | ||
********************************************************** | ||
--> | ||
<target name="dist" depends="compile,revision"> | ||
<echo message="creating ${ant.project.name}.jar ... "/> | ||
<copy todir="${plugin.build.dir}"> | ||
<fileset dir="."> | ||
<include name="README" /> | ||
<include name="LICENSE" /> | ||
</fileset> | ||
</copy> | ||
<jar destfile="${plugin.jar}" basedir="${plugin.build.dir}"> | ||
<!-- | ||
************************************************ | ||
** configure these properties. Most of them will be copied to the plugins | ||
** manifest file. Property values will also show up in the list available | ||
** plugins: http://josm.openstreetmap.de/wiki/Plugins. | ||
** | ||
************************************************ | ||
--> | ||
<manifest> | ||
<attribute name="Author" value="Dieter Muecke"/> | ||
<attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.DataImport"/> | ||
<attribute name="Plugin-Date" value="${version.entry.commit.date}"/> | ||
<attribute name="Plugin-Description" value="Allows to import various file formats into JOSM directly."/> | ||
<attribute name="Plugin-Mainversion" value="1700"/> | ||
<attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> | ||
</manifest> | ||
</jar> | ||
</target> | ||
|
||
<!-- | ||
********************************************************** | ||
** revision - extracts the current revision number for the | ||
** file build.number and stores it in the XML property | ||
** version.* | ||
********************************************************** | ||
--> | ||
<target name="revision"> | ||
|
||
<exec append="false" output="REVISION" executable="svn" failifexecutionfails="false"> | ||
<env key="LANG" value="C"/> | ||
<arg value="info"/> | ||
<arg value="--xml"/> | ||
<arg value="."/> | ||
</exec> | ||
<xmlproperty file="REVISION" prefix="version" keepRoot="false" collapseAttributes="true"/> | ||
<delete file="REVISION"/> | ||
</target> | ||
|
||
<!-- | ||
********************************************************** | ||
** clean - clean up the build environment | ||
********************************************************** | ||
--> | ||
<target name="clean"> | ||
<delete dir="${plugin.build.dir}"/> | ||
<delete file="${plugin.jar}"/> | ||
</target> | ||
|
||
<!-- | ||
********************************************************** | ||
** install - install the plugin in your local JOSM installation | ||
********************************************************** | ||
--> | ||
<target name="install" depends="dist"> | ||
<property environment="env"/> | ||
<condition property="josm.plugins.dir" value="${env.APPDATA}/JOSM/plugins" else="${user.home}/.josm/plugins"> | ||
<and> | ||
<os family="windows"/> | ||
</and> | ||
</condition> | ||
<copy file="${plugin.jar}" todir="${josm.plugins.dir}"/> | ||
</target> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/** | ||
* | ||
*/ | ||
package org.openstreetmap.josm.io; | ||
|
||
import static org.openstreetmap.josm.tools.I18n.tr; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.ArrayList; | ||
|
||
import javax.swing.JOptionPane; | ||
|
||
import org.openstreetmap.josm.Main; | ||
import org.openstreetmap.josm.actions.ExtensionFileFilter; | ||
import org.openstreetmap.josm.data.coor.LatLon; | ||
import org.openstreetmap.josm.data.gpx.GpxData; | ||
import org.openstreetmap.josm.data.gpx.GpxTrack; | ||
import org.openstreetmap.josm.data.gpx.WayPoint; | ||
import org.openstreetmap.josm.gui.layer.GpxLayer; | ||
import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; | ||
|
||
/** | ||
* @author dmuecke Data import for TangoGPS file format. | ||
*/ | ||
public class TangoGPS extends FileImporter { | ||
|
||
public TangoGPS() { | ||
super(new ExtensionFileFilter("log", "log",tr("TangoGPS Files (*.log)"))); | ||
} | ||
|
||
/** | ||
* @author cbrill | ||
* This function imports data from file and adds trackpoints | ||
* to a layer. | ||
* Read a log file from TangoGPS. These are simple text files in the | ||
* form: <lat>,<lon>,<elevation>,<speed>,<course>,<hdop>,<datetime> | ||
*/ | ||
@Override | ||
public void importData(File file) throws IOException { | ||
// create the data tree | ||
GpxData data = new GpxData(); | ||
GpxTrack currentTrack = new GpxTrack(); | ||
data.tracks.add(currentTrack); | ||
ArrayList<WayPoint> currentTrackSeg = new ArrayList<WayPoint>(); | ||
|
||
int imported = 0; | ||
int failure = 0; | ||
|
||
BufferedReader rd = null; | ||
try { | ||
InputStream source = new FileInputStream(file); | ||
rd = new BufferedReader(new InputStreamReader(source)); | ||
|
||
String line; | ||
while ((line = rd.readLine()) != null) { | ||
failure++; | ||
String[] lineElements = line.split(","); | ||
if (lineElements.length == 7) { | ||
try { | ||
WayPoint currentWayPoint = new WayPoint( | ||
parseLatLon(lineElements)); | ||
currentWayPoint.attr.put("ele", lineElements[2]); | ||
currentWayPoint.attr.put("time", lineElements[6]); | ||
currentWayPoint.setTime(); | ||
currentTrackSeg.add(currentWayPoint); | ||
imported++; | ||
} catch (NumberFormatException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
failure = failure - imported; | ||
if(imported > 0) { | ||
currentTrack.trackSegs.add(currentTrackSeg); | ||
data.recalculateBounds(); | ||
data.storageFile = file; | ||
GpxLayer gpxLayer = new GpxLayer(data, file.getName()); | ||
Main.main.addLayer(gpxLayer); | ||
if (Main.pref.getBoolean("marker.makeautomarkers", true)) { | ||
MarkerLayer ml = new MarkerLayer(data, tr("Markers from {0}", file.getName()), file, gpxLayer); | ||
if (ml.data.size() > 0) { | ||
Main.main.addLayer(ml); | ||
} | ||
} | ||
} | ||
showInfobox(imported,failure); | ||
} finally { | ||
if (rd != null) | ||
rd.close(); | ||
} | ||
} | ||
|
||
private double parseCoord(String s) { | ||
return Double.parseDouble(s); | ||
} | ||
|
||
private LatLon parseLatLon(String[] lineElements) { | ||
if (lineElements.length < 2) | ||
return null; | ||
return new LatLon(parseCoord(lineElements[0]), | ||
parseCoord(lineElements[1])); | ||
} | ||
|
||
private void showInfobox(int success,int failure) { | ||
String msg = tr("Coordinates imported: ") + success + " " + tr("Format errors: ") + failure + "\n"; | ||
if (success > 0) { | ||
JOptionPane.showMessageDialog(Main.parent, msg, tr("TangoGPS import success"), JOptionPane.INFORMATION_MESSAGE); | ||
} else { | ||
JOptionPane.showMessageDialog(Main.parent, msg, tr("TangoGPS import faliure!"), JOptionPane.ERROR_MESSAGE); | ||
} | ||
} | ||
|
||
|
||
} |
19 changes: 19 additions & 0 deletions
19
dataimport/src/org/openstreetmap/josm/plugins/DataImport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* This plugin leverages JOSM to import TangoGPS files. | ||
*/ | ||
package org.openstreetmap.josm.plugins; | ||
|
||
import org.openstreetmap.josm.actions.ExtensionFileFilter; | ||
import org.openstreetmap.josm.io.TangoGPS; | ||
|
||
public class DataImport extends Plugin { | ||
|
||
/** | ||
* Add new File import filter into open dialog | ||
*/ | ||
public DataImport() { | ||
super(); | ||
ExtensionFileFilter.importers.add(new TangoGPS()); | ||
} | ||
|
||
} |