operate g-raph with python

g-raph plugin for tcp/ip JSON communication and python wrapping

g-raph_plugin_server 1.0.0

0.9.0 new 2022 18 Aug. with python wrap module
0.9.1 updated 2022 25 Sep.
1.0.0 updated 2023 26 Mar.
1.0.2 updated 2023 12 Dec.

 

How to start.

Toggle the check box of “Start Sever”

Place the python module py_g_raph.py at the library path or beside your script.
This module is not yet packaged, just 1 .py script file. 

python module py_g_raph version 1.0.0

python module py_g_raph version 0.9.1 updated 2022 25 Sep.
python module py_g_raph version 1.0.0 updated 2023 26 Mar.
python module py_g_raph version 1.0.2 2023 18 Dec.

import py_g_raph as g
g.init()
import py_g_raph as g
g.init('127.0.0.1', 313)
import py_g_raph as g

if(g.init()):

    g.clear()
    g.setLengthUnit('Meters')

    poss = []
    poss.append([0, 0, 0])
    poss.append([0, 10, 0])
    poss.append([20, 30, 0])
    poss.append([-10, -20, 0])
    poss.append([-10, 10, 0])
    poss.append([-120, 30, 0])
    poss.append([-120, -20, 0])
    res = g.addNode(poss)
    print(res)

    g.addEdge(1, 0)
    g.addEdge(1, 2)
    g.addEdge(3, 0)
    g.addEdge(0, 4)
    g.addEdge(4, 1)
    g.addEdge(4, 2)
    g.addEdge(4, 3)
    g.addEdge(5, 3)
    g.addEdge(5, 2)
    g.addEdge(5, 6)
    g.addEdge(6, 3)

    g.fitCamera()

    g.clearOrigins()
    g.clearDestinations()
    g.addOrigins([2])
    g.addDestinations([6])

    g.setShortestK(2)

    res = g.findshortestpaths()
    for rt in res:
        print(rt._node_ids)
        print(rt._length)
        print(rt._reachtime*60, 'min')

    g.showDisplayNodeID(True)
    g.showDisplayNodeInfo(True)
    g.setDisplaySizeRouteArrow(2.0)
    g.setDisplaySizeNode(6)

    g.edgeDisplayMode('evaluation')

1 Comment

Comments are closed.