WikiMapiaPlace ParseWikiPlace(XmlNode place)
        {
            string id = place.SelectSingleNode("id").InnerText;

            XmlNode           loc      = place.SelectSingleNode("location");
            WikiMapiaLocation location = new WikiMapiaLocation {
                Lon          = float.Parse(loc.SelectSingleNode("lon").InnerText),
                Lat          = float.Parse(loc.SelectSingleNode("lat").InnerText),
                North        = float.Parse(loc.SelectSingleNode("north").InnerText),
                South        = float.Parse(loc.SelectSingleNode("south").InnerText),
                East         = float.Parse(loc.SelectSingleNode("east").InnerText),
                West         = float.Parse(loc.SelectSingleNode("west").InnerText),
                Country      = loc.SelectSingleNode("country").InnerText,
                State        = loc.SelectSingleNode("state").InnerText,
                Place        = loc.SelectSingleNode("place").InnerText,
                CountryAdmId = int.Parse(loc.SelectSingleNode("country_adm_id").InnerText)
            };

            var title = place.SelectSingleNode("title");

            WikiMapiaPlace p = new WikiMapiaPlace {
                Id       = int.Parse(id),
                Title    = title != null ? title.InnerText : "No Title",
                Location = location,
                Polygon  = new List <Vector2>()
            };

            XmlNode poly = place.SelectSingleNode("polygon");

            foreach (XmlNode child in poly.ChildNodes)
            {
                float x = float.Parse(child.SelectSingleNode("x").InnerText);
                float y = float.Parse(child.SelectSingleNode("y").InnerText);

                p.Polygon.Add(new Vector2(x, y));
            }


            p.Tags = new Dictionary <string, string>();

            var tags = place.SelectSingleNode("tags");

            foreach (XmlNode child in tags.ChildNodes)
            {
                p.Tags.Add(child.SelectSingleNode("id").InnerText, child.SelectSingleNode("title").InnerText);
            }

            return(p);
        }
Beispiel #2
0
        WikiMapiaPlace ParseWikiPlace(XmlNode place)
        {
            string id = place.SelectSingleNode("id").InnerText;

            XmlNode				loc			= place.SelectSingleNode("location");
            WikiMapiaLocation	location	= new WikiMapiaLocation {
                    Lon				= float.Parse(loc.SelectSingleNode("lon").InnerText),
                    Lat				= float.Parse(loc.SelectSingleNode("lat").InnerText),
                    North			= float.Parse(loc.SelectSingleNode("north").InnerText),
                    South			= float.Parse(loc.SelectSingleNode("south").InnerText),
                    East			= float.Parse(loc.SelectSingleNode("east").InnerText),
                    West			= float.Parse(loc.SelectSingleNode("west").InnerText),
                    Country			= loc.SelectSingleNode("country").InnerText,
                    State			= loc.SelectSingleNode("state").InnerText,
                    Place			= loc.SelectSingleNode("place").InnerText,
                    CountryAdmId	= int.Parse(loc.SelectSingleNode("country_adm_id").InnerText)
                };

            var title = place.SelectSingleNode("title");

            WikiMapiaPlace p = new WikiMapiaPlace {
                    Id			= int.Parse(id),
                    Title		= title!=null ? title.InnerText : "No Title",
                    Location	= location,
                    Polygon		= new List<Vector2>()
                };

            XmlNode poly = place.SelectSingleNode("polygon");
            foreach (XmlNode child in poly.ChildNodes) {
                float x = float.Parse(child.SelectSingleNode("x").InnerText);
                float y = float.Parse(child.SelectSingleNode("y").InnerText);

                p.Polygon.Add(new Vector2(x, y));
            }

            p.Tags = new Dictionary<string, string>();

            var tags = place.SelectSingleNode("tags");
            foreach (XmlNode child in tags.ChildNodes) {
                p.Tags.Add(child.SelectSingleNode("id").InnerText, child.SelectSingleNode("title").InnerText);
            }

            return p;
        }