Exemple #1
0
 /// <summary>
 /// Splits the list of segments into 2 lists depening where they lay(West or East). If it's stuck between the
 /// two, it splits it in half and adds the halves to the according list.
 /// </summary>
 /// <param name="split">List of street segments being split.</param>
 /// <param name="x">Value of X on the graph.</param>
 /// <param name="east">list of all segments east.</param>
 /// <param name="west">List of all segments west.</param>
 private static void SplitEastWest(List <StreetSegment> split, float x, List <StreetSegment> east,
                                   List <StreetSegment> west)
 {
     foreach (StreetSegment street in split)
     {
         if (street.Start.X <= x && street.End.X <= x)
         {
             west.Add(street);
         }
         else if (street.Start.X > x && street.End.X > x)
         {
             east.Add(street);
         }
         else
         {
             StreetSegment firstHalf  = street;
             StreetSegment secondHalf = street;
             float         y          = (((street.End.Y - street.Start.Y) * (x - street.Start.X)) / (street.End.X - street.Start.X))
                                        + street.Start.Y;
             firstHalf.Start = new PointF(x, y);
             secondHalf.End  = new PointF(x, y);
             if (firstHalf.End.X > x)
             {
                 east.Add(firstHalf);
                 west.Add(secondHalf);
             }
             else
             {
                 east.Add(secondHalf);
                 west.Add(firstHalf);
             }
         }
     }
 }
        /// <summary>
        /// Private method ReadFile reads the contents of a file using a StreamReader and mapBounds
        /// </summary>
        /// <param name="fileName">This string is the filename passed in</param>
        /// <param name="mapBounds">Passed as a reference, this RectangleF will contain the bounds of the map</param>
        /// <returns></returns>
        private static List <StreetSegment> ReadFile(string fileName, out RectangleF mapBounds)
        {
            using (StreamReader sr = new StreamReader(fileName))
            {
                string[]             lines;
                List <StreetSegment> streets = new List <StreetSegment>();
                string   heightAndWidth      = sr.ReadLine();
                string[] fields = heightAndWidth.Split(',');
                mapBounds = new RectangleF(0, 0, Convert.ToSingle(fields[0]), Convert.ToSingle(fields[1]));

                while (!sr.EndOfStream)
                {
                    fields = sr.ReadLine().Split(',');
                    float x1 = Convert.ToSingle(fields[0]);
                    float y1 = Convert.ToSingle(fields[1]);
                    float x2 = Convert.ToSingle(fields[2]);
                    float y2 = Convert.ToSingle(fields[3]);

                    PointF point1 = new PointF(x1, y1);
                    PointF point2 = new PointF(x2, y2);

                    Color         color  = Color.FromArgb(Convert.ToInt32(fields[4]));
                    float         width  = Convert.ToSingle(fields[5]);
                    int           zoom   = Convert.ToInt32(fields[6]);
                    StreetSegment street = new StreetSegment(point1, point2, color, width, zoom);
                    streets.Add(street);
                }

                return(streets);
            }
        }
