zoukankan      html  css  js  c++  java
  • 批量地理位置解析

    public class GisHelper
    {
    /// <summary>
    /// 批量地理位置解析
    /// </summary>
    /// <param name="lonlat"></param>
    /// <returns>index-->loc</returns>
    public static Dictionary<string, string> GetLocation(List<Dictionary<string, string>> lonlat)
    {
    string posTemplate = "1,{0},{1},{2}";
    Dictionary<string, string> lis = new Dictionary<string, string>();

    try
    {
    WebClientEx client = new WebClientEx();
    client.Encoding = Encoding.UTF8;
    List<string> param = new List<string>();
    int index = 0;
    lonlat.ForEach(p =>
    {
    foreach (KeyValuePair<string, string> item in p)
    {
    string[] temp = item.Value.Split(',');
    param.Add(string.Format(posTemplate, item.Key, temp[0], temp[1]));
    index++;
    }
    });
    string url = "http://{0}:{1}/stargis/Openlayers/GetCountrySeatHandler.aspx?requestInfos=";//xxx.xxx.xxx.xxx:10087  //xxx.xxx.xxx.xxx

    string locationinfo = client.OpenRead(string.Format(url, "xxx.xxx.xxx.xxx", 10087) + string.Join(";", param.ToArray()));

    if (locationinfo.Trim().Length > 0)
    {
    string[] temp = locationinfo.Trim().TrimStart('(').TrimEnd(')').Split(';');
    foreach (var s in temp)
    {
    string[] ss = s.Split(',');
    if (ss != null && ss.Length >= 3)
    {
    string sim = ss[1];
    string loc = ss[2];
    lis[sim] = loc;
    }
    }
    }
    }
    catch (Exception ex)
    {
    LogHelper.Error("位置解析失败", ex);
    }

    return lis;
    }

    public static string GetLocation(string lon, string lat)
    {
    string location = string.Empty;
    List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
    Dictionary<string, string> dic = new Dictionary<string, string>();
    dic["0"] = string.Format("{0},{1}", lon, lat);
    list.Add(dic);
    Dictionary<string, string> o = GetLocation(list);
    if (o.ContainsKey("0"))
    return o["0"];
    return location;
    }
    }

  • 相关阅读:
    买不起笔记本,只好自己动手做一个啦!(转)
    Microsoft.Press.Microsoft.Visual.C.Sharp.2005.Step.by.Step.Oct.2005
    将指定网页添加到收藏夹的方法(c#)
    一个任意获得页面控件的方法
    取客户端MAC地址的方法
    关于在活动目录(ACTIVE DIRECTORY)中创建组织单位和用户
    无 Cookie 的 ASP.NET
    吉祥三宝(设计篇)
    C语言第一次实验报告
    C语言第二次实验作业
  • 原文地址:https://www.cnblogs.com/daizhipeng/p/7815556.html
Copyright © 2011-2022 走看看