Exemplo n.º 1
0
        internal static void ParseSitus()
        {
            var city_list = @"FRESNO,CLOVIS,COALINGA,KINGSBURG,KERMAN,SELMA,FOWLER,SANGER,PARLIER,BIOLA,REEDLEY,DINKEY CREEK,PIEDRA,PINEDALE,PINEHURST,HIGHWAY CITY,DEL REY,HURON,AUBERRY,ORANGE COVE,SAN JOAQUIN,TRANQUILLITY,FIREBAUGH,DINUBA,DOS PALOS,RIVERDALE,MENDOTA,EASTON,SQUAW VALLEY,CARUTHERS,SHAVER LAKE,LATON,PRATHER,HUME LAKE,MALAGA,FRIANT,FIVE POINTS,TOLLHOUSE,RAISIN CITY,MIRAMONTE,CANTUA CREEK,HERNDON,BURRELL,MINERAL,HELM,BIG CREEK,DUNLAP,DUNBAR,HUNTINGTON LA".Split(',');

            city_list.ToList().ForEach(p => Cities.Add(p, Cities.Keys.Count + 1));

            var situs = File.ReadAllLines(@"Data/situs.txt");

            var records = new List <AddressRecord> {
            };

            foreach (var line in situs)
            {
                if (line.StartsWith("PAGE:"))
                {
                    continue;
                }

                (string prefix, int city_id, string suffix) = ParseLine(line);

                if (city_id == 0)
                {
                    msg($"[!] -- no city in: {line}");
                    continue;
                }

                var parts = suffix.Split(' ');

                // "W" "E" etc prefixes are after the city name:

                if (!Char.IsDigit(parts[0][0]))
                {
                    prefix = $"{parts[0][0]} {prefix}";
                    parts  = parts.Skip(1).ToArray();
                }

                if (!Streets.ContainsKey(prefix))
                {
                    Streets.Add(prefix, Streets.Keys.Count + 1);
                }

                records.Add(new AddressRecord {
                    cityname_id = city_id, streetname_id = Streets[prefix], street_address = parts[0], apn_code = parts[1]
                });
            }

            AddressRecords = records.ToArray();

            Save();
        }