Select to view content in your preferred language

Reprojecting ATOM feeds in SilverLight

738
4
02-03-2011 01:49 PM
adamestrada
Emerging Contributor
All,

As you can see below I have a method that extracts the location information from an ATOM feed. In this case it's all my FourSquare check ins. Anyway, would anyone mind lending a hand on this one? The error I get is that the Point does not fall within a valid range of the geographic coordinate system. I though I was reprojecting it (and the same method worked with my GeoRSS feed) but I still get the error.


    
   private static ESRI.ArcGIS.Client.Projection.WebMercator _mercator =
            new ESRI.ArcGIS.Client.Projection.WebMercator();

#region Parse ATOM feed (Not Done Yet!)
        private void ATOM(Stream s)
        {
                GraphicsLayer graphicsLayer = Map.Layers["GeoRSSFeed"] as GraphicsLayer;
                graphicsLayer.ClearGraphics();

                var document = XDocument.Load(s);
                if (document.Root == null)
                    return;

                var georss = XNamespace.Get("http://www.georss.org/georss");

                var posts = from ev in document.Descendants("channel").Elements("item")

                              let values = ev.Element(georss + "point").Value.Split(' ')
                              select new 
                              {
                                  Latitude = double.Parse(values[0], System.Globalization.CultureInfo.InvariantCulture),
                                  Longitude = double.Parse(values[1], System.Globalization.CultureInfo.InvariantCulture),
                                  Title = (ev.Element("title").Value),
                              }; 
                foreach (var ev in posts)
                {
                    Graphic graphic = new Graphic()
                        {
                            Geometry = _mercator.FromGeographic(new MapPoint(ev.Latitude, ev.Longitude)),
                            Symbol = LayoutRoot.Resources["QuakePictureSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol,
                       
                            //MapPoint point = new MapPoint(ev.Latitude, ev.Longitude,
                            //    new SpatialReference(4326));
                            //graphic.Geometry = ESRI.ArcGIS.Client.Bing.Transform.GeographicToWebMercator(point);

                        };
                    graphicsLayer.Graphics.Add(graphic);
                }   
        }
        #endregion


I know that 4326 is the EPSG code for for WGS84 but I've not had to mess with that in the past hence the reason its commented out.

Thanks in advance,
Adam
0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor
Looks to me like you are switching lat and long:
MapPoint point = new MapPoint(ev.Longitude, ev.Latitude) { SpatialReference = new SpatialReference(4326)) };
0 Kudos
adamestrada
Emerging Contributor
Morten,

<facepalm>Stupid mistake</facepalm>

Adam
0 Kudos
dotMorten_esri
Esri Notable Contributor
I doubt anyone can claim that they have never done this 🙂
0 Kudos
adamestrada
Emerging Contributor
You Europeans say Long/Lat whereas us Americans say Lat/Long. I am reluctant to say that you're correct in how it should be referred to. BTW, your latest XBox rambings are the dogs bollocks! Did I say that correctly?

Adam
0 Kudos