################################################################################ ### Creating a graph from imported OSM data (6 / 11) ################################################################################ ### Description: ### - This script creates a graph from imported OSM data. ### Please, see tu_osm_import.sh for further details. ### ### Precondition: ### - activated necessary algebras ### - existing open database with successfully imported osm data ### - NodesRel-relation ### NodesRel: rel{Node: point, NodeId: int} ### - ExtSectionsRel-relation ### ExtSectionsRel: rel{SectionId: int, Section: sline, StartNodeId: int, ### EndNodeId: int, StreetId: int, GroupId: int, ### SectionDist: real} ### ### Postconditions: ### - CityGraphRel-relation ### CityGraphRel: rel{StreetId: int, Costs: real, NodeId1: int, NodeId2: int, ### Node1: point, Node2: point} ### - CityGraph-graph ### ### Author: ### - Thomas Uchdorf, thomas.uchdorf(at)fernuni-hagen.de ################################################################################ # Computing data on the city graph let CityGraphRel = NodesRel feed {n2} ( NodesRel feed {n1} ExtSectionsRel feed projectextend [StartNodeId, EndNodeId, StreetId; Costs : size(.Section)] # Costs : size(.Section,create_geoid("WGS1984"))] hashjoin [NodeId_n1, StartNodeId, 99997] project [StartNodeId, EndNodeId, StreetId, Costs, Node_n1] ) hashjoin [NodeId_n2, EndNodeId, 99997] project [StartNodeId, EndNodeId, Node_n1, Node_n2, StreetId, Costs] extendstream [D : intstream(0,1) ] projectextend [StreetId, Costs; NodeId1 : ifthenelse(.D=0 , .StartNodeId, .EndNodeId), NodeId2 : ifthenelse(.D=0 , .EndNodeId, .StartNodeId), Node1 : ifthenelse(.D=0 , .Node_n1, .Node_n2), Node2 : ifthenelse(.D=0 , .Node_n2, .Node_n1)] consume; # Creating the graph of the city let CityGraph = CityGraphRel feed constgraphpoints[NodeId1, NodeId2, .Costs, Node1, Node2];