public LbsGeotableBaseResponse <TPoiInfoType> GetPoiInfoByProperties <TPoiInfoType>(IDictionary <string, string> properties) { LbsGeotableBaseResponse <TPoiInfoType> result = null; var uri = new Uri("http://api.map.baidu.com/geosearch/v3/local"); var values = new Dictionary <string, string>(); values.Add("ak", Ak); values.Add("geotable_id", TableId); //max page size values.Add("page_size", "50"); var page_index = 0; var pageIndexStr = "page_index"; values.Add(pageIndexStr, page_index.ToString()); /* * LbsGeotableBaseResponse<TPoiInfoType> poiResponse = null; * uint maxPageNum = 0; * while (true) * { * var res = HttpUtils.GetResponse("GET", uri, values); * var s = res.GetResponseStream(); */ return(result); }
public LbsGeotableBaseResponse <TPoiInfoType> GetAllPoiInfo <TPoiInfoType>() { var uri = new Uri("http://api.map.baidu.com/geosearch/v3/local"); var values = new Dictionary <string, string>(); values.Add("ak", Ak); values.Add("geotable_id", TableId); //max page size values.Add("page_size", "50"); var page_index = 0; var pageIndexStr = "page_index"; values.Add(pageIndexStr, page_index.ToString()); LbsGeotableBaseResponse <TPoiInfoType> poiResponse = null; uint maxPageNum = 0; while (true) { var res = HttpUtils.GetResponse("GET", uri, values); var s = res.GetResponseStream(); var sr = new StreamReader(s); string jsonStr = sr.ReadToEnd(); JavaScriptSerializer jss = new JavaScriptSerializer(); if (page_index == 0) { poiResponse = jss.Deserialize <LbsGeotableBaseResponse <TPoiInfoType> >(jsonStr); if (poiResponse.size == 0) { break; } maxPageNum = poiResponse.total / poiResponse.size; } else { var tmp = jss.Deserialize <LbsGeotableBaseResponse <TPoiInfoType> >(jsonStr); poiResponse.contents = poiResponse.contents.Concat(tmp.contents).ToList(); } if (page_index++ > maxPageNum) { break; } values[pageIndexStr] = page_index.ToString(); } return(poiResponse); }