Changeset 20815 in osm for applications/editors/josm
- Timestamp:
- 2010-04-07T14:38:36+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/public_transport/src/public_transport
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/public_transport/src/public_transport/SettingsStoptypeCommand.java
r20772 r20815 58 58 for (int i = 0; i < track.stoplistTM.getRowCount(); ++i) 59 59 { 60 if ( (Node)track.stoplistTM.nodes.elementAt(i) != null)60 if (track.stoplistTM.nodeAt(i) != null) 61 61 { 62 Node node = (Node)track.stoplistTM.nodes.elementAt(i);62 Node node = track.stoplistTM.nodeAt(i); 63 63 oldStrings.add(new HighwayRailway(node)); 64 64 StopImporterAction.setTagsWrtType(node, type); -
applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java
r20791 r20815 155 155 Main.main.undoRedo.add(new TrackSuggestStopsCommand(this)); 156 156 else if ("stopImporter.stoplistFind".equals(event.getActionCommand())) 157 findNodesInTable(dialog.getStoplistTable(), currentTrack.stoplistTM. nodes);157 findNodesInTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes()); 158 158 else if ("stopImporter.stoplistShow".equals(event.getActionCommand())) 159 showNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM. nodes);159 showNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes()); 160 160 else if ("stopImporter.stoplistMark".equals(event.getActionCommand())) 161 markNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM. nodes);161 markNodesFromTable(dialog.getStoplistTable(), currentTrack.stoplistTM.getNodes()); 162 162 else if ("stopImporter.stoplistDetach".equals(event.getActionCommand())) 163 163 { -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackReference.java
r20773 r20815 31 31 public double threshold; 32 32 private StopImporterAction controller = null; 33 public boolean inEvent = false; 33 34 34 35 public TrackReference(GpxTrack track, StopImporterAction controller) … … 100 101 if ((e.getType() == TableModelEvent.UPDATE) && (e.getFirstRow() >= 0)) 101 102 { 103 if (inEvent) 104 return; 105 102 106 double time = StopImporterDialog.parseTime 103 107 ((String)stoplistTM.getValueAt(e.getFirstRow(), 0)); 104 108 if (time < 0) 105 109 { 110 stoplistTM.setValueAt 111 (stoplistTM.timeAt(e.getFirstRow()), e.getFirstRow(), 0); 106 112 JOptionPane.showMessageDialog 107 113 (null, "Can't parse a time from this string.", "Invalid value", … … 110 116 } 111 117 112 LatLon latLon = computeCoor(time); 113 114 if (stoplistTM.nodes.elementAt(e.getFirstRow()) == null) 115 { 116 Node node = controller.createNode 117 (latLon, (String)stoplistTM.getValueAt(e.getFirstRow(), 1)); 118 stoplistTM.nodes.set(e.getFirstRow(), node); 119 } 120 else 121 { 122 Node node = new Node(stoplistTM.nodes.elementAt(e.getFirstRow())); 123 node.setCoor(latLon); 124 node.put("name", (String)stoplistTM.getValueAt(e.getFirstRow(), 1)); 125 Command cmd = new ChangeCommand(stoplistTM.nodes.elementAt(e.getFirstRow()), node); 126 if (cmd != null) { 127 Main.main.undoRedo.add(cmd); 128 } 129 } 118 Main.main.undoRedo.add(new TrackStoplistNameCommand 119 (this, e.getFirstRow(), 120 (String)stoplistTM.getValueAt(e.getFirstRow(), 0), 121 (String)stoplistTM.getValueAt(e.getFirstRow(), 1))); 122 stoplistTM.setTimeAt 123 (e.getFirstRow(), (String)stoplistTM.getValueAt(e.getFirstRow(), 0)); 130 124 } 131 125 } … … 186 180 public void relocateNodes() 187 181 { 188 for (int i = 0; i < stoplistTM. nodes.size(); ++i)189 { 190 Node node = stoplistTM.node s.elementAt(i);182 for (int i = 0; i < stoplistTM.getNodes().size(); ++i) 183 { 184 Node node = stoplistTM.nodeAt(i); 191 185 if (node == null) 192 186 continue; … … 195 189 ((String)stoplistTM.getValueAt(i, 0)); 196 190 LatLon latLon = computeCoor(time); 197 191 198 192 Node newNode = new Node(node); 199 193 newNode.setCoor(latLon); … … 205 199 } 206 200 } 207 208 public void suggestStops()209 {210 Vector< WayPoint > wayPoints = new Vector< WayPoint >();211 Iterator< GpxTrackSegment > siter = track.getSegments().iterator();212 while (siter.hasNext())213 {214 Iterator< WayPoint > witer = siter.next().getWayPoints().iterator();215 while (witer.hasNext())216 wayPoints.add(witer.next());217 }218 Vector< Double > wayPointsDist = new Vector< Double >(wayPoints.size());219 220 int i = 0;221 double time = -48*60*60;222 double dGpsStartTime = StopImporterDialog.parseTime(gpsStartTime);223 while ((i < wayPoints.size()) && (time < dGpsStartTime + timeWindow/2))224 {225 if (wayPoints.elementAt(i).getString("time") != null)226 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)227 .getString("time").substring(11,19));228 if (time < dGpsStartTime)229 time += 24*60*60;230 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));231 ++i;232 }233 while (i < wayPoints.size())234 {235 int j = i;236 double time2 = time;237 while ((j > 0) && (time - timeWindow/2 < time2))238 {239 --j;240 if (wayPoints.elementAt(j).getString("time") != null)241 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(j)242 .getString("time").substring(11,19));243 if (time2 < dGpsStartTime)244 time2 += 24*60*60;245 }246 int k = i + 1;247 time2 = time;248 while ((k < wayPoints.size()) && (time + timeWindow/2 > time2))249 {250 if (wayPoints.elementAt(k).getString("time") != null)251 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(k)252 .getString("time").substring(11,19));253 if (time2 < dGpsStartTime)254 time2 += 24*60*60;255 ++k;256 }257 258 if (j < k)259 {260 double dist = 0;261 LatLon latLonI = wayPoints.elementAt(i).getCoor();262 for (int l = j; l < k; ++l)263 {264 double distL = latLonI.greatCircleDistance(wayPoints.elementAt(l).getCoor());265 if (distL > dist)266 dist = distL;267 }268 wayPointsDist.add(Double.valueOf(dist));269 }270 else271 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));272 273 if (wayPoints.elementAt(i).getString("time") != null)274 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)275 .getString("time").substring(11,19));276 if (time < dGpsStartTime)277 time += 24*60*60;278 ++i;279 }280 281 Vector< Node > toDelete = new Vector< Node >();282 for (i = 0; i < stoplistTM.getRowCount(); ++i)283 {284 if ((Node)stoplistTM.nodes.elementAt(i) != null)285 toDelete.add((Node)stoplistTM.nodes.elementAt(i));286 }287 if (!toDelete.isEmpty())288 {289 Command cmd = DeleteCommand.delete290 (Main.main.getEditLayer(), toDelete);291 if (cmd == null)292 return;293 Main.main.undoRedo.add(cmd);294 }295 stoplistTM.clear();296 297 LatLon lastStopCoor = null;298 for (i = 1; i < wayPoints.size()-1; ++i)299 {300 if (wayPointsDist.elementAt(i).doubleValue() >= threshold)301 continue;302 if ((wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i-1)) != -1)303 || (wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i+1)) != -1))304 continue;305 306 LatLon latLon = wayPoints.elementAt(i).getCoor();307 if ((lastStopCoor != null) && (lastStopCoor.greatCircleDistance(latLon) < threshold))308 continue;309 310 if (wayPoints.elementAt(i).getString("time") != null)311 {312 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)313 .getString("time").substring(11,19));314 double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);315 if (gpsSyncTime < dGpsStartTime - 12*60*60)316 gpsSyncTime += 24*60*60;317 double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);318 time -= timeDelta;319 stoplistTM.insertRow(-1, StopImporterAction.timeOf(time));320 Node node = controller.createNode(latLon, "");321 stoplistTM.nodes.set(stoplistTM.getRowCount()-1, node);322 }323 324 lastStopCoor = latLon;325 }326 }327 201 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistAddCommand.java
r20772 r20815 33 33 if (workingLine < 0) 34 34 workingLine = stoplistTM.getRowCount()-1; 35 stoplistTM.nodes.removeElementAt(workingLine);36 35 stoplistTM.removeRow(workingLine); 37 36 } -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistDeleteCommand.java
r20772 r20815 59 59 { 60 60 int j = workingLines.elementAt(i).intValue(); 61 Node node = stoplistTM.node s.elementAt(j);61 Node node = stoplistTM.nodeAt(j); 62 62 nodesForUndo.add(new NodeTimeName 63 63 (node, (String)stoplistTM.getValueAt(j, 0), 64 64 (String)stoplistTM.getValueAt(j, 1))); 65 stoplistTM.nodes.removeElementAt(j);66 65 stoplistTM.removeRow(j); 67 66 if (node == null) -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistDetachCommand.java
r20772 r20815 40 40 for (int i = 0; i < consideredLines.size(); ++i) 41 41 { 42 if (stoplistTM.node s.elementAt(consideredLines.elementAt(i)) != null)42 if (stoplistTM.nodeAt(consideredLines.elementAt(i)) != null) 43 43 workingLines.add(consideredLines.elementAt(i)); 44 44 } … … 51 51 { 52 52 int j = workingLines.elementAt(i).intValue(); 53 Node node = stoplistTM.node s.elementAt(j);53 Node node = stoplistTM.nodeAt(j); 54 54 nodesForUndo.add(node); 55 stoplistTM. nodes.set(j, null);55 stoplistTM.setNodeAt(j, null); 56 56 } 57 57 return true; … … 64 64 int j = workingLines.elementAt(i).intValue(); 65 65 Node node = nodesForUndo.elementAt(i); 66 stoplistTM. nodes.set(j, node);66 stoplistTM.setNodeAt(j, node); 67 67 } 68 68 } -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistSortCommand.java
r20772 r20815 19 19 private Vector< Vector< Object > > tableDataModel = null; 20 20 private Vector< Node > nodes = null; 21 private Vector< String > times = null; 21 22 private Vector< Integer > workingLines = null; 22 23 private int insPos; … … 49 50 tableDataModel = (Vector< Vector< Object > >)stoplistTM.getDataVector() 50 51 .clone(); 51 nodes = (Vector< Node >)stoplistTM.nodes.clone(); 52 nodes = (Vector< Node >)stoplistTM.getNodes().clone(); 53 times = (Vector< String >)stoplistTM.getTimes().clone(); 52 54 53 55 Vector< NodeSortEntry > nodesToSort = new Vector< NodeSortEntry >(); … … 56 58 int j = workingLines.elementAt(i).intValue(); 57 59 nodesToSort.add(new NodeSortEntry 58 (stoplistTM.node s.elementAt(j), (String)stoplistTM.getValueAt(j, 0),60 (stoplistTM.nodeAt(j), (String)stoplistTM.getValueAt(j, 0), 59 61 (String)stoplistTM.getValueAt(j, 1), 60 62 StopImporterDialog.parseTime(stopwatchStart))); 61 stoplistTM.nodes.removeElementAt(j);62 63 stoplistTM.removeRow(j); 63 64 } … … 80 81 { 81 82 stoplistTM.setDataVector(tableDataModel); 82 stoplistTM.nodes = nodes; 83 stoplistTM.setNodes(nodes); 84 stoplistTM.setTimes(times); 83 85 } 84 86 -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistTableModel.java
r20772 r20815 11 11 public class TrackStoplistTableModel extends DefaultTableModel 12 12 { 13 public Vector< Node > nodes = new Vector< Node >(); 14 public Vector< String > columns = null; 13 private Vector< Node > nodes = null; 14 private Vector< String > times = null; 15 private Vector< String > columns = null; 15 16 16 17 public TrackStoplistTableModel(TrackReference tr) … … 22 23 columns.add("Name"); 23 24 } 25 nodes = new Vector< Node >(); 26 times = new Vector< String >(); 24 27 25 28 setColumnIdentifiers(columns); … … 47 50 insertRow(insPos, null, time, ""); 48 51 } 49 52 53 public void removeRow(int pos) 54 { 55 super.removeRow(pos); 56 nodes.removeElementAt(pos); 57 times.removeElementAt(pos); 58 } 59 60 public Node nodeAt(int i) 61 { 62 return nodes.elementAt(i); 63 } 64 65 public void setNodeAt(int i, Node node) 66 { 67 nodes.set(i, node); 68 } 69 70 public final Vector< Node > getNodes() 71 { 72 return nodes; 73 } 74 75 public void setNodes(Vector< Node > nodes) 76 { 77 this.nodes = nodes; 78 } 79 80 public String timeAt(int i) 81 { 82 return times.elementAt(i); 83 } 84 85 public void setTimeAt(int i, String time) 86 { 87 times.set(i, time); 88 } 89 90 public final Vector< String > getTimes() 91 { 92 return times; 93 } 94 95 public void setTimes(Vector< String > times) 96 { 97 this.times = times; 98 } 99 50 100 public void insertRow(int insPos, Node node, String time, String name) 51 101 { … … 56 106 { 57 107 nodes.addElement(node); 108 times.addElement(time); 58 109 super.addRow(buf); 59 110 } … … 61 112 { 62 113 nodes.insertElementAt(node, insPos); 114 times.insertElementAt(time, insPos); 63 115 super.insertRow(insPos, buf); 64 116 } … … 68 120 { 69 121 nodes.clear(); 122 times.clear(); 70 123 super.setRowCount(0); 71 124 } -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackSuggestStopsCommand.java
r20773 r20815 29 29 private Vector< Vector< Object > > tableDataModel = null; 30 30 private Vector< Node > nodes = null; 31 private Vector< String > times = null; 31 32 32 33 public TrackSuggestStopsCommand(StopImporterAction controller) … … 49 50 tableDataModel = (Vector< Vector< Object > >)stoplistTM.getDataVector() 50 51 .clone(); 51 nodes = (Vector< Node >)stoplistTM. nodes.clone();52 53 for (int i = 0; i < stoplistTM.nodes.size(); ++i)54 {55 Node node = stoplistTM.nodes.elementAt(i);56 stoplistTM.nodes.set(i, null);52 nodes = (Vector< Node >)stoplistTM.getNodes().clone(); 53 times = (Vector< String >)stoplistTM.getTimes().clone(); 54 55 for (int i = 0; i < stoplistTM.getNodes().size(); ++i) 56 { 57 Node node = stoplistTM.nodeAt(i); 57 58 if (node == null) 58 59 continue; … … 155 156 double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart); 156 157 time -= timeDelta; 157 stoplistTM.insertRow(-1, StopImporterAction.timeOf(time));158 158 Node node = StopImporterAction.createNode(latLon, type, ""); 159 stoplistTM. nodes.set(stoplistTM.getRowCount()-1, node);159 stoplistTM.insertRow(-1, node, StopImporterAction.timeOf(time), ""); 160 160 } 161 161 … … 168 168 public void undoCommand() 169 169 { 170 for (int i = 0; i < stoplistTM.nodes.size(); ++i) 171 { 172 Node node = stoplistTM.nodes.elementAt(i); 173 stoplistTM.nodes.set(i, null); 170 for (int i = 0; i < stoplistTM.getNodes().size(); ++i) 171 { 172 Node node = stoplistTM.nodeAt(i); 174 173 if (node == null) 175 174 continue; … … 179 178 180 179 stoplistTM.setDataVector(tableDataModel); 181 stoplistTM.nodes = nodes; 182 183 for (int i = 0; i < stoplistTM.nodes.size(); ++i) 184 { 185 Node node = stoplistTM.nodes.elementAt(i); 180 stoplistTM.setNodes(nodes); 181 stoplistTM.setTimes(times); 182 183 for (int i = 0; i < stoplistTM.getNodes().size(); ++i) 184 { 185 Node node = stoplistTM.nodeAt(i); 186 186 if (node == null) 187 187 continue; … … 199 199 public MutableTreeNode description() 200 200 { 201 return new DefaultMutableTreeNode("public_transport.TrackStoplist.S ort");201 return new DefaultMutableTreeNode("public_transport.TrackStoplist.SuggestStops"); 202 202 } 203 203
Note:
See TracChangeset
for help on using the changeset viewer.