We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

draw point chart from latitude and longitude

Hi There,

For chartcontrol, do you have any build-in functions or properties to draw a point chart from a series of GPS latitude and longitude coordinates?

for example, if I collected 1000 GPS points along a highway at interval of about 5 meters, each point has its latitude and longitude coordinates. I want to convert latitude to distance in meters, then draw it as Y-axes, convert longitude to distance in meters, then draw it on X-axes. so that the chart displays a curve of the 5-kilometers road.

Do you have any idea or examples?

Thanks,

Lan




5 Replies

MS Manimala S Syncfusion Team March 13, 2009 12:39 PM UTC

Hi Lan,

Currently we don have a built function or property to do this. But you can get the various values of longitude and latitudes in an array or a set of variables and convert those to meter values and then just plot the chart (with 5 meters interval) of the converted points as we add series points to the chart.


Kindly, let me know if you are able to do this.

Thanks,
Manimala



LM Lan Mo March 27, 2009 06:45 PM UTC

Hi Manimala,

Thanks you for you help.

I used following code to draw points chart. I want to show the point as red-circle with size(1,1). But the point always diaplay as black-circle. see my attached screen-shot.

I want to know what's wrong with my code.

Is the chart type correct for point chart ?
series.Type = ChartSeriesType.Scatter;

Thanks you very much.


private void InitializeCurveData(decimal from, decimal to )
{

// Hide the chart object to speed up drawing process.
chtModel.BeginUpdate();
chtModel.Series.Clear();

//set type
ChartSeries series=chtModel.Model.NewSeries("GPSCurve");
chtModel.Series.Add(series);

//I want to display point as a red circle
series.Type = ChartSeriesType.Scatter;
System.Drawing.Color pIndexColor = new Color();
pIndexColor=Color.Red;
series.Style.Interior =
new Syncfusion.Drawing.BrushInfo(Syncfusion.Drawing.GradientStyle.None,
pIndexColor, pIndexColor);
series.Style.Border.Color = pIndexColor;
series.Style.Symbol.Shape = ChartSymbolShape.Circle;
series.Style.Symbol.Size=new Size(1,1);
series.Style.Symbol.Color =pIndexColor;

//add points
DataTable dtGPS=BL.Access.LoadDataTable("working_cl","ppgps_order,PP_CL_NORTHING,PP_CL_EASTING",
string.Format("ppgps_order>={0} and ppgps_order<={1}",from,to));
DataRow[] rows=dtGPS.Select("","ppgps_order asc");
double MIN_EASTING=double.MaxValue;
double MIN_NORTHING=double.MaxValue;
double MAX_EASTING=double.MinValue;
double MAX_NORTHING=double.MinValue;
for(int i = 0; i < rows.Length; i++)
{
DataRow row=rows[i];
if ((row["PP_CL_NORTHING"]==DBNull.Value) || (row["PP_CL_EASTING"]==DBNull.Value)) continue;

double PP_CL_NORTHING=Convert.ToDouble(row["PP_CL_NORTHING"]);
double PP_CL_EASTING=Convert.ToDouble(row["PP_CL_EASTING"]);
series.Points.Add(PP_CL_EASTING,PP_CL_NORTHING);

//min
if (PP_CL_NORTHING if (PP_CL_EASTING if (PP_CL_NORTHING>MAX_NORTHING) MAX_NORTHING=PP_CL_NORTHING;
if (PP_CL_EASTING>MAX_EASTING) MAX_EASTING=PP_CL_EASTING;


}




//customize X-axes Y-axes
double SCALE=Math.Max(MAX_NORTHING-MIN_NORTHING,MAX_EASTING-MIN_EASTING);
double INTERVAL=SCALE/10;
//adjust MIN to make the scurve in middle
if (MAX_NORTHING-MIN_NORTHING>MAX_EASTING-MIN_EASTING)
{
MIN_EASTING=MIN_EASTING-(MIN_EASTING+SCALE-MAX_EASTING)/2;
}
else
{
MIN_NORTHING=MIN_NORTHING-(MIN_NORTHING+SCALE-MAX_NORTHING)/2;
}
chtModel.PrimaryXAxis.Title = "Easting";
chtModel.PrimaryYAxis.Title="Northing";
chtModel.LegendPosition=ChartDock.Right;
chtModel.PrimaryYAxis.RangeType = ChartAxisRangeType.Set;
chtModel.PrimaryYAxis.Range.Min = MIN_NORTHING-INTERVAL/2;
chtModel.PrimaryYAxis.Range.Max = MIN_NORTHING+SCALE+INTERVAL/2;//MAX_NORTHING;
chtModel.PrimaryYAxis.Range.Interval =INTERVAL;
chtModel.PrimaryXAxis.RangeType = ChartAxisRangeType.Set;
chtModel.PrimaryXAxis.Range.Min =MIN_EASTING-INTERVAL/2;
chtModel.PrimaryXAxis.Range.Max =MIN_EASTING+SCALE+INTERVAL/2;//MAX_EASTING;
chtModel.PrimaryXAxis.Range.Interval = INTERVAL;
chtModel.PrimaryXAxis.LabelRotate = true;
chtModel.PrimaryXAxis.LabelRotateAngle = 315;

// Now show the chart.
chtModel.EndUpdate();

}






PointChart_d96a8cce.zip


MS Manimala S Syncfusion Team April 2, 2009 12:41 PM UTC

Hi Lan,

You can get this by setting the border color of the symbol. Here is the code to do this.

series.Style.Symbol.Border.Color = pIndexColor;

Kindly, let me know if it helps.

Thanks,
Manimala.



LM Lan Mo April 2, 2009 01:31 PM UTC

Hi,
Sorry. I am using V4.4.0.51.
There is no such "series.Style.Symbol.Border.Color "property in that version.

I try to make my question clearer here.
In Syncfusion 4.4.0.51 and C#, I want to draw a set of (x,y) data as POINTS OF CIRCLE WITH RED COLOR.

How can I do it? if you can give me a sample, that would be super.

Thank you very much for helping.

Lan



MS Manimala S Syncfusion Team April 7, 2009 01:56 PM UTC

Hi Lan,

I am working on this, will update you once I have got.

Thanks,
Manimala.


Loader.
Live Chat Icon For mobile
Up arrow icon