GithubHelp home page GithubHelp logo

Comments (1)

mtortora-ai avatar mtortora-ai commented on June 1, 2024

Hi,

the problem is due to the fact that there are two isolated graphs, where in the second smaller one a candidate point of the last gps coordinate (61.46429, 23.7183) lies.
The problem, as you say, is due to the point being in a parking area and network_type='drive' does not take into account parking lots when constructing the road graph.
However, from PyTrack version 2.0.8 (you have 2.0.6) it is possible to define custom network_type.
Below is the working code and the results obtained.

Remember to leave a star for the repository 🤟

import numpy as np
from pytrack.graph import graph, distance
from pytrack.matching import candidate, mpmatching_utils, mpmatching
from pytrack.analytics import visualization

coords = [
    (61.464851, 23.72293),
    (61.464935, 23.721074),
    (61.465018, 23.719238),
    (61.464761, 23.718313),
    (61.46429, 23.7183)]


north, east = np.max(np.array([*coords]), 0)
south, west = np.min(np.array([*coords]), 0)

custom_filter = ('["highway"]["area"!~"yes"]["access"!~"private"]'
                 '["highway"!~"abandoned|bridleway|bus_guideway|construction|corridor|cycleway|'
                 'elevator|escalator|footway|path|pedestrian|planned|platform|proposed|raceway|steps|track"]'
                 '["service"!~"emergency_access|private"]')

G = graph.graph_from_bbox(*distance.enlarge_bbox(north, south, west, east, 500), simplify=True, custom_filter=custom_filter)

G_interp, candidates = candidate.get_candidates(G, coords, interp_dist=10, closest=True, radius=30)

trellis = mpmatching_utils.create_trellis(candidates)

path_prob, predecessor = mpmatching.viterbi_search(G_interp, trellis, "start", "target")


loc = (np.mean(np.array([*coords])[:, 0]), np.mean(np.array([*coords])[:, 1]))
maps = visualization.Map(location=loc, zoom_start=15)

maps.draw_candidates(candidates, 30)

maps.add_graph(G, plot_nodes=True)
maps.draw_path(G_interp, trellis, predecessor)
maps

github

from pytrack.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.