Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using Parser;
- namespace Datastructure
- {
- public class DataCollector : IData
- {
- private ParserController pc;
- ///<summary>
- /// Author: Author: Leo van Essen | s1035621 / Rick Schuiling
- /// Review: Leo van Essen | s1035621
- /// Creating a Parsercontroller Object.
- ///</summary>
- public DataCollector(string chartPath)
- {
- this.pc = new ParserController(chartPath);
- }
- ///<summary>
- /// Author: Leo van Essen | s1035621 / Rick Schuiling
- /// Review: Jarno Nijboer | s1035448
- /// Converting the data from the parser to node and edge objects.
- ///</summary>
- public List<Node> CollectNodes()
- {
- List<Node> nodeList = new List<Node>();
- List<NodeStruct> nodesDataList = pc.GetNodesData();
- foreach (NodeStruct item in nodesDataList)
- {
- Node node = new Node();
- node.NodeId = item.Id;
- CoordinateStruct coor = pc.GetCoordinateById(item.CoordinateId);
- foreach (Point cd in coor.CoordinatePoints)
- {
- PointF coordinates = MakePoint(cd);
- node.Coordinates = coordinates;
- }
- nodeList.Add(node);
- }
- return nodeList;
- }
- ///<summary>
- /// Author: Leo van Essen | s1035621 / Rick Schuiling | s1035296
- /// Review: Jarno Nijboer | s1035448
- /// Changing the data from the parser to node and edge objects.
- ///</summary>
- public List<Edge> CollectEdges()
- {
- List<Edge> edgesList = new List<Edge>();
- List<EdgeStruct> edgesDataList = pc.GetEdgesData();
- foreach (EdgeStruct item in edgesDataList)
- {
- Edge edge = new Edge();
- edge.EdgeId = item.Id;
- edge.StartNodeId = item.FromNodeId;
- edge.DestinationNodeId = item.ToNodeId;
- CoordinateStruct segments = pc.GetCoordinateById(item.CoordinateId);
- foreach (Point coor in segments.CoordinatePoints)
- {
- PointF coordinates = MakePoint(coor);
- edge.Segments.Add(coordinates);
- }
- edgesList.Add(edge);
- }
- return edgesList;
- }
- ///<summary>
- /// Author: Rosan Mosterman | s1027567
- /// Review: Leo van Essen | s1035621
- /// Creating pointF pointdata from parsed points.
- ///</summary>
- public PointF MakePoint(Point item)
- {
- float x = item.X;
- float y = item.Y;
- float xx = x / 1000000;
- float yy = y / 1000000;
- return new PointF(xx, yy);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment