use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelAnalysisSpeed method RefreshInfo.
private void RefreshInfo(int i) {
if ((track == null) || (settings == null))
return;
// -- Get the data
CgData d = track.data.get(i);
lbSpeedInfoStartSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoStartSpeed.text") + "=" + String.format("%2.1f", startSpeed) + "km/h ");
lbSpeedInfoEndSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoEndSpeed.text") + "=" + String.format("%2.1f", endSpeed) + "km/h ");
lbSpeedInfoSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoSpeed.text") + "=" + d.getSpeedString(settings.Unit, true) + " ");
lbSpeedInfoDistance.setText(" " + bundle.getString("JPanelAnalysisSpeed.lbSpeedInfoDistance.text") + "=" + d.getTotalString(settings.Unit, true) + " ");
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelAnalysisSpeedSlope method Refresh.
/**
* Update the Slope/Speed chart
*/
public void Refresh(TrackData track, CgSettings settings) {
if (track == null)
return;
if (track.data.isEmpty())
return;
this.track = track;
this.settings = settings;
// -- Clear all series
if (datasetSpeedSlopePoint.getSeriesCount() > 0)
datasetSpeedSlopePoint.removeAllSeries();
if (datasetSpeedSlopeLine.getSeriesCount() > 0)
datasetSpeedSlopeLine.removeAllSeries();
XYPlot plot = chart.getXYPlot();
plot.clearDomainMarkers();
// -- Populate the series
XYSeries serie1 = new XYSeries("Speed/Slope (points)");
XYSeries serie2 = new XYSeries("Speed/Slope (line)");
int[] nb;
int j = 0;
double[] fCurveSpeedSlope = new double[101];
double[] fCurveSpeedSlope2 = new double[101];
Double[] Average = new Double[101];
Double[] Variance = new Double[101];
Double[] StandardDeviation = new Double[101];
nb = new int[101];
// -- init calc
for (j = 0; j < 101; j++) {
fCurveSpeedSlope[j] = 0;
fCurveSpeedSlope2[j] = 0;
nb[j] = 0;
}
// -- Execute the speed filtering calculation
SpeedFilter();
/*
* -- Pass 1 We calculate the average, variance and standard deviation
* of each area (1% per area)
*/
int n = 0;
double s = 0.0;
double coeff = 0.0;
double diff = 0.0;
for (CgData r : track.data) {
if (btSpeedSlopeFilter.isSelected())
s = r.tmp1;
else
s = r.getSpeed(settings.Unit);
if (btSpeedSlopeCorr.isSelected()) {
coeff = r.getCoeff() / 100.0;
diff = r.getDiff() / 100.0;
} else {
coeff = 1.00;
diff = 1.00;
}
if (s > 1.5) {
if (r.getSlope() < -49) {
fCurveSpeedSlope[0] = fCurveSpeedSlope[0] + (s / coeff / diff);
fCurveSpeedSlope2[0] = fCurveSpeedSlope2[0] + Math.pow((s / coeff / diff), 2);
nb[0]++;
} else if (r.getSlope() > 49) {
fCurveSpeedSlope[100] = fCurveSpeedSlope[100] + (s / coeff / diff);
fCurveSpeedSlope2[100] = fCurveSpeedSlope2[100] + Math.pow((s / coeff / diff), 2);
nb[100]++;
} else {
n = (int) Math.floor(r.getSlope());
fCurveSpeedSlope[n + 50] = fCurveSpeedSlope[n + 50] + (s / coeff / diff);
fCurveSpeedSlope2[n + 50] = fCurveSpeedSlope2[n + 50] + Math.pow((s / coeff / diff), 2);
nb[n + 50]++;
}
}
}
for (j = 0; j < 101; j++) {
if ((nb[j] > 0)) {
Average[j] = fCurveSpeedSlope[j] / nb[j];
Variance[j] = fCurveSpeedSlope2[j] / nb[j] - Average[j] * Average[j];
StandardDeviation[j] = Math.sqrt(Variance[j]);
}
}
// -- Init calc
for (j = 0; j < 101; j++) {
fCurveSpeedSlope[j] = 0;
fCurveSpeedSlope2[j] = 0;
nb[j] = 0;
}
n = 0;
s = 0.0;
coeff = 0.0;
diff = 0.0;
for (CgData r : track.data) {
{
if (btSpeedSlopeFilter.isSelected())
s = r.tmp1;
else
s = r.getSpeed(settings.Unit);
if (btSpeedSlopeCorr.isSelected()) {
coeff = r.getCoeff() / 100.0;
diff = r.getDiff() / 100.0;
} else {
coeff = 1.00;
diff = 1.00;
}
if (s > 1.5) {
if (r.getSlope() < -49) {
if ((s <= Average[0] + StandardDeviation[0]) || (s >= Average[0] - StandardDeviation[0])) {
fCurveSpeedSlope[0] = fCurveSpeedSlope[0] + (s / coeff / diff);
fCurveSpeedSlope2[0] = fCurveSpeedSlope2[0] + Math.pow((s / coeff / diff), 2);
nb[0]++;
}
} else if (r.getSlope() > 49) {
if ((s <= Average[100] + StandardDeviation[100]) || (s >= Average[100] - StandardDeviation[100])) {
fCurveSpeedSlope[100] = fCurveSpeedSlope[100] + (s / coeff / diff);
fCurveSpeedSlope2[100] = fCurveSpeedSlope2[100] + Math.pow((s / coeff / diff), 2);
nb[100]++;
}
} else {
n = (int) Math.floor(r.getSlope());
if ((s <= Average[n + 50] + StandardDeviation[n + 50]) || (s >= Average[n + 50] - StandardDeviation[n + 50])) {
fCurveSpeedSlope[n + 50] = fCurveSpeedSlope[n + 50] + (s / coeff / diff);
fCurveSpeedSlope2[n + 50] = fCurveSpeedSlope2[n + 50] + Math.pow((s / coeff / diff), 2);
nb[n + 50]++;
}
}
}
}
}
double maxspeed = 0.0;
// -- Populate the first serie
for (CgData r : track.data) {
if (btSpeedSlopeFilter.isSelected())
s = r.tmp1;
else
s = r.getSpeed(settings.Unit);
if (s > maxspeed)
maxspeed = s;
serie1.add(r.getSlope(), s);
}
datasetSpeedSlopePoint.addSeries(serie1);
// -- Populate the second serie
double m = 0.0;
for (j = 0; j < 101; j++) {
if ((nb[j] > 0)) {
m = fCurveSpeedSlope[j] / nb[j];
if (m > maxspeed)
maxspeed = m;
serie2.add(j - 50, m);
}
}
// -- If there is no speed the exit (not already calculated)
if (maxspeed == 0)
return;
datasetSpeedSlopeLine.addSeries(serie2);
// -- Set the range of the X axis
ValueAxis axisX = plot.getDomainAxis();
axisX.setRange(-50.0, 50.0);
ValueAxis axisY = plot.getRangeAxis(0);
axisY.setRange(0, Math.ceil(maxspeed / 5.0) * 5.0);
axisY = plot.getRangeAxis(1);
axisY.setRange(1, Math.ceil(maxspeed / 5.0) * 5.0);
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelAnalysisSpeedSlope method RefreshInfo.
private void RefreshInfo(int i) {
if ((track == null) || (settings == null))
return;
// -- Get the data
CgData d = track.data.get(i);
lbSpeedSlopeInfoSpeed.setText(" " + bundle.getString("JPanelAnalysisSpeedSlope.lbSpeedSlopeInfoSpeed.text") + "=" + d.getSpeedString(settings.Unit, true) + " ");
lbSpeedSlopeInfoSlope.setText(" " + bundle.getString("JPanelAnalysisSpeedSlope.lbSpeedSlopeInfoSlope.text") + "=" + d.getSlopeString(true) + " ");
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelAnalysisTimeDist method Refresh.
/**
* Update the Time/Distance chart
*/
public void Refresh(TrackData track, CgSettings settings) {
if (track == null)
return;
if (track.data.isEmpty())
return;
this.track = track;
this.settings = settings;
// -- Clear all series
if (datasetElevDist.getSeriesCount() > 0)
datasetElevDist.removeAllSeries();
if (datasetTimeDist.getSeriesCount() > 0)
datasetTimeDist.removeAllSeries();
XYPlot plot = chart.getXYPlot();
// -- Populate the serie
XYSeries serie1 = new XYSeries("Elevation/Distance");
XYSeries serie2 = new XYSeries("Time/Distance");
for (CgData r : track.data) {
double x = r.getTotal(settings.Unit) / 1000;
double y = r.getElevation(settings.Unit);
double t = r.getTime();
serie1.add(x, y);
serie2.add(x, t);
}
datasetElevDist.addSeries(serie1);
datasetTimeDist.addSeries(serie2);
if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) {
ValueAxis axisYElev = plot.getRangeAxis(0);
axisYElev.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0, Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0);
}
chart = CreateChart(datasetElevDist, datasetTimeDist);
RefreshInfo(0);
}
use of course_generator.CgData in project Course_Generator by patrovite.
the class JPanelAnalysisTimeDist method RefreshInfo.
private void RefreshInfo(int i) {
if ((track == null) || (settings == null))
return;
// -- Get the data
CgData d = track.data.get(i);
lbTimeDistInfoDistance.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoDistance.text") + "=" + d.getTotalString(settings.Unit, true) + " ");
lbTimeDistInfoElevation.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoElevation.text") + "=" + d.getElevationString(settings.Unit, true) + " ");
lbTimeDistInfoTime.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoTime.text") + "=" + d.getTimeString() + " ");
lbTimeDistInfoHour.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistInfoHour.text") + "=" + d.getHourString() + " ");
lbTimeDistSlope.setText(" " + bundle.getString("JPanelAnalysisTimeDist.lbTimeDistSlope.text") + "=" + d.getSlopeString(true) + " ");
}
Aggregations