Exemple #3
0
        /// <summary>
        /// Splits the streets into a north and south portion
        /// </summary>
        /// <param name="split">The street segment to be split</param>
        /// <param name="horizontal">The y value of the horizontal line</param>
        /// <param name="north">The street segment north of the horizontal line</param>
        /// <param name="south">The street segment south of the horizontal line</param>
        private static void SplitNorthSouth(List <StreetSegment> split, float horizontal, List <StreetSegment> north, List <StreetSegment> south)
        {
            foreach (StreetSegment street in split)
            {
                if (street.Ending.Y <= horizontal && street.Starting.Y <= horizontal)
                {
                    north.Add(street);
                }
                else if (street.Ending.Y >= horizontal && street.Starting.Y >= horizontal)
                {
                    south.Add(street);
                }
                else
                {
                    StreetSegment newNorth = street;
                    StreetSegment newSouth = street;

                    float  newX   = ((street.Ending.X - street.Starting.X) * (horizontal - street.Starting.Y) / (street.Ending.Y - street.Starting.Y)) + street.Starting.X;
                    PointF pointf = new PointF(newX, horizontal);

                    newNorth.Ending   = pointf;
                    newSouth.Starting = pointf;
                    if (newNorth.Starting.Y <= horizontal)
                    {
                        north.Add(newNorth);
                        south.Add(newSouth);
                    }
                    else
                    {
                        north.Add(newSouth);
                        south.Add(newNorth);
                    }
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Splits the street segments into an east and west portion
        /// </summary>
        /// <param name="split">Street segment to split</param>
        /// <param name="vertical">The x value of the vertical line</param>
        /// <param name="west">The street segments west of the vertical line</param>
        /// <param name="east">The street segments east of the vertical line</param>
        private static void SplitEastWest(List <StreetSegment> split, float vertical, List <StreetSegment> west, List <StreetSegment> east)
        {
            foreach (StreetSegment street in split)
            {
                if (street.Ending.X <= vertical && street.Starting.X <= vertical)
                {
                    west.Add(street);
                }
                else if (street.Ending.X >= vertical && street.Starting.X >= vertical)
                {
                    east.Add(street);
                }
                else
                {
                    StreetSegment newEast = street;
                    StreetSegment newWest = street;

                    float  newY   = ((street.Ending.Y - street.Starting.Y) * (vertical - street.Starting.X) / (street.Ending.X - street.Starting.X)) + street.Starting.Y;
                    PointF pointf = new PointF(vertical, newY);

                    newEast.Ending   = pointf;
                    newWest.Starting = pointf;
                    if (newEast.Ending.X >= vertical)
                    {
                        east.Add(newEast);
                        west.Add(newWest);
                    }
                    else
                    {
                        east.Add(newWest);
                        west.Add(newEast);
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// splits list of streets into east and west
        /// </summary>
        /// <param name="streets">list of streets to split</param>
        /// <param name="x">point to determine east and west sides</param>
        /// <param name="west">list to put all west street segments</param>
        /// <param name="east">list to put all east street segments</param>
        private static void SplitEastWest(List <StreetSegment> streets, float x, List <StreetSegment> west, List <StreetSegment> east)
        {
            for (int i = 0; i < streets.Count; i++)
            {
                if (streets[i].Start.X <= x && streets[i].End.X <= x)
                {
                    west.Add(streets[i]);
                }
                else if (streets[i].Start.X >= x && streets[i].End.X >= x)
                {
                    east.Add(streets[i]);
                }
                else
                {
                    float y = (((streets[i].End.Y - streets[i].Start.Y) * (x - streets[i].Start.X)) / (streets[i].End.X - streets[i].Start.X)) + streets[i].Start.Y;

                    StreetSegment copy1 = streets[i];
                    StreetSegment copy2 = streets[i];

                    copy1.Start = new PointF(x, y);
                    copy2.End   = new PointF(x, y);

                    if (copy1.End.X <= x)
                    {
                        west.Add(copy1);
                        east.Add(copy2);
                    }
                    else
                    {
                        west.Add(copy2);
                        east.Add(copy1);
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// splits list of streets into east and west
        /// </summary>
        /// <param name="streets">list of streets to split</param>
        /// <param name="y">point to determine north and south sides</param>
        /// <param name="north">list to put all north street segments</param>
        /// <param name="south">list to put all south street segments</param>
        private static void SplitNorthSouth(List <StreetSegment> streets, float y, List <StreetSegment> north, List <StreetSegment> south)
        {
            for (int i = 0; i < streets.Count; i++)
            {
                if (streets[i].Start.Y <= y && streets[i].End.Y <= y)
                {
                    south.Add(streets[i]);
                }
                else if (streets[i].Start.Y >= y && streets[i].End.Y >= y)
                {
                    north.Add(streets[i]);
                }
                else
                {
                    float x = (((streets[i].End.X - streets[i].Start.X) * (y - streets[i].Start.Y)) / (streets[i].End.Y - streets[i].Start.Y)) + streets[i].Start.X;

                    StreetSegment copy1 = streets[i];
                    StreetSegment copy2 = streets[i];

                    copy1.Start = new PointF(x, y);
                    copy2.End   = new PointF(x, y);

                    if (copy1.End.Y <= y)
                    {
                        south.Add(copy1);
                        north.Add(copy2);
                    }
                    else
                    {
                        south.Add(copy2);
                        north.Add(copy1);
                    }
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Works similar to the above method. Splits the segments from the list into 2 new lists. If it's between the
 /// 2 directions, it splits it in half and adds them to the correct list.
 /// </summary>
 /// <param name="split">List of segments being split</param>
 /// <param name="y">value of Y on the graph.</param>
 /// <param name="north">List of segments north.</param>
 /// <param name="south">List of segments south.</param>
 private static void SplitNorthSouth(List <StreetSegment> split, float y, List <StreetSegment> north,
                                     List <StreetSegment> south)
 {
     foreach (StreetSegment street in split)
     {
         if (street.Start.Y <= y && street.End.Y <= y)
         {
             north.Add(street);
         }
         else if (street.Start.Y > y && street.End.Y > y)
         {
             south.Add(street);
         }
         else
         {
             StreetSegment firstHalf  = street;
             StreetSegment secondHalf = street;
             float         x          = (((street.End.X - street.Start.X) * (y - street.Start.Y)) / (street.End.Y - street.Start.Y))
                                        + street.Start.X;
             firstHalf.End    = new PointF(x, y);
             secondHalf.Start = new PointF(x, y);
             if (firstHalf.End.Y > y)
             {
                 south.Add(firstHalf);
                 north.Add(secondHalf);
             }
             else
             {
                 south.Add(secondHalf);
                 north.Add(firstHalf);
             }
         }
     }
 }
Exemple #8
0
        /// <summary>
        /// Private method SplitEastWest splits street segments into an east portion and a west portion
        /// </summary>
        /// <param name="splitSegments">The segments to split</param>
        /// <param name="givenX">A given int to determine where to place the split segments</param>
        /// <param name="westSegmentsList">the western segments</param>
        /// <param name="eastSegmentsList">the eastern segments</param>
        private static void SplitEastWest(List <StreetSegment> splitSegments, float givenX, List <StreetSegment> westSegmentsList, List <StreetSegment> eastSegmentsList)
        {
            foreach (StreetSegment segment in splitSegments)
            {
                //beginning x coordinates
                float x1 = segment.End.X;

                //ending x coordinates
                float x2 = segment.Start.X;

                //Case 1: Both endpoints x-coordinates are no greater than the givenX
                if (x1 <= givenX && x2 <= givenX)
                {
                    westSegmentsList.Add(segment);
                }

                //Case 2: Both endpoints x-coordinates are no less than the givenX
                else if (x1 >= givenX && x2 >= givenX)
                {
                    eastSegmentsList.Add(segment);
                }

                //Case 3: one endpoint is west of vertical line, other is east.
                //In this case we split the segment into two segments with
                //One segment lying to the west of the vertical line and the other to the east
                else
                {
                    float newY = ((segment.End.Y - segment.Start.Y) / (segment.End.X - segment.Start.X) * (givenX - segment.Start.X)) + segment.Start.Y;

                    StreetSegment s1 = segment;
                    StreetSegment s2 = segment;
                    s1.End   = new PointF(givenX, newY);
                    s2.Start = new PointF(givenX, newY);
                    if (s1.Start.X <= givenX)
                    {
                        eastSegmentsList.Add(s2);
                        westSegmentsList.Add(s1);
                    }

                    if (s2.Start.X >= givenX)
                    {
                        eastSegmentsList.Add(s1);
                        westSegmentsList.Add(s2);
                    }
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Private method SplitNorthSouth seperates segments into lists of north or south based on a given Y and a segment
        /// </summary>
        /// <param name="splitSegments">Segments to split</param>
        /// <param name="givenY">The given Y coordinate</param>
        /// <param name="northSegmentsList">A list of the segments going to the North</param>
        /// <param name="southSegmentsLIst">A list of the segments going to the South</param>
        private static void SplitNorthSouth(List <StreetSegment> splitSegments, float givenY, List <StreetSegment> southSegmentsList, List <StreetSegment> northSegmentsList)
        {
            foreach (StreetSegment segment in splitSegments)
            {
                //beginning y coordinates
                float y1 = segment.Start.Y;

                //ending y coordinates
                float y2 = segment.End.Y;

                //Case 1: Both endpoints y-coordinates are no greater than the givenX
                if (y1 <= givenY && y2 <= givenY)
                {
                    northSegmentsList.Add(segment);
                }

                //Case 2: Both endpoints x-coordinates are no less than the givenX
                else if (y1 >= givenY && y2 >= givenY)
                {
                    southSegmentsList.Add(segment);
                }

                //Case 3: one endpoint is west of vertical line, other is east.
                //In this case we split the segment into two segments with
                //One segment lying to the west of the vertical line and the other to the east
                else
                {
                    float newX = ((segment.End.X - segment.Start.X) / (segment.End.Y - segment.Start.Y) * (givenY - segment.Start.Y)) + segment.Start.X;

                    StreetSegment s1 = segment;
                    StreetSegment s2 = segment;
                    s1.End   = new PointF(newX, givenY);
                    s2.Start = new PointF(newX, givenY);
                    if (s1.Start.Y <= givenY)
                    {
                        southSegmentsList.Add(s2);
                        northSegmentsList.Add(s1);
                    }

                    if (s2.Start.X >= givenY)
                    {
                        southSegmentsList.Add(s1);
                        northSegmentsList.Add(s2);
                    }
                }
            }
        }
Exemple #10
0
        Map uxMap;             //the Map to be used

        /// <summary>
        /// Used to read a csv file
        /// </summary>
        /// <param name="fileName">the name of the file</param>
        /// <param name="bounds">output a rectangle from the first line of the file</param>
        /// <returns></returns>
        private static List <StreetSegment> ReadFile(string fileName, out RectangleF bounds)
        {
            List <StreetSegment> map = new List <StreetSegment>();

            using (StreamReader input = new StreamReader(fileName))
            {
                string[] rect = input.ReadLine().Split(',');
                bounds = new RectangleF(0, 0, Convert.ToSingle(rect[0]), Convert.ToSingle(rect[1]));
                while (!input.EndOfStream)
                {
                    string[]      para   = input.ReadLine().Split(',');
                    PointF        start  = new PointF(Convert.ToSingle(para[0]), Convert.ToSingle(para[1]));
                    PointF        end    = new PointF(Convert.ToSingle(para[2]), Convert.ToSingle(para[3]));
                    StreetSegment street = new StreetSegment(start, end, Color.FromArgb(Convert.ToInt32(para[4])), Convert.ToSingle(para[5]), Convert.ToInt32(para[6]));
                    map.Add(street);
                }
                return(map);
            }
        }
Exemple #11
0
        /// <summary>
        /// Reads the file inputted and puts the values into a list of street segments.
        /// </summary>
        /// <param name="f">String of street data.</param>
        /// <param name="bounds">Area of the streets.</param>
        /// <returns></returns>
        private static List <StreetSegment> ReadFile(string f, out RectangleF bounds)
        {
            /*List<StreetSegment> _streets = new List<StreetSegment>();
             *
             * using (StreamReader sr = new StreamReader(f))
             * {
             *  string[] coords = sr.ReadLine().Split(',');
             *  bounds = new RectangleF(0, 0, Convert.ToSingle(coords[0]), Convert.ToSingle(coords[1]));
             *
             *  while (!sr.EndOfStream)
             *  {
             *      string[] lines = sr.ReadLine().Split(',');
             *      PointF start = new PointF(Convert.ToInt32(lines[0]), Convert.ToInt32(lines[1]));
             *      PointF end = new PointF(Convert.ToInt32(lines[2]), Convert.ToInt32(lines[3]));
             *      Color color = Color.FromArgb(Convert.ToInt32(lines[4]));
             *      int vl = Convert.ToInt32(lines[5]);
             *      float w = Convert.ToSingle(lines[6]);
             *      StreetSegment street = new StreetSegment(start, end, color, w, vl);
             *      _streets.Add(street);
             *  }
             * }
             * return _streets;*/

            List <StreetSegment> list = new List <StreetSegment>();


            using (StreamReader input = new StreamReader(f))
            {
                string[] conttents = input.ReadLine().Split(',');
                bounds = new RectangleF(0, 0, Convert.ToSingle(conttents[0]), Convert.ToSingle(conttents[1]));
                while (!input.EndOfStream)
                {
                    string[] contents = input.ReadLine().Split(',');

                    PointF        start = new PointF(Convert.ToSingle(contents[0]), Convert.ToSingle(contents[1]));
                    PointF        end   = new PointF(Convert.ToSingle(contents[2]), Convert.ToSingle(contents[3]));
                    StreetSegment str   = new StreetSegment(start, end, Color.FromArgb(Convert.ToInt32(contents[4])), Convert.ToSingle(contents[5]), Convert.ToInt32(contents[6]));
                    list.Add(str);
                }
            }

            return(list);
        }
Exemple #12
0
        }         //END OF uxOpenMap_Click METHOD

        /// <summary>
        /// Reads the file from the excel CSV doc
        /// </summary>
        /// <param name="fileName">Holds the string name to the file</param>
        /// <param name="mapBounds">Holds the map bounds for the QuadTree class</param>
        /// <returns></returns>
        private static List <StreetSegment> ReadFile(string fileName, out RectangleF mapBounds)
        {
            List <StreetSegment> listOfStreets = new List <StreetSegment>();

            using (StreamReader input = new StreamReader(fileName))
            {
                string[] lines  = input.ReadLine().Split(',');
                float    width  = Convert.ToSingle(lines[0]);
                float    length = Convert.ToSingle(lines[1]);
                mapBounds = new RectangleF(0, 0, width, length);
                while (!input.EndOfStream)
                {
                    lines = input.ReadLine().Split(',');
                    PointF        xCord     = new PointF(Convert.ToSingle(lines[0]), Convert.ToSingle(lines[1]));
                    PointF        yCord     = new PointF(Convert.ToSingle(lines[2]), Convert.ToSingle(lines[3]));
                    Color         color     = Color.FromArgb(Convert.ToInt32(lines[4]));
                    StreetSegment newStreet = new StreetSegment(xCord, yCord, color, Convert.ToSingle(lines[5]), Convert.ToInt32(lines[6]));
                    listOfStreets.Add(newStreet);
                } //END OF WHILE LOOP
            }     //END OF USING STATEMENT
            return(listOfStreets);
        }         //END OF ReadFile method
Exemple #13
0
        /// <summary>
        /// splits north and south
        /// </summary>
        /// <param name="splitStreet">streets to split</param>
        /// <param name="y">point to split at</param>
        /// <param name="northStreets">north streets</param>
        /// <param name="southStreets">south streets</param>
        private static void SplitNorthSouth(List <StreetSegment> splitStreet, float y, List <StreetSegment> northStreets, List <StreetSegment> southStreets)
        {
            foreach (StreetSegment s in splitStreet)
            {
                if (s.Start.Y <= y & s.End.Y <= y)
                {
                    northStreets.Add(s);
                }
                else if (s.Start.Y >= y & s.End.Y >= y)
                {
                    southStreets.Add(s);
                }
                else
                {
                    StreetSegment sCopy1 = s;
                    StreetSegment sCopy2 = s;
                    float         x1     = s.Start.X;
                    float         y1     = s.Start.Y;
                    float         x2     = s.End.X;
                    float         y2     = s.End.Y;
                    float         x      = (((x2 - x1) * (y - y1)) / (y2 - y1)) + x1;

                    sCopy1.End   = new PointF(x, y);
                    sCopy2.Start = new PointF(x, y);
                    if (sCopy1.Start.X >= x)
                    {
                        southStreets.Add(sCopy1);
                        northStreets.Add(sCopy2);
                    }
                    else
                    {
                        southStreets.Add(sCopy2);
                        northStreets.Add(sCopy1);
                    }
                }
            }
        }
Exemple #14
0
        /// <summary>
        /// Splits east and west lines
        /// </summary>
        /// <param name="splitStreet">the list to split</param>
        /// <param name="x">the point to seperate east and west</param>
        /// <param name="westStreets">a list of west streets</param>
        /// <param name="eastStreets">a list of east streets</param>
        private static void SplitEastWest(List <StreetSegment> splitStreet, float x, List <StreetSegment> westStreets, List <StreetSegment> eastStreets)
        {
            foreach (StreetSegment s in splitStreet)
            {
                if (s.Start.X <= x & s.End.X <= x)
                {
                    westStreets.Add(s);
                }
                else if (s.Start.X >= x & s.End.X >= x)
                {
                    eastStreets.Add(s);
                }
                else
                {
                    StreetSegment sCopy1 = s;
                    StreetSegment sCopy2 = s;
                    float         x1     = s.Start.X;
                    float         y1     = s.Start.Y;
                    float         x2     = s.End.X;
                    float         y2     = s.End.Y;
                    float         y      = (((y2 - y1) * (x - x1)) / (x2 - x1)) + y1;

                    sCopy1.End   = new PointF(x, y);
                    sCopy2.Start = new PointF(x, y);
                    if (sCopy1.Start.X >= x)
                    {
                        eastStreets.Add(sCopy1);
                        westStreets.Add(sCopy2);
                    }
                    else
                    {
                        eastStreets.Add(sCopy2);
                        westStreets.Add(sCopy1);
                    }
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// Splits street segments into a north portion and a south portion.
        /// </summary>
        /// <param name="tosplit"></param>
        /// <param name="north"></param>
        /// <param name="south"></param>
        private static void SplitNorthSouth(List <StreetSegment> tosplit, float value, List <StreetSegment> north, List <StreetSegment> south)
        {
            foreach (StreetSegment temp in tosplit)
            {
                if (temp.Start.Y <= value && temp.End.Y <= value)
                {
                    south.Add(temp);
                }
                else if (temp.Start.Y >= value && temp.End.Y >= value)
                {
                    north.Add(temp);
                }
                else
                {
                    if (temp.Start.X != temp.End.X)
                    {
                        float         x   = (((temp.End.X - temp.Start.X) / (temp.End.Y - temp.Start.Y)) * (value - temp.Start.Y)) + temp.Start.X;
                        PointF        mid = new PointF(x, value);
                        StreetSegment n   = temp;
                        StreetSegment s   = temp;
                        n.End   = mid;
                        s.Start = mid;

                        if (n.Start.Y >= value)
                        {
                            north.Add(n);
                            south.Add(s);
                        }
                        else
                        {
                            north.Add(s);
                            south.Add(n);
                        }
                    }
                }
            }
        }
Exemple #16
0
        /// <summary>
        /// Reads in data from input files.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="bounds"></param>
        /// <returns></returns>
        private static List <StreetSegment> ReadFile(string name, out RectangleF bounds)
        {
            List <StreetSegment> Data = new List <StreetSegment>();

            using (StreamReader input = new StreamReader(name))
            {
                string[] line = input.ReadLine().Split(',');

                float width  = Convert.ToSingle(line[0]);
                float height = Convert.ToSingle(line[1]);
                bounds = new RectangleF(0, 0, width, height);

                while (!input.EndOfStream)
                {
                    line = input.ReadLine().Split(',');
                    Color         color = Color.FromArgb(Convert.ToInt32(line[4]));
                    PointF        X     = new PointF(Convert.ToSingle(line[0]), Convert.ToSingle(line[1]));
                    PointF        Y     = new PointF(Convert.ToSingle(line[2]), Convert.ToSingle(line[3]));
                    StreetSegment temp  = new StreetSegment(X, Y, color, Convert.ToSingle(line[5]), Convert.ToInt32(line[6]));
                    Data.Add(temp);
                }
            }
            return(Data);
        }
Exemple #17
0
 /// <summary>
 /// Splits street segments into an east portion and a west portion.
 /// </summary>
 /// <param name="tosplit"></param>
 /// <param name="west"></param>
 /// <param name="east"></param>
 private static void SplitEastWest(List <StreetSegment> tosplit, float value, List <StreetSegment> west, List <StreetSegment> east)
 {
     foreach (StreetSegment temp in tosplit)
     {
         if (temp.Start.X <= value && temp.End.X <= value)
         {
             west.Add(temp);
         }
         else if (temp.Start.X >= value && temp.End.X >= value)
         {
             east.Add(temp);
         }
         else
         {
             if (temp.Start.X != temp.End.X)
             {
                 float         y   = (((temp.End.Y - temp.Start.Y) / (temp.End.X - temp.Start.X)) * (value - temp.Start.X)) + temp.Start.Y;
                 PointF        mid = new PointF(value, y);
                 StreetSegment w   = temp;
                 StreetSegment e   = temp;
                 w.End   = mid;
                 e.Start = mid;
                 if (w.Start.X <= value)
                 {
                     west.Add(w);
                     east.Add(e);
                 }
                 else
                 {
                     west.Add(e);
                     east.Add(w);
                 }
             }
         }
     }
 }
Exemple #18
0
        }         //END OF visibility

        /// <summary>
        /// Iterates through the street segments to split east or west
        /// </summary>
        /// <param name="split">List of streetSegments to split</param>
        /// <param name="vertical">giving the value of a verticle line</param>
        /// <param name="west">street segments west of the given vertical line will be placed here</param>
        /// <param name="east">street segments east of the given vertical line will be placed here</param>
        private static void eastOrWest(List <StreetSegment> split, float vertical, List <StreetSegment> west, List <StreetSegment> east)
        {
            foreach (StreetSegment street in split)
            {
                if (street.start.X <= vertical && street.end.X <= vertical)
                {
                    west.Add(street);
                }   //END OF IF STATEMENT
                else if (street.start.X >= vertical && street.end.X >= vertical)
                {
                    east.Add(street);
                }   //END OF ELSE-IF STATEMENT
                else
                {
                    if (street.start.X != street.end.X)
                    {
                        StreetSegment tempEast = street;
                        StreetSegment tempWest = street;
                        float         YCord    = (((street.end.Y - street.start.Y) / (street.end.X - street.start.X)) * (vertical - street.start.X)) + street.start.Y;
                        PointF        tempE    = new PointF(vertical, YCord);
                        tempWest.end   = tempE;
                        tempEast.start = tempE;
                        if (tempWest.start.X <= vertical)
                        {
                            west.Add(tempWest);
                            east.Add(tempEast);
                        }   //END OF IF STATEMENT
                        else
                        {
                            west.Add(tempEast);
                            east.Add(tempWest);
                        } //END OF ELSE STATEMENT
                    }     //END OF IF STATEMENT
                }         //END OF ELSE-IF STATEMENT
            }             //END OF foreach LOOP
        }                 //END OF eastORWest METHOD
Exemple #19
0
        }                 //END OF eastORWest METHOD

        /// <summary>
        /// Method used to split the streets into north or south lists
        /// </summary>
        /// <param name="split">Full list of streets</param>
        /// <param name="horizontal">The horizontal point we are splitting upon</param>
        /// <param name="north">The list that will be modified to hold the north streets</param>
        /// <param name="south">The list that will be modified to hold the south streets</param>
        private static void northOrSouth(List <StreetSegment> split, float horizontal, List <StreetSegment> north, List <StreetSegment> south)
        {
            foreach (StreetSegment street in split)
            {
                if (street.start.Y <= horizontal && street.end.Y <= horizontal)
                {
                    south.Add(street);
                }   //END OF IF STATEMENT
                else if (street.start.Y >= horizontal && street.end.Y >= horizontal)
                {
                    north.Add(street);
                }   //END OF ELSE-IF STATEMENT
                else
                {
                    if (street.end.X != street.start.X)
                    {
                        StreetSegment tempNorth = street;
                        StreetSegment tempSouth = street;
                        float         xCord     = (((street.end.X - street.start.X) / (street.end.Y - street.start.Y)) * (horizontal - street.start.Y)) + street.start.X;
                        PointF        tempE     = new PointF(xCord, horizontal);
                        tempNorth.end   = tempE;
                        tempSouth.start = tempE;
                        if (street.start.Y > horizontal)
                        {
                            north.Add(tempNorth);
                            south.Add(tempSouth);
                        }   //END OF IF STATEMENT
                        else
                        {
                            south.Add(tempNorth);
                            north.Add(tempSouth);
                        } //END OF ELSE STATEMENT
                    }     //END OF IF STATEMENT
                }         //END OF ELSE STATEMENT
            }             //END OF FOREACH LOOP
        }                 //END OF northOrSouth METHOD