当前位置: 首页>>代码示例>>C#>>正文


C# ProjectionInfo.ParseEsriString方法代码示例

本文整理汇总了C#中DotSpatial.Projections.ProjectionInfo.ParseEsriString方法的典型用法代码示例。如果您正苦于以下问题:C# ProjectionInfo.ParseEsriString方法的具体用法?C# ProjectionInfo.ParseEsriString怎么用?C# ProjectionInfo.ParseEsriString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotSpatial.Projections.ProjectionInfo的用法示例。


在下文中一共展示了ProjectionInfo.ParseEsriString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BUT_shptopoly_Click

        private void BUT_shptopoly_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog fd = new OpenFileDialog())
            {
                fd.Filter = "Shape file|*.shp";
                DialogResult result = fd.ShowDialog();
                string file = fd.FileName;

                ProjectionInfo pStart = new ProjectionInfo();
                ProjectionInfo pESRIEnd = KnownCoordinateSystems.Geographic.World.WGS1984;
                bool reproject = false;

                if (File.Exists(file))
                {
                    string prjfile = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar +
                                     Path.GetFileNameWithoutExtension(file) + ".prj";
                    if (File.Exists(prjfile))
                    {
                        using (
                            StreamReader re =
                                File.OpenText(Path.GetDirectoryName(file) + Path.DirectorySeparatorChar +
                                              Path.GetFileNameWithoutExtension(file) + ".prj"))
                        {
                            pStart.ParseEsriString(re.ReadLine());

                            reproject = true;
                        }
                    }

                    IFeatureSet fs = FeatureSet.Open(file);

                    fs.FillAttributes();

                    int rows = fs.NumRows();

                    DataTable dtOriginal = fs.DataTable;
                    for (int row = 0; row < dtOriginal.Rows.Count; row++)
                    {
                        object[] original = dtOriginal.Rows[row].ItemArray;
                    }

                    foreach (DataColumn col in dtOriginal.Columns)
                    {
                        Console.WriteLine(col.ColumnName + " " + col.DataType.ToString());
                    }

                    int a = 1;

                    string path = Path.GetDirectoryName(file);

                    foreach (var feature in fs.Features)
                    {
                        StringBuilder sb = new StringBuilder();

                        sb.Append("#Shap to Poly - Mission Planner\r\n");
                        foreach (var point in feature.Coordinates)
                        {
                            if (reproject)
                            {
                                double[] xyarray = {point.X, point.Y};
                                double[] zarray = {point.Z};

                                Reproject.ReprojectPoints(xyarray, zarray, pStart, pESRIEnd, 0, 1);

                                point.X = xyarray[0];
                                point.Y = xyarray[1];
                                point.Z = zarray[0];
                            }

                            sb.Append(point.Y.ToString(CultureInfo.InvariantCulture) + "\t" +
                                      point.X.ToString(CultureInfo.InvariantCulture) + "\r\n");
                        }

                        log.Info("writting poly to " + path + Path.DirectorySeparatorChar + "poly-" + a + ".poly");
                        File.WriteAllText(path + Path.DirectorySeparatorChar + "poly-" + a + ".poly", sb.ToString());

                        a++;
                    }
                }
            }
        }
开发者ID:ans10528,项目名称:MissionPlanner-MissionPlanner1.3.34,代码行数:81,代码来源:temp.cs

示例2: button24_Click

 private void button24_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog fd = new OpenFileDialog())
     {
         fd.Filter = "Shape 文件|*.shp";
         DialogResult result = fd.ShowDialog();
         string file = fd.FileName;
         ProjectionInfo pStart = new ProjectionInfo();
         ProjectionInfo pESRIEnd = KnownCoordinateSystems.Geographic.World.WGS1984;
         bool reproject = false;
         // Poly Clear
         drawnpolygonsoverlay.Markers.Clear();
         drawnpolygonsoverlay.Polygons.Clear();
         drawnpolygon.Points.Clear();
         if (File.Exists(file))
         {
             string prjfile = Path.GetDirectoryName(file) + Path.DirectorySeparatorChar +
                              Path.GetFileNameWithoutExtension(file) + ".prj";
             if (File.Exists(prjfile))
             {
                 using (
                     StreamReader re =
                         File.OpenText(Path.GetDirectoryName(file) + Path.DirectorySeparatorChar +
                                       Path.GetFileNameWithoutExtension(file) + ".prj"))
                 {
                     pStart.ParseEsriString(re.ReadLine());
                     reproject = true;
                 }
             }
             try
             {
                 IFeatureSet fs = FeatureSet.Open(file);
                 fs.FillAttributes();
                 int rows = fs.NumRows();
                 DataTable dtOriginal = fs.DataTable;
                 for (int row = 0; row < dtOriginal.Rows.Count; row++)
                 {
                     object[] original = dtOriginal.Rows[row].ItemArray;
                 }
                 string path = Path.GetDirectoryName(file);
                 foreach (var feature in fs.Features)
                 {
                     foreach (var point in feature.Coordinates)
                     {
                         if (reproject)
                         {
                             double[] xyarray = { point.X, point.Y };
                             double[] zarray = { point.Z };
                             Reproject.ReprojectPoints(xyarray, zarray, pStart, pESRIEnd, 0, 1);
                             point.X = xyarray[0];
                             point.Y = xyarray[1];
                             point.Z = zarray[0];
                         }
                         drawnpolygon.Points.Add(new PointLatLng(point.Y, point.X));
                         addpolygonmarkergrid(drawnpolygon.Points.Count.ToString(), point.X, point.Y, 0);
                     }
                     // remove loop close
                     if (drawnpolygon.Points.Count > 1 &&
                         drawnpolygon.Points[0] == drawnpolygon.Points[drawnpolygon.Points.Count - 1])
                     {
                         drawnpolygon.Points.RemoveAt(drawnpolygon.Points.Count - 1);
                     }
                     drawnpolygonsoverlay.Polygons.Add(drawnpolygon);
                     gMapControl1.UpdatePolygonLocalPosition(drawnpolygon);
                     gMapControl1.Invalidate();
                     gMapControl1.ZoomAndCenterMarkers(drawnpolygonsoverlay.Id);
                 }
             }
             catch (Exception ex)
             {
                 CustomMessageBox.Show(Strings.ERROR + "\n" + ex, Strings.ERROR);
             }
         }
     }
 }
开发者ID:kkouer,项目名称:PcGcs,代码行数:75,代码来源:GCS.cs


注:本文中的DotSpatial.Projections.ProjectionInfo.ParseEsriString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。