使用ProjNet.Silverlight可以将ArcGis中的从标由大地座标转换为经纬座标,代码如下
public List<MapPoint> ConvertTo(List<MapPoint> mps) { CoordinatetransformationFactory ctfac = new CoordinatetransformationFactory(); Point p = new Point(108.94,34.28); string bj1954Lcc = "PROJCS[\"China_LAmbert_Conformal_Conic\",GEOGCS[\"GCS_Beijing_1954\",DATUM[\"D_Beijing_1954\",SPHEROID[\"Krasovsky_1940\",6378245.0,298.3]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"LAmbert_Conformal_Conic\"],ParaMETER[\"False_Easting\",ParaMETER[\"False_northing\",ParaMETER[\"Central_MerIDian\",105.0],ParaMETER[\"Standard_Parallel_1\",30.0],ParaMETER[\"Standard_Parallel_2\",62.0],ParaMETER[\"Latitude_Of_Origin\",UNIT[\"Meter\",1.0]]"; IProjectedCoordinateSystem fromCS = CoordinateSystemWktReader.Parse(bj1954Lcc) as IProjectedCoordinateSystem; GeographicCoordinateSystem toCS = (GeographicCoordinateSystem)fromCS.GeographicCoordinateSystem; List<MapPoint> List = new List<MapPoint>(); foreach (var mp in mps) { var p1 = new Point(mp.X,mp.Y); var p2 = ctfac.CreateFromCoordinateSystems(fromCS,toCS).Mathtransform.transform(p1); List.Add(new MapPoint(p2.X,p2.Y)); } return List; }
下载ProjNet.Silverlight后在Silverlight中使用是会出一个'p' is not recognized.的错误,找了半天没有解决,最后反编译代码然后跟踪发现原来有一个字符处理时使用的是EnCoding是Unicode,在中文的C#中字符串的默认编码是UTF-8,将代码中的Unicode改为UTF-8即可!
需要改的代码在:ProjNet.Converters.WellKNownText.IO.StreamTokenizer类中的
private TokenType NextTokenAny()中!
总结以上是内存溢出为你收集整理的使用ProjNet.Silverlight进行ArcGis座标转换(有解决出错问题方法)全部内容,希望文章能够帮你解决使用ProjNet.Silverlight进行ArcGis座标转换(有解决出错问题方法)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)