This is a migrated thread and some comments may be shown as answers.

Something about WktReader?

1 Answer 73 Views
Map
This is a migrated thread and some comments may be shown as answers.
Jimmy
Top achievements
Rank 1
Jimmy asked on 05 Sep 2011, 09:49 AM
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();
            coll.Add(northAreaDataRow);
    }
 
    //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)
        {
            try
            {
                WebClient wc = new WebClient();
                wc.DownloadStringAsync(uri);
                wc.DownloadStringCompleted += (object sender, DownloadStringCompletedEventArgs e) =>
                {
                    try
                    {
                        callback(e.Result);
                    }
                    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?


1 Answer, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 08 Sep 2011, 09:40 AM
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.


Greetings,
Bart.
Tags
Map
Asked by
Jimmy
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Share this question
or