文章标题

最近做的项目对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;
                } `
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值