Hi,
I am using GetPointOnALine function. I want to find third point on line from firstpoint at particular distance. It working on Decimaldegree. In other projection where map unit is meter. Its not working properly. Is there any dependency or suggest how to use it in different projections.
Thanks,
Goral
GetPointOnALine
Hi Goral,
The DeicmalDegree is used in the algorithm to calculate the point from a line, thus you need to convert all the shapes to EPSG:4326 as the input parameter, the demo codes shows as following:
LineShape shape =
new
LineShape();
shape.Vertices.Add(
new
Vertex(0, 0));
shape.Vertices.Add(
new
Vertex(800, 700));
Proj4Projection projection =
new
Proj4Projection();
projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(25832);
projection.ExternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString();
projection.MemoryMode = Proj4MemoryMode.Unmanaged;
projection.Open();
LineShape projectedShape = projection.ConvertToExternalProjection(shape)
as
LineShape;
PointShape point = projectedShape.GetPointOnALine(StartingPoint.FirstPoint, 120, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
PointShape projectedPoint = projection.ConvertToInternalProjection(point)
as
PointShape;
Thanks,
Johnny
HI,
Thanks for reply. From given example its explaining we can use GetPointOnLine function with DecimalDegree geographi unit. In example you have given 4326 in externalprojection string. My scenario is reverse 4326 is internalprojection. External projection string is my target projection. Thats why I am getting problem in GetPointOnAline function using with External projection unit. What is the solution for that?
Thank,
Goral
Hi Goral,
Please check the demo code as below, if it still runs into exception or error, could you please create a demo project for us?
LineShape shape =
new
LineShape();
shape.Vertices.Add(
new
Vertex(0, 0));
shape.Vertices.Add(
new
Vertex(0.5, 0.02));
Proj4Projection projection =
new
Proj4Projection();
projection.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
projection.InternalProjectionParametersString = Proj4Projection.GetWgs84ParametersString();
projection.MemoryMode = Proj4MemoryMode.Unmanaged;
PointShape originalPoint = shape.GetPointOnALine(StartingPoint.FirstPoint, 20000, GeographyUnit.DecimalDegree, DistanceUnit.Meter);
projection.Open();
LineShape projectedShape = projection.ConvertToExternalProjection(shape)
as
LineShape;
PointShape projectedPoint = projection.ConvertToExternalProjection(originalPoint)
as
PointShape;
PointShape point = projectedShape.GetPointOnALine(StartingPoint.FirstPoint, 20000, GeographyUnit.Meter, DistanceUnit.Meter);
Thanks,
Johnny