How to calculate distance along line from point using .NET Maps SDK?

634
3
Jump to solution
06-13-2023 07:54 AM
KevinCheriyan
Occasional Contributor

Background:

I have a .NET MAUI Application that I'm building for iOS devices. The application uses an MMPK for offline data storage, so whatever solution I implement to this problem must utilize MMPK data or coexist with it.

Problem:

I have a dataset consisting of lines (>11,000 features) and points (>2500) that intersect those lines. See a sample of what this data might look like:

KevinCheriyan_0-1686664886111.png

I want to be able to calculate the distance traversed from any given point feature along a line feature, respecting direction. So, essentially, what's the point on "brown" line feature that is x distance away from "green" point that intersects with this line?

My attempted solution:

Create network dataset and build it in ArcGIS Pro. Then add feature dataset containing ND to MMPK. In the app, create a ServiceAreaTask from transportation network dataset from the MMPK. Add ServiceAreaParameters, where I set my "green" points as facilities, and add default impedance cutoffs to distance x. Solve Service Area of facilities. Get my point outputs on the line features from this result.

 

I'm stuck at the part where I'm creating my ServiceAreaTask with the transportation network dataset, after realizing that I probably should be creating a network dataset with just the single line segment in question, instead of ALL the line segments. Am I correct in my assumption here? If I create a network dataset with all my line segments, then the calculation for the shortest route along any single line segment will be compromised by other intersecting lines.

Instead, for this to work, I need to create network datasets on the fly from the line segment in question. But as far as I know, there's no way to do this in .NET Maps SDK. I need a transportation or utility network to start the ServiceAreaLayer task, but the only way to create this is external to the SDK. 

So, how can I fix this problem for use in my MAUI application? Can I still use Network Analysis? Or do I need to come up with my own version of calculating distance traversed along line segment? Please tell me I don't have to implement Djikstra's algorithm to solve this in .NET 😶

Thanks for the help!

 

 


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
1 Solution

Accepted Solutions
DiveshGoyal
Esri Regular Contributor

Have you tried using GeometryEngine.CreatePointAlong()
If your starting point is not the beginning of the polyline, you'll first need to create a new polyline from the original one which starts at required starting point.

View solution in original post

3 Replies
DiveshGoyal
Esri Regular Contributor

Have you tried using GeometryEngine.CreatePointAlong()
If your starting point is not the beginning of the polyline, you'll first need to create a new polyline from the original one which starts at required starting point.

KevinCheriyan
Occasional Contributor

Thank you @DiveshGoyal for your reply. After deliberating over this, and trying out a first-pass implementation of NetworkAnalysis, I think it's becoming clear that I do need to use CreatePointAlong(). I can't believe I missed this while searching in the Geometry class docs. Apparently, I should've been checking the GeometryEngine docs instead!


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos
KevinCheriyan
Occasional Contributor

@DiveshGoyal Any idea why the CreatePointAlong() method uses planar distance to calculate? I want to use geodetic distance and tried reprojecting my data from wkid:3857 to wkid:4269, but no success.

I made a post here. If you have any insight, I'd appreciate it! Thanks!


--------------------------------------------------
Application Developer, GeoMarvel
0 Kudos