Connecting GIS Points from Global Table

Connecting GIS Points from Global Table

kadircan_t
Not applicable
27 Views
2 Replies
Message 1 of 3

Connecting GIS Points from Global Table

kadircan_t
Not applicable

[ FlexSim 23.1.1 ]

Network_Test.fsmHello,

I created points on GIS Module by Script as follows;

Table points = Table("Locations");
Model.find("GISNavigator").subnodes.clear();
for (int i = 1; i <= points.numRows; i++) {
    string id = points [1];
    double lat = points[2];
    double long = points[3];
    Object point = Object.create("GIS::Point");
    point.setProperty("Latitude", lat);
    point.setProperty("Longitude", long);
    setname(point, id);
}


I want to connect points according to the "Connections" global table according to cells that contains value "1"

for (int i = 1; i <= routes.numRows; i++ ) {
    for (int j = i+1; j <= routes.numCols; j++ ) {
        if    (routes == 1 ) {
        contextdragconnection ( connections, connections, "A");
        }
    }
}

I tried to connect with contextdragconnection command but failed. How should I update my script?

Thank you,

0 Likes
Accepted solutions (1)
28 Views
2 Replies
Replies (2)
Message 2 of 3

moehlmann_fe
Observer
Observer
Accepted solution

I don't know how you got to using connections[], but it is just a shortcut to access the node where the port connections of an object are stored in its attribute tree. So using this here will naturally not do anything/produce errors.

Your logic makes sense if you add the created points to an array and use those entries in contextdragconnection().

Table points = Table("Locations");
Array GISPoints = []; Model.find("GISNavigator").subnodes.clear(); for (int i = 1; i <= points.numRows; i++) {     string id = points [1];     double lat = points[2];     double long = points[3];     Object point = Object.create("GIS::Point");     point.setProperty("Latitude", lat);     point.setProperty("Longitude", long);     setname(point, id);     GISPoints.push(point); } Table routes = Table ("Connections"); for (int i = 1; i <= routes.numRows; i++ ) {     for (int j = i+1; j <= routes.numCols; j++ ) {         if    (routes == 1 ) {         contextdragconnection (GISPoints, GISPoints, "A");         }     } }

Furthermore, I would suggest to format your table differently, otherwise you will have to take into account an offset in the index between the locations and connections table.

capture1.png

Additionally your code currently only looks at the upper right half of the table (which makes sense if the table were symmetric).

Message 3 of 3

kadircan_t
Not applicable

Thank you @Felix Möhlmann , This is what I am looking for.

0 Likes