FT.Scraper.TripScraper.GeoCode C# (CSharp) Method

GeoCode() public static method

public static GeoCode ( ) : void
return void
        public static void GeoCode()
        {
            var db = new DBDataContext();

            foreach (var trip in db.CommitteeTrips.Where(_ => !_.CommitteeTripDestinations.Any()))
            {
                if (!string.IsNullOrEmpty(trip.Place))
                {
                    Console.WriteLine("geocoding " + trip.Place);
                    string[] dests = { };
                    if (trip.Place.Contains(" og "))
                    {
                        dests = trip.Place.Split(
                            new string[] { ",", "og" }, StringSplitOptions.RemoveEmptyEntries)
                            .Select(_ => _.Trim()).ToArray();
                    }
                    else
                    {
                        dests = new string[] { trip.Place };
                    }

                    var poss = dests.Select(_ => new { pos = Geo.Geocoder.GeoCode(_, false), place = _ });
                    var destinations = poss.Where(_ => _.pos != null).Select(_ => new CommitteeTripDestination
                    {
                        CommitteeTripId = trip.CommitteeTripId,
                        Lat = _.pos.Lat,
                        Lng = _.pos.Lng,
                        PlaceNameName = _.place.Trim()
                    });
                    db.CommitteeTripDestinations.InsertAllOnSubmit(destinations);
                }
            }
            db.SubmitChanges();

            Console.WriteLine("all done");
        }