Changeset 26168 in osm for applications/editors/josm/plugins/public_transport/src/public_transport/TrackSuggestStopsCommand.java
- Timestamp:
- 2011-06-23T17:50:32+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/public_transport/src/public_transport/TrackSuggestStopsCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import java.util.Collection; … … 58 60 Node node = stoplistTM.nodeAt(i); 59 61 if (node == null) 60 continue;62 continue; 61 63 Main.main.getCurrentDataSet().removePrimitive(node); 62 64 node.setDeleted(true); … … 70 72 Iterator< WayPoint > witer = siter.next().getWayPoints().iterator(); 71 73 while (witer.hasNext()) 72 wayPoints.add(witer.next());74 wayPoints.add(witer.next()); 73 75 } 74 76 Vector< Double > wayPointsDist = new Vector< Double >(wayPoints.size()); … … 80 82 { 81 83 if (wayPoints.elementAt(i).getString("time") != null) 82 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)83 .getString("time").substring(11,19));84 time = StopImporterDialog.parseTime(wayPoints.elementAt(i) 85 .getString("time").substring(11,19)); 84 86 if (time < dGpsStartTime) 85 time += 24*60*60;87 time += 24*60*60; 86 88 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY)); 87 89 ++i; … … 93 95 while ((j > 0) && (time - timeWindow/2 < time2)) 94 96 { 95 --j;96 if (wayPoints.elementAt(j).getString("time") != null)97 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(j)98 .getString("time").substring(11,19));99 if (time2 < dGpsStartTime)100 time2 += 24*60*60;97 --j; 98 if (wayPoints.elementAt(j).getString("time") != null) 99 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(j) 100 .getString("time").substring(11,19)); 101 if (time2 < dGpsStartTime) 102 time2 += 24*60*60; 101 103 } 102 104 int k = i + 1; … … 104 106 while ((k < wayPoints.size()) && (time + timeWindow/2 > time2)) 105 107 { 106 if (wayPoints.elementAt(k).getString("time") != null)107 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(k)108 .getString("time").substring(11,19));109 if (time2 < dGpsStartTime)110 time2 += 24*60*60;111 ++k;108 if (wayPoints.elementAt(k).getString("time") != null) 109 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(k) 110 .getString("time").substring(11,19)); 111 if (time2 < dGpsStartTime) 112 time2 += 24*60*60; 113 ++k; 112 114 } 113 115 114 116 if (j < k) 115 117 { 116 double dist = 0;117 LatLon latLonI = wayPoints.elementAt(i).getCoor();118 for (int l = j; l < k; ++l)119 {120 double distL = latLonI.greatCircleDistance(wayPoints.elementAt(l).getCoor());121 if (distL > dist)122 dist = distL;123 }124 wayPointsDist.add(Double.valueOf(dist));118 double dist = 0; 119 LatLon latLonI = wayPoints.elementAt(i).getCoor(); 120 for (int l = j; l < k; ++l) 121 { 122 double distL = latLonI.greatCircleDistance(wayPoints.elementAt(l).getCoor()); 123 if (distL > dist) 124 dist = distL; 125 } 126 wayPointsDist.add(Double.valueOf(dist)); 125 127 } 126 128 else 127 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));129 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY)); 128 130 129 131 if (wayPoints.elementAt(i).getString("time") != null) 130 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)131 .getString("time").substring(11,19));132 time = StopImporterDialog.parseTime(wayPoints.elementAt(i) 133 .getString("time").substring(11,19)); 132 134 if (time < dGpsStartTime) 133 time += 24*60*60;135 time += 24*60*60; 134 136 ++i; 135 137 } … … 139 141 { 140 142 if (wayPointsDist.elementAt(i).doubleValue() >= threshold) 141 continue;143 continue; 142 144 if ((wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i-1)) != -1) 143 145 || (wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i+1)) != -1)) 144 continue;146 continue; 145 147 146 148 LatLon latLon = wayPoints.elementAt(i).getCoor(); 147 149 if ((lastStopCoor != null) && (lastStopCoor.greatCircleDistance(latLon) < threshold)) 148 continue;150 continue; 149 151 150 152 if (wayPoints.elementAt(i).getString("time") != null) 151 153 { 152 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)153 .getString("time").substring(11,19));154 double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);155 if (gpsSyncTime < dGpsStartTime - 12*60*60)156 gpsSyncTime += 24*60*60;157 double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);158 time -= timeDelta;159 Node node = StopImporterAction.createNode(latLon, type, "");160 stoplistTM.insertRow(-1, node, StopImporterAction.timeOf(time), "", "");154 time = StopImporterDialog.parseTime(wayPoints.elementAt(i) 155 .getString("time").substring(11,19)); 156 double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime); 157 if (gpsSyncTime < dGpsStartTime - 12*60*60) 158 gpsSyncTime += 24*60*60; 159 double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart); 160 time -= timeDelta; 161 Node node = StopImporterAction.createNode(latLon, type, ""); 162 stoplistTM.insertRow(-1, node, StopImporterAction.timeOf(time), "", new TransText(null)); 161 163 } 162 164 … … 175 177 Node node = stoplistTM.nodeAt(i); 176 178 if (node == null) 177 continue;179 continue; 178 180 Main.main.getCurrentDataSet().removePrimitive(node); 179 181 node.setDeleted(true); … … 188 190 Node node = stoplistTM.nodeAt(i); 189 191 if (node == null) 190 continue;192 continue; 191 193 node.setDeleted(false); 192 194 Main.main.getCurrentDataSet().addPrimitive(node); … … 202 204 @Override public JLabel getDescription() 203 205 { 204 return new JLabel( "public_transport.TrackStoplist.SuggestStops");206 return new JLabel(tr("Public Transport: Suggest stops")); 205 207 } 206 208 … … 223 225 double time = StopImporterDialog.parseTime(this.time); 224 226 if (time - startTime > 12*60*60) 225 time -= 24*60*60;227 time -= 24*60*60; 226 228 227 229 double nseTime = StopImporterDialog.parseTime(nse.time); 228 230 if (nseTime - startTime > 12*60*60) 229 nseTime -= 24*60*60;231 nseTime -= 24*60*60; 230 232 231 233 if (time < nseTime) 232 return -1;234 return -1; 233 235 else if (time > nseTime) 234 return 1;236 return 1; 235 237 else 236 return 0;238 return 0; 237 239 } 238 240 };
Note:
See TracChangeset
for help on using the changeset viewer.