ArcGIS Server REST API 中的很多操作都可以用以下方式实现,具体参数的设置请查看其中的详细说明
public List<string> getGeometry(string CZAH, string url)
{
url += "/query";//query url
string postString = "where=CZAH='" + CZAH + "'";//where
//postString += "text=04CH88131210000004";
postString += "&" + "returnGeometry=true";//returnGeometry
postString += "&" + "f=json";//json
string result = getPostData(postString, url);
List<string> list = new List<string>();
var result1 = JsonConvert.DeserializeObject<dynamic>(result);//添加Newtonsoft.Json类库并引用;
var list1 = result1.features as IEnumerable<dynamic>;
dynamic[] jsonfea = list1.ToArray();
for (int i = ; i < jsonfea.Length; i++)
{
list.Add(jsonfea[i].geometry.ToString());
}
return list;
}
/// <summary>
/// 获取post后的返回值
/// </summary>
/// <param name="postString">POST String</param>
/// <param name="url">Post URL</param>
/// <returns></returns>
public string getPostData(string postString, string url)
{
string result = "";
try
{
byte[] postData = Encoding.UTF8.GetBytes(postString);
WebClient webClient = new WebClient();
string method = "POST";
//POST Header
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
//webClient.Headers.Add("Cache-Control", "no-cache");
//同步提交请求,并返回数据
byte[] responseData = webClient.UploadData(url, method, postData);//得到返回字符流
result = Encoding.UTF8.GetString(responseData);//解码
}
catch (Exception)
{
throw;
}
return result;
}