Пример #1
0
        public void polygonPartition(Layer fromLayer, Layer toLayer, Layer buildingLayer)
        {
            Feature     aFeature = null;
            FeatureDefn oDefn    = toLayer.GetLayerDefn();

            while ((aFeature = fromLayer.GetNextFeature()) != null)
            {
                Geometry receiveExtent = fromLayer.GetFeature(0).GetGeometryRef();

                //read current feature
                Queue <Geometry> LineSource = bean.staticPartition(10, receiveExtent, 4);

                Feature          bFeature  = null;
                Queue <Geometry> buildings = new Queue <Geometry>();
                while ((bFeature = buildingLayer.GetNextFeature()) != null)
                {
                    if (bFeature.GetGeometryRef().Intersects(receiveExtent))
                    {
                        buildings.Enqueue(bFeature.GetGeometryRef());
                    }
                }

                Random   ran   = new Random();
                Geometry point = null;
                while (LineSource.Count != 0)
                {
                    point = LineSource.Dequeue();
                    foreach (Geometry building in buildings)
                    {
                        if (building.Intersects(point))
                        {
                            point = null;
                            break;
                        }
                    }
                    if (point != null)
                    {
                        Feature feature = new Feature(oDefn);
                        // feature.SetGeometry(point.Buffer(500,30));
                        feature.SetGeometry(point);
                        feature.SetField(0, 4);
                        feature.SetField(1, ran.Next(40, 120));
                        toLayer.CreateFeature(feature);
                    }
                }
            }
        }
Пример #2
0
        public void mapCompute()
        {
            //声源离散
            Layer      sourceLayer = getSource();
            PathSearch pathbean    = new PathSearch();
            //接收点离散
            Queue <Geometry> receiveList = PolygonPartition.staticPartition(m_gridSize, m_computationalGrid, m_receiveHeight);


            //障碍物优化
            DataSource barrierSource = Ogr.Open(m_barrierPath, 0);
            Layer      barrierLayer  = barrierSource.GetLayerByIndex(0);

            Geometry receivePoint  = null;
            Geometry sourcePoint   = null;
            Feature  sourceFeature = null;

            Geometry[]     pathList       = null;
            List <float[]> sourceLineList = new List <float[]>();

            //路径计算,循环接收点
            while (receiveList.Count > 0)
            {
                //声源点和接收点
                receivePoint = receiveList.Dequeue();
                sourceLayer.SetSpatialFilter(receivePoint.Buffer(m_range, 30));
                //循环声源点
                while ((sourceFeature = sourceLayer.GetNextFeature()) != null)
                {
                    sourcePoint = sourceFeature.GetGeometryRef();
                    //获取路径
                    pathList = pathbean.getPath(barrierLayer, sourcePoint, receivePoint, m_range);
                }
            }


            //衰减计算
        }