Beispiel #1
0
        /// <summary>
        /// 将要素转换成Mesh对象
        /// </summary>
        private void FeaturesToMesh()
        {
            //读取shapefile的内容
            string path   = "";
            var    rader  = new NetTopologySuite.IO.ShapeFile.Extended.ShapeDataReader(path);
            var    result = rader.ReadByMBRFilter(rader.ShapefileBounds);
            //读取其中的点信息,转换成mesh对象
            var mesh = new PongGlobe.Core.Mesh <Vector3>();

            mesh.PrimitiveType = PrimitiveType.TriangleStrip;
            //在转换成
            List <Vector3> positions = new List <Vector3>();
            //记录其indices
            List <ushort> indics = new List <ushort>();

            //填充顶点跟索引
            //详细流程,如果是投影坐标,将其转换成wgs84的经纬度坐标,再使用参考系计算出其真实的地理坐标
            foreach (var item in result)
            {
                var geo = item.Geometry.Coordinates;
                //暂未考虑multipolygon的情况,也即是Hole polygon.
                foreach (var coord in geo)
                {
                    //将其转换成弧度制
                    positions.Add(_shape.ToVector3(new Geodetic3D(MathExtension.ToRadius(coord.X), MathExtension.ToRadius(coord.Y))));
                }
            }
            //简化几何,如去除重复点,重置indices等操作
        }
Beispiel #2
0
        /// <summary>
        /// 这里统一使用弧度制作为参数
        /// </summary>
        /// <param name="shpPath"></param>
        /// <param name="scene"></param>
        public VectorLayerRender(string shpPath, Scene.Scene scene)
        {
            var shpReader = new NetTopologySuite.IO.ShapeFile.Extended.ShapeDataReader(shpPath);
            var fea       = shpReader.ReadByMBRFilter(shpReader.ShapefileBounds);

            _features = fea;
            //构建索引
            foreach (var item in _features)
            {
                if (item.Geometry is IPolygon)
                {
                    var env = item.Geometry.EnvelopeInternal;
                    _quadTree.Insert(item.Geometry.EnvelopeInternal, item);
                }
                else if (item.Geometry is IMultiPolygon)
                {
                    foreach (var child in item.Geometry as IMultiPolygon)
                    {
                        _quadTree.Insert(child.EnvelopeInternal, item);
                    }
                }
            }
            _scene = scene;
            //设置其选中的样式
            SelectedStyle.PolygonStyle.FillColor = RgbaFloat.Orange;
        }
Beispiel #3
0
        public PointVectorLayerRender(string shpPath, Scene.Scene scene)
        {
            _scene = scene;
            var shpReader = new NetTopologySuite.IO.ShapeFile.Extended.ShapeDataReader(shpPath);
            var fea       = shpReader.ReadByMBRFilter(shpReader.ShapefileBounds);

            _meshPoints = FeatureTrianglator.PointFeatureToPoints(fea, _scene.Ellipsoid);
            //这里可以强制释放相关资源了
            shpReader.Dispose();
        }