Example #1
0
 public void Add(Straat _straat)
 {
     Count = Count + 1;
     Array.Resize(ref straten, Count);
     straten[(Count - 1)] = _straat;
 }
Example #2
0
        /// <summary>
        /// not 100% functional, for better results use upgraded non-selectve ReadAll()
        /// </summary>
        /// <param name="targetGemeente"></param>
        public void Read(string targetGemeente)
        {
            long         totalTimeElapsed = 0;
            StreamReader reader;
            Gemeente     gevondenGemeente  = null;
            Provincie    gevondenProvincie = null;
            Straat       gevondenStraat    = null;
            // READ GEMEENTEDATA
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            reader = new StreamReader(WRGemeentenaam);
            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split(';');

                if (values[2].Equals(this.TaalCode) && values[3].Equals(targetGemeente))
                {
                    gevondenGemeente = new Gemeente(line);
                }
            }
            reader.Close();
            stopWatch.Stop();
            Console.WriteLine($"Reading gemeentedata took {stopWatch.ElapsedMilliseconds} millis.");
            totalTimeElapsed += stopWatch.ElapsedMilliseconds;
            stopWatch.Reset();
            // READ PROVINCIEDATA
            stopWatch.Start();
            reader = new StreamReader(provincieInfo);
            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split(';');
                if (!String.IsNullOrEmpty(line) && Char.IsLetter(line[0]))
                {
                    continue;
                }
                if (values[2].Equals(this.TaalCode) && gevondenGemeente.Id == int.Parse(values[0]))
                {
                    gevondenProvincie = new Provincie(line);
                    gevondenProvincie.Gemeentes.Add(gevondenGemeente);
                    this.Regios[0].Provincies.Add(gevondenProvincie);
                }
            }
            reader.Close();
            stopWatch.Stop();
            Console.WriteLine($"Reading provinciedata took {stopWatch.ElapsedMilliseconds} millis.");
            totalTimeElapsed += stopWatch.ElapsedMilliseconds;
            stopWatch.Reset();
            // READ STREETID DATA
            stopWatch.Start();
            reader = new StreamReader(straatnaamID_gemeenteID);
            while (!reader.EndOfStream)
            {
                var line   = reader.ReadLine();
                var values = line.Split(';');

                if (!String.IsNullOrEmpty(line) && Char.IsLetter(line[0]))
                {
                    continue;
                }

                if (int.Parse(values[1]).Equals(gevondenGemeente.Id))
                {
                    gevondenStraat = new Straat(line);
                    this.Regios[0].Provincies[0].Gemeentes[0].Straten.Add(gevondenStraat);
                }
            }
            Console.WriteLine(this.Naam + ", " + this.Regios[0].Naam + ", " +
                              this.Regios[0].Provincies[0].Naam + ", " +
                              this.Regios[0].Provincies[0].Gemeentes[0].Naam + " heeft " +
                              this.Regios[0].Provincies[0].Gemeentes[0].Straten.Count +
                              " straten geregistreerd.");
            reader.Close();
            stopWatch.Stop();
            Console.WriteLine($"Reading streetiddata took {stopWatch.ElapsedMilliseconds} millis.");
            totalTimeElapsed += stopWatch.ElapsedMilliseconds;
            stopWatch.Reset();
            // READ STREETNAMEDATA
            stopWatch.Start();
            reader = new StreamReader(WRstraatnamen);
            while (!reader.EndOfStream)
            {
                string line   = reader.ReadLine().TrimEnd();
                var    values = line.Split(';');
                if (!String.IsNullOrEmpty(line) && Char.IsLetter(line[0]))
                {
                    continue;
                }

                if (this.Regios[0].Provincies[0].Gemeentes[0].Straten.Exists(int.Parse(values[0])))
                {
                    this.Regios[0].Provincies[0].Gemeentes[0].Straten.KenNaamToe(int.Parse(values[0]), values[1]);
                }
            }
            reader.Close();
            stopWatch.Stop();
            Console.WriteLine($"Reading streetnamedata took {stopWatch.ElapsedMilliseconds} millis.");
            totalTimeElapsed += stopWatch.ElapsedMilliseconds;
            Console.WriteLine($"Total time elpased: {totalTimeElapsed} millis.");
            stopWatch.Reset();
        }