文章标题
来源:互联网 发布:c语言打印数字图形 编辑:程序博客网 时间:2024/06/05 11:07
最近做的项目对argis生成的shp文件进行处理,比如把里面的线,点,面,对应的坐标读取来,然后根据百度接口,将点,线,面。加到百度地图上面
进行二次开发。使用c#将shp文件,读出坐标写到文档里面。里面遇到一个问题,就是发现。shp文件里面的线数据竟然是三维的,多一个Z轴,通过supermap desktop 将三维的线变为二维的就行,具体如何变,百度一下,该如何做。`代码已经上传
switch (ShapeType)
{
case 1: //Single Point 点
fs = new FileStream(“C:\Users\Administrator\Desktop\桌面bak\a\test.txt”, FileMode.Create);//将读出坐标放到路径文件,要自己修改
sw = new StreamWriter(fs);
sw.WriteLine(“{0} {1} {2}”,”line”,”linePoint”,”coordinate”);
for (int n = 0; n < RecorderNumber; n++)
{
RecorderNum = br.ReadInt32(); //记录号
Num++;
ContentLength = br.ReadInt32(); //坐标记录长度
RecorderNum = Convert.ToInt32(big2little(RecorderNum));
ContentLength = Convert.ToInt32(big2little(ContentLength)); // ContentLength以字为单位,一字等于2字节,等于16位
int shapetype1 = 0;
double x = 0;
double y = 0;
shapetype1 = br.ReadInt32();
x = br.ReadDouble();
y = br.ReadDouble();
textBox_show.Text += RecorderNum.ToString() + ” ” + ContentLength.ToString() + ” ” + shapetype1.ToString() + ” ” + x.ToString() + ” ” + y.ToString() + ” \r\n”;
Console.WriteLine(“这是第” +n+ “个断点” + “x=” + x+”y=”+y);
sw.WriteLine(“{0} {1} {2},{3}”, n, 1, x, y);
}
sw.Close();
break;
case 3: //Polyline 线
fs = new FileStream("C:\\Users\\Administrator\\Desktop\\桌面bak\\a\\test.txt", FileMode.Create); sw = new StreamWriter(fs); sw.WriteLine("{0} {1} {2}","line","linePoint","coordinate"); Console.WriteLine("一共有" + RecorderNumber + "条线"); for (int n = 0; n < RecorderNumber; n++) { Console.WriteLine("第" + n + "条线"); RecorderNum = br.ReadInt32(); //记录号 Num++; ContentLength = br.ReadInt32(); //坐标记录长度 RecorderNum = Convert.ToInt32(big2little(RecorderNum)); ContentLength = Convert.ToInt32(big2little(ContentLength)); // ContentLength以字为单位,一字等于2字节,等于16位 int shapetype1 = 0; //几何类型 shapetype1 = br.ReadInt32(); double Xmin1 = 0; //边界盒 double Ymin1 = 0; double Xmax1 = 0; double Ymax1 = 0; Xmin1 = br.ReadDouble(); Ymin1 = br.ReadDouble(); Xmax1 = br.ReadDouble(); Ymax1 = br.ReadDouble(); int Numparts; //子线段个数 int Numpoints; //坐标点数 Numparts = br.ReadInt32(); Numpoints = br.ReadInt32(); int[] parts = new int[Numparts]; for (int i = 0; i < Numparts; i++) { parts[i] = br.ReadInt32(); } double[] pointsx = new double[Numpoints]; double[] pointsy = new double[Numpoints]; for (int i = 0; i < Numpoints; i++) { pointsx[i] = br.ReadDouble(); pointsy[i] = br.ReadDouble(); } textBox_show.Text += RecorderNum.ToString() + " " + ContentLength.ToString() + " " + shapetype1.ToString() + " "; //+ x.ToString() + " " + y.ToString() + "***************"; for (int i = 0; i < Numpoints; i++) { Console.WriteLine("这是第"+i+"个断点"+ "x=" + pointsx[i]); textBox_show.Text += "x=" + pointsx[i] + " "; textBox_show.Text += "y=" + pointsy[i] + " "; Console.WriteLine("这是第" + i + "个断点" + "y=" + pointsy[i]); // //获得字节数组 sw.WriteLine("{0} {1} {2},{3}",n,i,pointsx[i],pointsy[i]); // sw.WriteLine(".NET笔记"); // byte[] data = System.Text.Encoding.Default.GetBytes(+pointsx[i] + "," + pointsy[i]); //开始写入 // fs.Write(data, 0, data.Length); // fs.Flush(); //fs.Close(); } textBox_show.Text += " \r\n"; } sw.Close(); break; } `
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- mysql 5.6 的安装
- [运维]VMware vSphere介绍
- leetcode 306. Additive Number
- Codeup_1323_算法2-1:集合union
- 买卖股票的最佳时机
- 文章标题
- pat 1108. Finding Average
- [运维]ESXI系统的安装
- 递归函数
- 基于esp8266的nodemcu模块从白痴到不太白痴
- 暴力求解法中的枚举排列,生成全排列
- 怎样用js实现两个输入框中的数字相加显示在第三个输入框
- 2016-Deep Learning Trends @ICLR
- 流程控制语句