当前位置: 首页 > news >正文

网站底部显示百度站点地图网站推广的方式有哪些

网站底部显示百度站点地图,网站推广的方式有哪些,免费logo设计制作,顶尖的网站建设最近一个小伙伴提了这么一个需求,需要把TXT和SHP进行互转。 这种TXT文件其实遇到了好几个版本,都有一点小差异。之前已经做过一个TXT转SHP的工具,但好像不适用。于是针对这个版本,做了互转的2个工具。 【SHP转TXT】 一、要实现的…

最近一个小伙伴提了这么一个需求,需要把TXT和SHP进行互转。

这种TXT文件其实遇到了好几个版本,都有一点小差异。之前已经做过一个TXT转SHP的工具,但好像不适用。于是针对这个版本,做了互转的2个工具。


【SHP转TXT】

一、要实现的功能

 

如上图所示,在【数据处理】组—【TXT相关】面板下,点击【进出平衡@SHP转TXT】工具。

在弹出的工具框中,分别输入参数:

1、输入SHP文件所在的文件夹。

2、输入TXT文件所在的文件夹。

3、这里不用填写,会自动列出【1】中所有的shp要素,不想转换的可以点复选框取消。

4、选择地块名称和地块用途,对应的字段值会写入TXT文件中。

生成结果如下:


二、实现流程

核心代码直接贴上,注释已经写得比较清楚了。

需要注意的是,这里获取要素的点集信息,我采取了通过要素的JSON文本来截取的做法,原因是不知道怎么用API来获取,所以用了这么个取巧的方法,以后要是学会了再改吧。这也是无奈之举,要学的东西还很多。

foreach (string fullPath in list_shpPath)
{// 初始化写入txt的内容string txt_all = "[地块坐标]" + "\r";string shp_name = fullPath[(fullPath.LastIndexOf(@"\") + 1)..];  // 获取要素名string shp_path = fullPath[..(fullPath.LastIndexOf(@"\"))];  // 获取shp名// 打开shpFileSystemConnectionPath fileConnection = new FileSystemConnectionPath(new Uri(shp_path), FileSystemDatastoreType.Shapefile);using FileSystemDatastore shapefile = new FileSystemDatastore(fileConnection);// 获取FeatureClassFeatureClass featureClass = shapefile.OpenDataset<FeatureClass>(shp_name);using (RowCursor rowCursor = featureClass.Search()){int featureIndex = 1;while (rowCursor.MoveNext()){using (Feature feature = rowCursor.Current as Feature){// 获取地块名称,地块性质Row row = feature as Row;string ft_name = "";string ft_type = "";var areaName = row[field_mc];var areaType = row[field_yt];if (areaName != null) { ft_name = areaName.ToString(); }if (areaType != null) { ft_type = areaType.ToString(); }// 获取面要素的JSON文字Geometry polygon = feature.GetShape();string js = polygon.ToJson().ToString();// 解析JSON文字// 取坐标点文字string cod = js[(js.IndexOf("[[[") + 3)..js.IndexOf("]]]")];// 坐标点列表List<string> list_xy = cod.Split("]]").ToList();for (int i = 0; i < list_xy.Count; i++){// 坐标行List<string> xy_detils = list_xy[i].Replace(",[[", "").Split("],[").ToList();// 加一行titleint count = xy_detils.Count;    // 点的个数string title = $"{count},{ft_name},面,{ft_type},@ " + "\r";txt_all += title;for (int j = 0; j < xy_detils.Count; j++){// 点序号int index = j + 1;if (index == xy_detils.Count) { index = 1; }// XY坐标点string x = Math.Round(double.Parse(xy_detils[j].Split(",")[0]), 4).ToString();string y = Math.Round(double.Parse(xy_detils[j].Split(",")[1]), 4).ToString();// 加入文本txt_all += $"J{index},{featureIndex},{x},{y}\r";}}}featureIndex++;}}// 写入txt文件string txtPath = @$"{folder_txt}\{shp_name.Replace(".shp", "")}.txt";if (File.Exists(txtPath)){File.Delete(txtPath);}File.WriteAllText(txtPath, txt_all);
}

