Exemple #1
0
        override public void DeserializeFromJSON(JSONNode segmentJSON, Dictionary <string, NetworkLane> lanes)
        {
            this.id        = segmentJSON ["id"];
            this.osmID     = segmentJSON ["osm"].AsInt;
            this.start     = segmentJSON ["start"];
            this.end       = segmentJSON ["end"];
            this.length    = segmentJSON ["length"].AsDouble;
            this.maxSpeed  = segmentJSON ["maxspeed"].AsDouble;
            this.hierarchy = segmentJSON ["hierarchy"];
            this.oneway    = segmentJSON ["oneway"] != null && segmentJSON ["oneway"].AsBool;

            JSONArray jsonForward  = segmentJSON ["lanes"] ["forward"].AsArray;
            JSONArray jsonBackward = segmentJSON ["lanes"] ["backward"].AsArray;
            JSONArray jsonShapes   = segmentJSON ["shapes"].AsArray;
            JSONArray jsonVertices = segmentJSON ["vertices"].AsArray;

            foreach (JSONNode jsonVertex in jsonVertices)
            {
                float x = jsonVertex ["x"].AsFloat;
                float y = jsonVertex ["y"].AsFloat;
                float z = jsonVertex ["z"].AsFloat;
                vertices.Add(new Vector3(x, y, z));
            }

            foreach (JSONNode shapeJSON in jsonShapes.Children)
            {
                NetworkShape shape = NetworkShape.DeserializeFromJSON(shapeJSON);
                this.shapes.Add(shape);
            }

            foreach (JSONString laneID in jsonForward.Children)
            {
                NetworkLane lane;
                if (lanes.TryGetValue(laneID, out lane))
                {
                    this.forwardLanes.Add(lane);
                }
            }

            foreach (JSONString laneID in jsonBackward.Children)
            {
                NetworkLane lane;
                if (lanes.TryGetValue(laneID, out lane))
                {
                    this.backwardLanes.Add(lane);
                }
            }
        }
Exemple #2
0
        public static NetworkShape DeserializeFromJSON(JSONNode shapeJSON)
        {
            string       id    = shapeJSON ["id"];
            NetworkShape shape = new NetworkShape(id);

            JSONArray jsonVertices = shapeJSON ["vertices"].AsArray;

            foreach (JSONNode jsonVertex in jsonVertices)
            {
                float x = jsonVertex ["x"].AsFloat;
                float y = jsonVertex ["y"].AsFloat;
                float z = jsonVertex ["z"].AsFloat;
                shape.vertices.Add(new Vector3(x, y, z));
            }

            return(shape);
        }
Exemple #3
0
        override public void DeserializeFromJSON(JSONNode nodeJSON, Dictionary <string, NetworkLane> lanes)
        {
            this.id        = nodeJSON ["id"];
            this.osmID     = nodeJSON ["osm"].AsInt;
            this.hierarchy = nodeJSON ["hierarchy"];

            JSONArray jsonLanes      = nodeJSON ["lanes"].AsArray;
            JSONArray jsonShapes     = nodeJSON ["shapes"].AsArray;
            JSONArray jsonVertices   = nodeJSON ["vertices"].AsArray;
            JSONArray jsonNeightbors = nodeJSON ["neighbourSegments"].AsArray;

            foreach (JSONNode jsonVertex in jsonVertices)
            {
                float x = jsonVertex ["x"].AsFloat;
                float y = jsonVertex ["y"].AsFloat;
                float z = jsonVertex ["z"].AsFloat;
                this.vertices.Add(new Vector3(x, y, z));
            }

            foreach (JSONString neighbour in jsonNeightbors)
            {
                neighbourSegments.Add(neighbour);
            }

            foreach (JSONNode shapeJSON in jsonShapes.Children)
            {
                NetworkShape shape = NetworkShape.DeserializeFromJSON(shapeJSON);
                this.shapes.Add(shape);
            }

            foreach (JSONString laneID in jsonLanes.Children)
            {
                NetworkLane lane;
                if (lanes.TryGetValue(laneID, out lane))
                {
                    this.lanes.Add(lane);
                }
            }
        }