Skip to content

Fix route not going over edges that are very short #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DavidKarlas
Copy link

I know this is a bit hacky, but feel free to propose better solution :)
Here is code on how to find such edges:

using var ms = new MemoryStream();
using var jsonWriter = new Utf8JsonWriter(ms);
jsonWriter.WriteFeatureCollectionStart();

var latest = routerDb.Latest;
var edgeEnumerator = latest.GetEdgeEnumerator();
foreach (var vertex in latest.GetVertices())
{
    if (!edgeEnumerator.MoveTo(vertex))
    {
        continue;
    }

    while (edgeEnumerator.MoveNext())
    {
        if (!edgeEnumerator.Forward)
        {
            continue;
        }
        var length = edgeEnumerator.EdgeLength();
        if (length == 0)
        {
            jsonWriter.WriteVertexFeature(VertexId.Empty, edgeEnumerator.HeadLocation);
        }
    }
}
jsonWriter.WriteFeatureCollectionEnd();
jsonWriter.Flush();
Console.WriteLine(Encoding.UTF8.GetString(ms.ToArray()));

Here is for example output in Slovenia.pbf: GeoJson.io and Github Gist(Click Raw to see actual .geojson)

@DavidKarlas
Copy link
Author

And also Belgium.pbf: GeoJson.io and Github Gist(Click Raw to see actual .geojson)

@DavidKarlas
Copy link
Author

Here is example of route that works with this PR, but not without:
var lux1 = (5.521588, 50.659852, (float?)0f);
var lux2 = (5.525663, 50.659128, (float?)0f);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant