Something about WktReader?

2 posts, 0 answers
  1. Jimmy
    Jimmy avatar
    24 posts
    Member since:
    Nov 2006

    Posted 05 Sep 2011 Link to this post

    I made a small test about WktReader , found that can not read data from a wcf service!!! 
    but when I copied the demo file from  the example to the project, it can run well! 
    In my test project I did not modify the other file except the file WktDataViewModel.cs
    my WktDataViewModel like this:
    public WktDataViewModel()
        this.WktDataCollection = new Collection<WktDataRow>();
        var coll = new Collection<WktDataRow>();  
        Uri xmlUri = new Uri(string.Concat(Constant.HOST, "/DataService.svc/ProvinceList/2011"));
        LoaderService.DownloadString(xmlUri, result =>
            var jarProvince = JArray.Parse(result);
            for (int i = 0; i < jarProvince.Count; i++)
                var obj = (JObject)jarProvince[i];
                WktDataRow northAreaDataRow = new WktDataRow();
                northAreaDataRow.Name = obj["name"].ToString();
                northAreaDataRow.Geometry = obj["coordinates"].ToString();
        //WktDataCollection = (Collection<WktDataRow>)Newtonsoft.Json.JsonConvert.DeserializeObject(result, typeof(Collection<WktDataRow>));
        this.WktDataCollection = coll;

    and the method DownloadString code is :
    public static void DownloadString(Uri uri, Action<string> callback)
                    WebClient wc = new WebClient();
                    wc.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) =>
                        catch (System.Exception ex) { }
                catch (System.Exception ex) { }

    this is why? is there anything wrong?  
    thank you !!

    Is there any more demos about use 
    Sql GeospatialData?

  2. Bartholomeo Rocca
    Bartholomeo Rocca avatar
    247 posts
    Member since:
    May 2006

    Posted 08 Sep 2011 Link to this post

    Hello Jimmy,

    Not sure what do you mean by WktReader not reading data from wcf service -- based on the provided code it seems you are populating the WktDataCollection manually in response to the service call so the WktReader does not communicate directly with your service. Most probably you are experiencing configuration issue with your Uri -- have you verified that the service returns the expected result in the first place? Other than that, once you have populated the WktDataCollection properly, it should work as expected as it would be using the same approach as the online example here.

    You can check the WktReader documentation here as well.

  3. DevCraft R3 2016 release webinar banner
Back to Top