Exemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Pois EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPois(Poi poi)
 {
     base.AddObject("Pois", poi);
 }
Exemplo n.º 2
0
        public static void GeneratePOI(string cfgName, IEnumerable<PoiObject> poiObjects)
        {
            using (var ctx = new CityContainer())
            {
                var configuration = ctx.Configurations.Single(c => c.Name == cfgName);

                var lastPoiType = string.Empty;
                try
                {
                    foreach (var poiObject in poiObjects)
                    {
                        var poi = new Poi
                                      {
                                          Configuration = configuration,
                                          Vicinity = poiObject.Vicinity,
                                          Name = poiObject.Name,
                                          MapPoint = new MapPoint
                                                         {
                                                             Lat = poiObject.Latitude,
                                                             Lng = poiObject.Longitude
                                                         }
                                      };

                        foreach (var type in poiObject.Types)
                        {
                            lastPoiType = type;

                            string poiType = lastPoiType;
                            poi.Type.Add(ctx.PoiTypes.Single(t => t.Code == poiType));

                        }
                        ctx.Pois.AddObject(poi);
                    }
                    ctx.SaveChanges();
                }
                catch (Exception e)
                {
                    Logger.LogError("Unsupported POI type '{0}'. Please consider adding this "
                        + "type to poi types configuration file.\n{1}", lastPoiType, e.Message);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Poi object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="vicinity">Initial value of the Vicinity property.</param>
 public static Poi CreatePoi(global::System.Int32 id, global::System.String name, global::System.String vicinity)
 {
     Poi poi = new Poi();
     poi.Id = id;
     poi.Name = name;
     poi.Vicinity = vicinity;
     return poi;
 }
Exemplo n.º 4
0
        public static void GeneratePOI(string cfgName, string poiXml)
        {
            using (var ctx = new CityContainer())
            {
                var configuration = ctx.Configurations.Single(c => c.Name == cfgName);

                var document = XDocument.Load(poiXml);
                var results = from c in document.Descendants("result")
                              select new {
            // ReSharper disable PossibleNullReferenceException
                                             Vicinity = c.Element("vicinity").Value,
                                             Name = c.Element("name").Value,
                                             Lat = c.Element("geometry").Element("location").Element("lat").Value,
                                             Lng = c.Element("geometry").Element("location").Element("lng").Value,
                                             Types = c.Elements("type").Select(v => v.Value)
            // ReSharper restore PossibleNullReferenceException
                                         };

                foreach (var result in results)
                {
                    var poi = new Poi
                                  {
                                      Configuration = configuration,
                                      Vicinity = result.Vicinity,
                                      Name = result.Name,
                                      MapPoint = new MapPoint
                                      {
                                          Lat = CommonUtilities.ParseDouble(result.Lat),
                                          Lng = CommonUtilities.ParseDouble(result.Lng)
                                      }
                                  };
                    var lastPoiType = string.Empty;
                    try
                    {
                        foreach (var type in result.Types)
                        {
                            lastPoiType = type;

                            var poiType = lastPoiType;
                            poi.Type.Add(ctx.PoiTypes.Single(t => t.Code == poiType));

                        }
                        ctx.Pois.AddObject(poi);
                    }
                    catch (Exception e)
                    {
                        Logger.LogError("Unsupported POI type '{0}'. Please consider adding this type to poi types configuration file.\n{2}", lastPoiType, e.Message);
                    }
                }

                ctx.SaveChanges();
            }
            File.Delete(poiXml);
        }