def CreateRoads(self): cadis_roads = [] for rname, road in self.World.IterEdges(edgetype='Road'): if rname in self.RoadMap: continue if road.RoadType.Name not in self.LayoutSettings.RoadTypeMap: self.Logger.warn('Failed to find asset for %s' % (road.RoadType.Name)) continue # check to see if we need to render this road at all if road.RoadType.Render: zoff = self.LayoutSettings.RoadTypeMap[ road.RoadType.Name][0].ZOffset (p1x, p1y), (p2x, p2y), scene = self.ComputeLocation( road.StartNode, road.EndNode) # Create CADIS road objects for run-time usage cadis_road = Road() cadis_road.StartingPoint = Vector3(p1x, p1y, zoff) cadis_road.EndPoint = Vector3(p2x, p2y, zoff) cadis_road.Width = road.RoadType.TotalWidth( scale=self.WorldScale) cadis_road.Type = road.RoadType.Dump() cadis_roads.append(cadis_road) # build the map so that we do render the reverse roads self.RoadMap[Edge.GenEdgeName(road.StartNode, road.EndNode)] = True self.RoadMap[Edge.GenEdgeName(road.EndNode, road.StartNode)] = True if self.DataFolder and cadis_roads: f = open(os.path.join(self.DataFolder, "roads.js"), "w") f.write(json.dumps(cadis_roads, cls=CADISEncoder)) f.close()
class Road(CADIS): def __init__(self): self.ID = uuid.uuid4() _StartPoint = Vector3(0, 0, 0) @dimension def StartingPoint(self): return self._StartPoint @StartingPoint.setter def StartingPoint(self, value): self._StartPoint = value _EndPoint = Vector3(0, 0, 0) @dimension def EndPoint(self): return self._EndPoint @EndPoint.setter def EndPoint(self, value): self._EndPoint = value _Width = 0 @dimension def Width(self): return self._Width @Width.setter def Width(self, value): self._Width = value _Type = None @dimension def Type(self): return self._Type @Type.setter def Type(self, value): self._Type = value
class SimulationNode(CADIS): def __init__(self): self.ID = uuid.uuid4() _Center = Vector3(0, 0, 0) @dimension def Center(self): return self._Center @Center.setter def Center(self, value): self._Center = value _Angle = 0 @dimension def Angle(self): return self._Angle @Angle.setter def Angle(self, value): self._Angle = value _Name = None @dimension def Name(self): return self._Name @Name.setter def Name(self, value): self._Name = value _Width = 0 @dimension def Width(self): return self._Width @Width.setter def Width(self, value): self._Width = value _Rezcap = Capsule() @dimension def Rezcap(self): return self._Rezcap @Rezcap.setter def Rezcap(self, value): self._Rezcap = value
def CreateNode(self, name, node, list_nodes): tname = node.IntersectionType.Name sig1 = node.EdgeMap.Signature() if tname not in self.LayoutSettings.IntersectionTypeMap: self.Logger.warn('Unable to locate node type %s' % (tname)) return success = False for itype in self.LayoutSettings.IntersectionTypeMap[tname]: sig2 = itype.Signature rot = self.ComputeRotation(sig1, sig2) if rot >= 0: self.NodeMap[name] = itype (p1x, p1y), sim = CalculateOSCoordinates( node.Coord.X + self.BuildOffsetX, node.Coord.Y + self.BuildOffsetY, self) p1z = itype.ZOffset if node.NodeType.Name == "EndPoint": if "BusinessLocation" in node.InheritedDecorations: busloc = node.BusinessLocation.HostObject capsule = busloc.Capsule simnode = BusinessNode() simnode.Rezcap = Capsule() simnode.Rezcap.SourceName = capsule.SourceName simnode.Rezcap.DestinationName = capsule.DestinationName simnode.PeakCustomerCount = node.BusinessLocation.PeakCustomerCount simnode.PeakEmployeeCount = node.BusinessLocation.PeakEmployeeCount simnode.CustomersPerNode = node.BusinessLocation.HostObject.BusinessLocationProfile.CustomersPerNode simnode.EmployeesPerNode = node.BusinessLocation.HostObject.BusinessLocationProfile.EmployeesPerNode simnode.PreferredBusinessTypes = node.BusinessLocation.HostObject.BusinessLocationProfile.PreferredBusinessTypes for edge in busloc.InputEdges: if edge.NodeType.Name == "ResidesAt": bnode = edge.StartNode if "EmploymentProfile" in bnode.Decorations: ep = bnode.EmploymentProfile.HostObject for wedge in ep.InputEdges: self.employedby[ wedge.StartNode.Name] = name elif "ResidentialLocation" in node.InheritedDecorations: resloc = node.ResidentialLocation.HostObject capsule = resloc.Capsule simnode = ResidentialNode() simnode.Rezcap = Capsule() simnode.Rezcap.SourceName = capsule.SourceName simnode.Rezcap.DestinationName = capsule.DestinationName simnode.ResidentsPerNode = resloc.ResidentialLocationProfile.ResidentsPerNode simnode.ResidentCount = node.ResidentialLocation.ResidentCount simnode.ResidenceList = [] for edge in resloc.InputEdges: if edge.NodeType.Name == "ResidesAt": simnode.ResidenceList.append( edge.StartNode.Name) self.livesat[edge.StartNode.Name] = name else: # Create CADIS node objects for run-time usage simnode = SimulationNode() simnode.Name = name simnode.Center = Vector3(p1x, p1y, p1z) simnode.Angle = 90.0 * rot simnode.Width = node.EdgeMap.Widths(scale=self.WorldScale) list_nodes.append(simnode) success = True else: self.Logger.warn("Rotation < 0 for node %s", node) if not success: self.NodeMap[name] = self.LayoutSettings.IntersectionTypeMap[ tname][0] self.Logger.warn( "No match for node %s with type %s and signature %s" % (name, tname, sig1))
class Vehicle(CADIS): ''' classdocs ''' _Name = None @dimension def Name(self): return self._Name @Name.setter def Name(self, value): self._Name = value _Type = None @dimension def Type(self): return self._Type @Type.setter def Type(self, value): self._Type = value _Route = None @dimension def Route(self): return self._Route @Route.setter def Route(self, value): self._Route = value _Target = None @dimension def Target(self): return self._Target @Target.setter def Target(self, value): self._Target = value _Position = Vector3(0, 0, 0) @dimension def Position(self): return self._Position @Position.setter def Position(self, value): self._Position = value _Velocity = Vector3(0, 0, 0) @dimension def Velocity(self): return self._Velocity @Velocity.setter def Velocity(self, value): self._Velocity = value _Rotation = Quaternion(0, 0, 0, 0) @dimension def Rotation(self): return self._Rotation @Rotation.setter def Rotation(self, value): self._Rotation = value def __init__(self): self.ID = uuid.uuid4()