Plotting Lat/Long data as LineSeries gives incorrect display
-
- Newbie
- Posts: 17
- Joined: Thu Jan 04, 2018 12:00 am
Plotting Lat/Long data as LineSeries gives incorrect display
Hi Support
I have a series of Latitude and Longitude values that I wish to plot with a connecting line between the points. The points are recorded GPS data and all have a correct sequence order of data events. They were recorded from a GPS equipped vehicle traveling a known path and are in chronological order.
If I use a TPoint Series, the points are shown in the correct expected locations on the graph.
If I use the same data with a TLineSeries or TFastLine Series, the tracking line incorrectly connects to other points, giving an obscure and inaccurate plot.
There must presumably be a setting that allows the LineSeries to correctly interconnect the adjacent points instead of the erratic lines drawing that occurs.
Typical sample data is shown below
Hopefully someone can advise of my error.
Thanks and regards
Trevor
I have a series of Latitude and Longitude values that I wish to plot with a connecting line between the points. The points are recorded GPS data and all have a correct sequence order of data events. They were recorded from a GPS equipped vehicle traveling a known path and are in chronological order.
If I use a TPoint Series, the points are shown in the correct expected locations on the graph.
If I use the same data with a TLineSeries or TFastLine Series, the tracking line incorrectly connects to other points, giving an obscure and inaccurate plot.
There must presumably be a setting that allows the LineSeries to correctly interconnect the adjacent points instead of the erratic lines drawing that occurs.
Typical sample data is shown below
Hopefully someone can advise of my error.
Thanks and regards
Trevor
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Hello,
This probably happens because the values are x-sorted by default. You can disable this with:
This probably happens because the values are x-sorted by default. You can disable this with:
Code: Select all
Series1.XValues.Order:=loNone;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 17
- Joined: Thu Jan 04, 2018 12:00 am
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Thanks Yeeray, that's a minor improvement, but the start/end points lines are still being incorrectly connected. The graphic below shows the real vehicle path (green arrows). The graph has shown that, and also taken a shortcut, joining the start and end of the route with straight lines.Yeray wrote:Hello,
This probably happens because the values are x-sorted by default. You can disable this with:Code: Select all
Series1.XValues.Order:=loNone;
I tried also Series.YValues.Order:=loNone; but that did not make a difference
- Attachments
-
- 2018-06-16_23-31-20.jpg (174.47 KiB) Viewed 20458 times
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Hello,
I've done a simple example trying to reproduce the problem here, but it seems to work fine for me.
Could you please modify the above or arrange a simple example project we can run as-is to reproduce the problem here?
Thanks in advance.
I've done a simple example trying to reproduce the problem here, but it seems to work fine for me.
Code: Select all
uses Series;
const
xPoints: array[0..6] of double =
(
145.114, 145.113, 145.109, 145.115,
145.124, 145.123, 145.122
);
yPoints: array[0..6] of double =
(
-37.847, -37.850, -37.850, -37.817,
-37.818, -37.82, -37.82
);
procedure TForm1.FormCreate(Sender: TObject);
procedure GoAndBack;
var i: Integer;
begin
for i:=0 to Length(xPoints)-1 do
Chart1[0].AddXY(xPoints[i]+random*0.001-0.0005, yPoints[i]+random*0.001-0.0005);
for i:=Length(xPoints)-1 downto 0 do
Chart1[0].AddXY(xPoints[i]+random*0.001-0.0005, yPoints[i]+random*0.001-0.0005);
end;
var i: Integer;
begin
Chart1.View3D:=False;
Chart1.Legend.LegendStyle:=lsSeries;
Chart1.Axes.Bottom.SetMinMax(145.101, 145.131);
Chart1.Axes.Bottom.LabelsAngle:=90;
with Chart1.AddSeries(TFastLineSeries) as TFastLineSeries do
begin
Title:='A';
XValues.Order:=loNone;
for i:=0 to 4 do
GoAndBack;
end;
end;
Thanks in advance.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 17
- Joined: Thu Jan 04, 2018 12:00 am
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Thank you Yeeray for your valuable support, it is appreciated.
I may have located the cause, but I don't yet know how to resolve.
I have found that the vehicle records when it goes 'online' and travels from A(north) to B(south). It then goes 'offline' while it tracks back to point A again, goes online, and then starts recording the track from A to B again. Sometimes it is two-way data and other times it is one-way only.
The unintended line was drawn when point A was the next available point after the previous last point B
I thought I might resolve this by only plotting if the distance between the two points is less than a 'threshold' value.
I can calculate the great circle distance between the two adjacent points, and if it is greater than a threshold, I want to avoid drawing that 'track' on the graph.
I tried just bypassing the call if the distance was greater than 300 metres:
However, even though the distance was much greater than 300 meters, the line still was drawn (presumably) on the following point from the array.
I also tried using Series.AddNull, unsuccessfully.
How can avoid drawing the line if the distance from B to A is greater than a specific value?
Many thanks for your kind assistance
I may have located the cause, but I don't yet know how to resolve.
I have found that the vehicle records when it goes 'online' and travels from A(north) to B(south). It then goes 'offline' while it tracks back to point A again, goes online, and then starts recording the track from A to B again. Sometimes it is two-way data and other times it is one-way only.
The unintended line was drawn when point A was the next available point after the previous last point B
I thought I might resolve this by only plotting if the distance between the two points is less than a 'threshold' value.
I can calculate the great circle distance between the two adjacent points, and if it is greater than a threshold, I want to avoid drawing that 'track' on the graph.
I tried just bypassing the call if the distance was greater than 300 metres:
Code: Select all
ThisPt.X := BusRec.Long;
ThisPt.Y := BusRec.Lat;
if (LastPt.X = 0.0) and (LastPt.Y = 0) then LastPt := ThisPt; {first time through}
Dist := GetDistanceBetweenTwoLocations(ThisPt, LastPt, False);
if (Dist < 300) then {Less than 300 metres traveled since last location was recorded? Plot it}
begin
TBtwnLineSeries[TBtwnLineSeriesCount].AddXY(BusRec.Long, BusRec.Lat);
end
LastPt := ThisPt {update for next time}
However, even though the distance was much greater than 300 meters, the line still was drawn (presumably) on the following point from the array.
I also tried using Series.AddNull, unsuccessfully.
How can avoid drawing the line if the distance from B to A is greater than a specific value?
Many thanks for your kind assistance
-
- Newbie
- Posts: 17
- Joined: Thu Jan 04, 2018 12:00 am
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Hi Team
I have created a program that reproduces my issue.
It needs the csv data file to be copied to the same location as the exe.
Click on a point on the grid to draw the chart to that point. The problem occurs at row 148.
If I can determine how to avoid plotting those points where the distance is excessive, this would allow me to solve my problem.
I have uploaded a sample program that reproduces my issue (ChartTrackingIssueWithSrc.zip).
Many thanks.
I have created a program that reproduces my issue.
It needs the csv data file to be copied to the same location as the exe.
Click on a point on the grid to draw the chart to that point. The problem occurs at row 148.
Code: Select all
procedure TForm5.Button1Click(Sender: TObject);
var
i : Integer;
begin
if not (FileExists('TrackPath.csv')) then exit;
ResultsSG.Clear;
Series1.Clear;
Chart1.Axes.Bottom.SetMinMax(145.101, 145.131);
Chart1.Axes.Bottom.LabelsAngle:=90;
Chart1.View3D:=False;
Chart1.Legend.LegendStyle:=lsSeries;
Series1.XValues.Order:=loNone;
ResultsSG.LoadFromCSV('TrackPath.csv');
for i := 1 to ResultsSG.RowCount-1 do
Series1.AddXY( ResultsSG.Floats[3, i], ResultsSG.Floats[2, i]);
end;
procedure TForm5.ResultsSGClickCell(Sender: TObject; ARow, ACol: Integer);
var
i : Integer;
Lt, Ln : Real;
begin
{temporarily replot the graph from index 1 to current position to see where the faulty trace line occurs.}
if assigned(Series1) then Series1.Clear;
for i := 1 to ARow do
begin
Lt := ResultsSG.Floats[2, i];
Ln := ResultsSG.Floats[3, i];
Series1.AddXY(Ln, Lt);
end;
end;
I have uploaded a sample program that reproduces my issue (ChartTrackingIssueWithSrc.zip).
Many thanks.
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Hello,
The null points should do the trick for you. If you are using a TFastLineSeries, try changing it to a TLineSeries to see if it makes any difference.
If you still find problems with it, please try to arrange a simple example we can run as-is to reproduce the problem here.
The null points should do the trick for you. If you are using a TFastLineSeries, try changing it to a TLineSeries to see if it makes any difference.
If you still find problems with it, please try to arrange a simple example we can run as-is to reproduce the problem here.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 17
- Joined: Thu Jan 04, 2018 12:00 am
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Thank you
Both changing from FastLineSeries to LineSeries, and adding the null worked.
Your assistance is greatly appreciated
Both changing from FastLineSeries to LineSeries, and adding the null worked.
Code: Select all
Dist := GetDistanceBetweenTwoLocations(ThisPt, LastPt, False);
if (Dist < 500) then
Series1.AddXY(ThisPt.X, ThisPt.Y)
else
Series1.AddNull;
Re: Plotting Lat/Long data as LineSeries gives incorrect display
Great! I'm glad to hear it works fine now.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |