Changeset 16382 in osm for applications/editors/josm/plugins/dataimport/src/org
- Timestamp:
- 2009-07-08T16:30:54+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/dataimport/src/org/openstreetmap/josm
- Files:
-
- 1 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/dataimport/src/org/openstreetmap/josm/io/Tcx.java
r16362 r16382 2 2 package org.openstreetmap.josm.io; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import java.io.File; 7 import java.io.IOException; 5 8 import java.util.ArrayList; 6 9 import java.util.Collection; … … 12 15 import javax.xml.datatype.XMLGregorianCalendar; 13 16 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.actions.ExtensionFileFilter; 14 19 import org.openstreetmap.josm.data.coor.LatLon; 15 20 import org.openstreetmap.josm.data.gpx.GpxData; 16 21 import org.openstreetmap.josm.data.gpx.GpxTrack; 17 22 import org.openstreetmap.josm.data.gpx.WayPoint; 23 import org.openstreetmap.josm.gui.layer.GpxLayer; 24 import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer; 18 25 import org.openstreetmap.josm.io.tcx.ActivityLapT; 19 26 import org.openstreetmap.josm.io.tcx.ActivityT; … … 23 30 import org.openstreetmap.josm.io.tcx.TrackpointT; 24 31 import org.openstreetmap.josm.io.tcx.TrainingCenterDatabaseT; 32 25 33 26 34 /** … … 43 51 * to the endorsed directory (create it if necessary) of your JRE. Usually it is something like this: 44 52 * \<program files>\Java\jre<java version>\lib\endorsed 45 * 53 * 46 54 * @author adrian <as@nitegate.de> 47 * 55 * 48 56 */ 49 public class Tcx Reader {50 51 private File tcxFile; 57 public class Tcx extends FileImporter { 58 59 //private File tcxFile; 52 60 53 61 private GpxData gpxData; 54 62 63 64 public Tcx() { 65 super(new ExtensionFileFilter("tcx", "tcx",tr("TCX Files (*.tcx)"))); 66 } 67 55 68 /** 56 69 * @param tcxFile 57 70 */ 58 public TcxReader(File tcxFile) { 59 super(); 60 this.tcxFile = tcxFile; 61 parseFile(); 62 } 63 64 /** 65 * 66 */ 67 @SuppressWarnings("unchecked") private void parseFile() { 71 @Override 72 public void importData(File tcxFile) throws IOException { 73 //this.tcxFile = tcxFile; 74 parseFile(tcxFile); 75 76 GpxData gpxData = getGpxData(); 77 gpxData.storageFile = tcxFile; 78 GpxLayer gpxLayer = new GpxLayer(gpxData, tcxFile.getName()); 79 Main.main.addLayer(gpxLayer); 80 if (Main.pref.getBoolean("marker.makeautomarkers", true)) 81 { 82 MarkerLayer ml = new MarkerLayer(gpxData, tr("Markers from {0}", tcxFile.getName()), tcxFile, gpxLayer); 83 if (ml.data.size() > 0) 84 { 85 Main.main.addLayer(ml); 86 } 87 } 88 89 } 90 91 /** 92 * 93 */ 94 @SuppressWarnings("unchecked") private void parseFile(File tcxFile) { 68 95 try { 69 96 JAXBContext jc = JAXBContext … … 96 123 PositionT p = tp.getPosition(); 97 124 98 if (p == null) {125 if (p == null) 99 126 // If the TrackPointT lacks a position, return null. 100 127 return null; 101 }102 128 103 129 WayPoint waypt = new WayPoint(new LatLon(p.getLatitudeDegrees(), … … 189 215 } 190 216 191 p ublicGpxData getGpxData() {217 private GpxData getGpxData() { 192 218 return gpxData; 193 219 } -
applications/editors/josm/plugins/dataimport/src/org/openstreetmap/josm/plugins/DataImport.java
r16176 r16382 4 4 package org.openstreetmap.josm.plugins; 5 5 6 import java.io.IOException; 7 6 8 import org.openstreetmap.josm.actions.ExtensionFileFilter; 7 9 import org.openstreetmap.josm.io.TangoGPS; 10 import org.openstreetmap.josm.io.Tcx; 8 11 9 12 public class DataImport extends Plugin { 10 13 11 /** 12 * Add new File import filter into open dialog 13 */ 14 public DataImport() { 15 super(); 16 ExtensionFileFilter.importers.add(new TangoGPS()); 17 } 14 /** 15 * Add new File import filter into open dialog 16 */ 17 public DataImport() throws IOException{ 18 super(); 19 20 ExtensionFileFilter.importers.add(new TangoGPS()); 21 ExtensionFileFilter.importers.add(new Tcx()); 22 } 23 18 24 19 25 }
Note:
See TracChangeset
for help on using the changeset viewer.