zoukankan
html css js c++ java
C#根据经纬度请求返回坐标实际地址
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; using System.Net; using System.IO; using System.Configuration; using System.Xml; namespace WSGPSGateway.BLL { public class LocationAPI { public static string GetAddressByLatLng(string Lat, string Lng) { string CellUrl = "http://*******/CellAPI.aspx?Lat={0}&Lng={1}&Type=99"; string url = string.Format(CellUrl, Lat.ToString(), Lng.ToString()); string htm = GetPage(url); return htm; } public static string GetPage(string url) { if (url == "") return ""; WebResponse response = null; Stream stream = null; StreamReader reader = null; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.UserAgent = @"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.40607; .NET CLR 1.1.4322)"; request.Timeout = 5000; response = request.GetResponse(); stream = response.GetResponseStream(); if (Get_Chartset(response.Headers["Content-Type"].ToString()).ToLower() == "gbk") { reader = new StreamReader(stream, System.Text.Encoding.GetEncoding("GB2312")); } else if (Get_Chartset(response.Headers["Content-Type"].ToString()).ToLower() == "utf-8") { reader = new StreamReader(stream, System.Text.Encoding.UTF8); } else { reader = new StreamReader(stream, System.Text.Encoding.UTF8); } string buffer = reader.ReadToEnd(); return buffer; } catch (Exception ex) { DAL.Log.Write("google抓取数据失败异常! \0 错误记录:" + ex + "\r\n"); return ""; } finally { if (reader != null) reader.Close(); if (stream != null) stream.Close(); if (response != null) response.Close(); } } public static string Get_Chartset(string s) { if (s.ToLower() == "text/html") { return "gbk"; } else { int l = s.IndexOf("charset=") + 8; return s.Substring(l, s.Length - l); } } public string GetLatLng(string CID, string LAC) { string Url = "http://********/CellAPI.aspx?cid={0}&lac={1}"; Url = String.Format(Url, CID, LAC); string LatLng = ""; try { LatLng = BLL.LocationAPI.GetPage(Url); } catch (Exception ex) { DAL.Log.Write("获取基站地址发生错误! \0 错误记录:" + ex + "\r\n"); DAL.Log.Write("-----------------------------------------------------------\r\n"); } return LatLng; } } }
查看全文
相关阅读:
Python之Sklearn使用教程
Centos 查看路径下所有文件中是否包含指定字符
Centos7x 开启6379端口,Centos7x开启端口
分享几个ip定位api【转】
@Scheduled(cron = "* * * * * *")
QueryRunner的使用
linux redis重置密码、重启
nginx里的sticky的作用
windows环境xampp搭建php电商项目/搭建禅道
hive中解决中文乱码
原文地址:https://www.cnblogs.com/javawebsoa/p/2458198.html
最新文章
代码重构(六):代码重构完整案例
jcseg-1.8.7版本发布
PHP 5.4.17 发布!
Xcode连接git@osc
整合 Ext JS 和第三方类库
gNewSense 3.0 Beta 2 发布
Ember.js 1.0 RC6 发布,JavaScript 框架
Netty 4.0.0.CR6 发布,高性能网络服务框架
Xen4CentOS 帮你移植到 CentOS 6 和 Xen 4
Jackcess 1.2.13 发布,Java 访问 Access 数据库
热门文章
GDSL 1.7 发布,C语言通用数据结构库
深度学习人脸关键点检测方法----综述
Apple数据线的针脚定义
【dlib代码解读】人脸关键点检测器的训练
数学中 arg min是什么意思
随机森林算法学习(RandomForest)
dlib库的68特征原理人脸关键点检测原理
【CART与GBDT】
One Millisecond Face Alignment with an Ensemble of Regression Trees人脸对齐 级联回归树 ERT GBDT
GBDT模型介绍
Copyright © 2011-2022 走看看