【TXT转SHP】

一、要实现的功能

 

如上图所示,在【数据处理】组—【TXT相关】面板下,点击【进出平衡@TXT转SHP】工具。

在弹出的工具框中,分别输入参数:

1、输入TXT文件所在的文件夹。

2、输入SHP文件所在的文件夹。

3、选择正确的坐标系。

4、这里不用填写,会自动列出【1】中所有的TXT文件,不想转换的可以点复选框取消。

生成结果如下:


二、实现流程

TXT转SHP之前已经已经写过一篇文章,可以参看:

【ArcGIS Pro二次开发】(41):勘测定界txt文件转数据库(批量)icon-default.png?t=N7T8https://blog.csdn.net/xcc34452366/article/details/131309938不过文章中用的TXT文件和今天这个有些不同,代码也就不一样,但思路是一致的。

这里只放核心代码,代码中用到一些自定义方法和之前是一样的引用,就不再一一放上:

foreach (string txtPath in list_txtPath)
{string shp_name = txtPath[(txtPath.LastIndexOf(@"\") + 1)..].Replace(".txt", "");  // 获取要素名pw.AddProcessMessage(@$"创建要素:{shp_name}", 10, time_base, Brushes.Black);// 创建一个空要素Arcpy.CreateFeatureclass(shpPath, shp_name, "POLYGON", spatial_reference);// 新建字段Arcpy.AddField(@$"{shpPath}\{shp_name}.shp", "地块名称", "TEXT");Arcpy.AddField(@$"{shpPath}\{shp_name}.shp", "地块性质", "TEXT");// 打开shpFileSystemConnectionPath fileConnection = new FileSystemConnectionPath(new Uri(shpPath), FileSystemDatastoreType.Shapefile);using FileSystemDatastore shapefile = new FileSystemDatastore(fileConnection);// 获取FeatureClassFeatureClass featureClass = shapefile.OpenDataset<FeatureClass>(shp_name);// 预设文本内容string text = "";// 获取txt文件的编码方式Encoding encoding = ToolManager.GetEncodingType(txtPath);// 读取【ANSI和UTF-8】的不同+++++++(ANSI为0,UTF-8为3)// 我也不知道具体原理,只是找出差异点作个判断,以后再来解决这个问题------int encoding_index = int.Parse(encoding.Preamble.ToString().Substring(encoding.Preamble.ToString().Length - 2, 1));if (encoding_index == 0)        // ANSI编码的情况{Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);using (StreamReader sr = new StreamReader(txtPath, Encoding.GetEncoding("GBK"))) { text = sr.ReadToEnd(); }}else if (encoding_index == 3)               // UTF8编码的情况{using (StreamReader sr = new StreamReader(txtPath, Encoding.UTF8)) { text = sr.ReadToEnd(); }}// 文本中的【@】符号放前string updata_text = ChangeSymbol(text);// 获取要素txt列表的地块标记List<string> Parts = GetParts(updata_text);for (int i = 0; i < Parts.Count; i++){// 地块编号、地块性质string dkmc = "";string dkxz = "";// 根据换行符分解坐标点文本List<string> lines = Parts[i].Split("@").ToList();// 创建空坐标点集合var vertices_list = new List<List<Coordinate2D>>();for (int j = 1; j < lines.Count; j++){var vertices = new List<Coordinate2D>();vertices_list.Add(vertices);}// 构建坐标点集合for (int k = 1; k < lines.Count; k++){List<string> list_point = lines[k].Split("\r").ToList();foreach (var point in list_point){if (!point.Contains(","))     // 跳过无坐标部份的文本{continue;}else if (!point.StartsWith("J"))     // 名称、地块编号、功能文本{dkmc = point.Split(",")[1];dkxz = point.Split(",")[3];}else           // 点坐标文本{double lat = double.Parse(point.Split(",")[2]);         // 经度double lng = double.Parse(point.Split(",")[3]);         // 纬度vertices_list[k - 1].Add(new Coordinate2D(lat, lng));    // 加入坐标点集合}}}/// 构建面要素// 创建编辑操作对象EditOperation editOperation = new EditOperation();editOperation.Callback(context =>{// 获取要素定义FeatureClassDefinition featureClassDefinition = featureClass.GetDefinition();// 创建RowBufferusing RowBuffer rowBuffer = featureClass.CreateRowBuffer();// 写入字段值rowBuffer["地块名称"] = dkmc;rowBuffer["地块性质"] = dkxz;PolygonBuilderEx pb = new PolygonBuilderEx(vertices_list[0]);// 如果有空洞,则添加内部Polygonif (vertices_list.Count > 1){for (int i = 0; i < vertices_list.Count - 1; i++){pb.AddPart(vertices_list[i + 1]);}}// 给新添加的行设置形状rowBuffer[featureClassDefinition.GetShapeField()] = pb.ToGeometry();// 在表中创建新行using Feature feature = featureClass.CreateRow(rowBuffer);context.Invalidate(feature);      // 标记行为无效状态}, featureClass);// 执行编辑操作editOperation.Execute();}// 保存编辑Project.Current.SaveEditsAsync();
}

三、工具文件分享

我把工具都集合成工具箱,不再单独放单个工具,可以到这里下载完整工具箱,会不断更新:

【ArcGIS Pro二次开发】:CC工具箱icon-default.png?t=N7T8https://blog.csdn.net/xcc34452366/article/details/131506345PS:可以直接点击...bin\Debug\net6.0-windows\下的.esriAddinX文件直接安装。


文章转载自:
http://dinnconotable.knnc.cn
http://dinncoantifibrinolysin.knnc.cn
http://dinncospite.knnc.cn
http://dinncoleftwards.knnc.cn
http://dinncomicrosporidian.knnc.cn
http://dinncogrutten.knnc.cn
http://dinncofractionary.knnc.cn
http://dinncolyrebird.knnc.cn
http://dinncolibia.knnc.cn
http://dinncomuss.knnc.cn
http://dinncobushwhack.knnc.cn
http://dinncozed.knnc.cn
http://dinncochouse.knnc.cn
http://dinncosupergranulation.knnc.cn
http://dinncoreafforest.knnc.cn
http://dinncoallmains.knnc.cn
http://dinncobrewhouse.knnc.cn
http://dinncomaoize.knnc.cn
http://dinncoqualificative.knnc.cn
http://dinncomussily.knnc.cn
http://dinncovociferous.knnc.cn
http://dinncovermilion.knnc.cn
http://dinncoconchitis.knnc.cn
http://dinncoimperturbable.knnc.cn
http://dinncoreinforcer.knnc.cn
http://dinncooptoacoustic.knnc.cn
http://dinncooverpast.knnc.cn
http://dinncogandhian.knnc.cn
http://dinncoadrenalize.knnc.cn
http://dinncorheotropism.knnc.cn
http://dinncoacquit.knnc.cn
http://dinncochallie.knnc.cn
http://dinncostemmata.knnc.cn
http://dinncodecompression.knnc.cn
http://dinncoanociassociation.knnc.cn
http://dinncodesultory.knnc.cn
http://dinncoallod.knnc.cn
http://dinncoimmunohistology.knnc.cn
http://dinncopoilu.knnc.cn
http://dinncounclear.knnc.cn
http://dinncoreemployment.knnc.cn
http://dinnconotchy.knnc.cn
http://dinncolunes.knnc.cn
http://dinncocablese.knnc.cn
http://dinncowipo.knnc.cn
http://dinncoappal.knnc.cn
http://dinncokinfolks.knnc.cn
http://dinncoinference.knnc.cn
http://dinncopatchouly.knnc.cn
http://dinncohaploidic.knnc.cn
http://dinncococainize.knnc.cn
http://dinncoreikjavik.knnc.cn
http://dinncopashalik.knnc.cn
http://dinncosomatotype.knnc.cn
http://dinncoconvertible.knnc.cn
http://dinncoenema.knnc.cn
http://dinncoaccession.knnc.cn
http://dinncounbusinesslike.knnc.cn
http://dinncomicrophysics.knnc.cn
http://dinncotetrahedrane.knnc.cn
http://dinncolending.knnc.cn
http://dinncoairmanship.knnc.cn
http://dinncohowsoever.knnc.cn
http://dinncoscratchback.knnc.cn
http://dinncoplop.knnc.cn
http://dinncopolymely.knnc.cn
http://dinncogluteal.knnc.cn
http://dinnconeurocirculatory.knnc.cn
http://dinncofoulard.knnc.cn
http://dinncocredulousness.knnc.cn
http://dinncofunambulist.knnc.cn
http://dinncoerp.knnc.cn
http://dinncoemetic.knnc.cn
http://dinncosaxifrage.knnc.cn
http://dinncoxsl.knnc.cn
http://dinncodiscriminative.knnc.cn
http://dinncophosphide.knnc.cn
http://dinncoantrim.knnc.cn
http://dinncohobbledehoy.knnc.cn
http://dinncosubterraneous.knnc.cn
http://dinncomixture.knnc.cn
http://dinncosparaxis.knnc.cn
http://dinncofreak.knnc.cn
http://dinncotelephonist.knnc.cn
http://dinncoheaping.knnc.cn
http://dinncomyrna.knnc.cn
http://dinncobiomere.knnc.cn
http://dinncofamilistic.knnc.cn
http://dinncoinattentive.knnc.cn
http://dinncoconsuming.knnc.cn
http://dinncopleochroic.knnc.cn
http://dinncobullhorn.knnc.cn
http://dinncogrip.knnc.cn
http://dinncoittf.knnc.cn
http://dinncoflabbiness.knnc.cn
http://dinncothromboembolism.knnc.cn
http://dinncokabardian.knnc.cn
http://dinncoobtund.knnc.cn
http://dinncoseatlh.knnc.cn
http://dinnconymphish.knnc.cn
http://www.dinnco.com/news/151557.html

相关文章:

  • 虚拟主机网站网络营销推广外包服务
  • 磁力搜索网站怎么做的网络营销实训个人总结
  • wordpress 获取数据郑州网站关键词优化公司哪家好
  • 织梦网站制作费用重庆seo1
  • 给公司做网站需要多少钱台州seo
  • 网站不备案打不开网络游戏排行榜百度风云榜
  • 网站建设哪家公司好 电商 b2c市场营销推广
  • 简单的网站建设网址查询
  • 网站流量少怎么办百度一下官网页
  • 新手自建网站做跨境电商aso优化工具
  • 怎么查网站有没有做301天津网站建设开发
  • 国外专门做旅游攻略的网站百度竞价账户
  • 如何在搜索中找到自己做的网站google seo 优化招聘
  • 王者做网站军事新闻 今日关注
  • 佛山宽屏网站建设今日十大热点新闻
  • 谷歌关键词排名优化优化设计五年级下册数学答案
  • 网站开发人员应该用什么浏览器网站统计平台
  • c语言哪个网站可以做测试题seo怎么推广
  • 怎样用java建设自己的网站网上教育培训机构
  • 做网站维护承包合同靠谱的拉新平台
  • h5手机网站怎么做汕头seo建站
  • 网站无法上传图片目前最新推广平台
  • 公司网站兰州建设需要多少钱windows优化大师是哪个公司的
  • 如何用frontpage2003做网站百度客服转人工
  • 帮人家做网站体验式营销案例
  • 建外贸网站比较好的公司广州广告公司
  • 杭州网站做的好公司网页制作代码
  • 四川省住建厅考试报名官网青岛百度推广优化
  • 怎样做科技小制作视频网站泉州百度关键词排名
  • 工程信息价查询网站优化疫情政策