Exemple #1
0
 public DrawCylinderLine(IMultiPolyline multiLine, IPipeSection section, string tcName, uint color)
 {
     this._tcName      = "";
     this._color       = 0xffff0000;
     base._modeltype   = ModelType.CylinderLine;
     this._pipeSection = section;
     base._cullModel   = gviCullFaceMode.gviCullNone;
     this._tcName      = tcName;
     this._color       = color;
     if (multiLine != null)
     {
         IEnvelope     envelope = null;
         IPolyline     polyline = null;
         List <Vector> item     = null;
         IPoint        point    = null;
         Vector        vector   = null;
         envelope    = multiLine.Envelope;
         base._x     = (envelope.MaxX + envelope.MinX) / 2.0;
         base._y     = (envelope.MaxY + envelope.MinY) / 2.0;
         base._z     = (envelope.MaxZ + envelope.MinZ) / 2.0;
         this._route = new List <List <Vector> >();
         for (int i = 0; i < multiLine.GeometryCount; i++)
         {
             polyline = multiLine.GetPolyline(i);
             item     = new List <Vector>();
             for (int j = 0; j < polyline.PointCount; j++)
             {
                 point  = polyline.GetPoint(j);
                 vector = new Vector(point.X - base._x, point.Y - base._y, point.Z - base._z);
                 item.Add(vector);
             }
             this._route.Add(item);
         }
     }
 }
Exemple #2
0
        private void btnBuildRoute_Click(object sender, System.EventArgs e)
        {
            clear();
            this.axRenderControl1.RcMouseClickSelect -= new _IRenderControlEvents_RcMouseClickSelectEventHandler(axRenderControl1_RcMouseClickSelect);

            this.axRenderControl1.InteractMode = gviInteractMode.gviInteractNormal;

            switch (cbOrderPolicy.SelectedIndex)
            {
            case 0:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviSequence;
                break;

            case 1:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFixStart;
                break;

            case 2:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFixStartAndReturn;
                break;

            case 3:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFixStartEnd;
                break;

            case 4:
                routeSolver.LocationOrderPolicy = gviNetworkLocationOrderPolicy.gviFree;
                break;
            }
            if (routeSolver.Solve())
            {
                INetworkRoute route = routeSolver.GetRoute();
                if (route != null)
                {
                    ICurveSymbol lineSym = new CurveSymbol();
                    lineSym.Color = System.Drawing.Color.Yellow;
                    lineSym.Width = -2;
                    IGeometry geo = route.GetRouteGeometry();
                    if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                    {
                        IPolyline line = geo as IPolyline;
                        renderLine = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, lineSym, rootId);
                        renderLine.MaxVisibleDistance = 10000;
                    }
                    else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                    {
                        IMultiPolyline line = geo as IMultiPolyline;
                        multiRenderLine = this.axRenderControl1.ObjectManager.CreateRenderMultiPolyline(line, lineSym, rootId);
                        multiRenderLine.MaxVisibleDistance = 10000;
                    }
                    btnNavigate.Enabled = true;

                    drawTempLine(route);
                }
            }
            else
            {
                MessageBox.Show("查找路径失败");
            }
        }
Exemple #3
0
        private void btnConstructMultiPolyline_Click(object sender, EventArgs e)
        {
            if (gfactory == null)
                gfactory = new GeometryFactory();
            multiPolyline = gfactory.CreateGeometry(gviGeometryType.gviGeometryMultiPolyline, gviVertexAttribute.gviVertexAttributeZ) as IMultiPolyline;
            if (multiPolyline == null)
                return;

            // 添加两条Polyline
            point = gfactory.CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
            polyline = gfactory.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZ) as IPolyline;
            int length = 100;
            for (int i = 0; i < length; i++)
            {
                point.SetCoords(i, 2 * i, 0, 0, i + 1);
                polyline.AppendPoint(point);
            }
            IPolyline polylineClone = polyline.Clone() as IPolyline;
            polylineClone.RemovePoints(50, 50);

            multiPolyline.AddPolyline(polyline);
            multiPolyline.AddPolyline(polylineClone);

            MultiCurve geo = new MultiCurve();
            // Geometry属性
            geo.Dimension = multiPolyline.Dimension;
            if (multiPolyline.Envelope != null)
            {
                geo.MaxX = multiPolyline.Envelope.MaxX;
                geo.MaxY = multiPolyline.Envelope.MaxY;
                geo.MaxZ = multiPolyline.Envelope.MaxZ;
                geo.MinX = multiPolyline.Envelope.MinX;
                geo.MinY = multiPolyline.Envelope.MinY;
                geo.MinZ = multiPolyline.Envelope.MinZ;
            }
            geo.GeometryType = multiPolyline.GeometryType;
            geo.IsEmpty = multiPolyline.IsEmpty;
            geo.IsValid = multiPolyline.IsValid;
            geo.VertexAttribute = multiPolyline.VertexAttribute;
            geo.HasId = multiPolyline.HasId();
            geo.HasM = multiPolyline.HasM();
            geo.HasZ = multiPolyline.HasZ();
            // GeometryCollection属性
            geo.GeometryCount = multiPolyline.GeometryCount;
            geo.IsOverlap = multiPolyline.IsOverlap;
            // MultiCurve属性
            geo.Length = multiPolyline.Length;

            this.propertyGrid1.SelectedObject = geo;
        }
        private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DevExpress.XtraEditors.Controls.EditorButton btn = e.Button;
            switch (btn.Caption)
            {
            case "定位":
                DF3DApplication app = DF3DApplication.Application;
                if (app == null || app.Current3DMapControl == null)
                {
                    return;
                }
                int focusedRowHandle = this.gridView1.FocusedRowHandle;
                if (focusedRowHandle == -1)
                {
                    return;
                }
                DataRow dr = this.gridView1.GetDataRow(focusedRowHandle);
                if (dr["geo"] != null && dr["Name"] != null && dr["fcName"] != null)
                {
                    ISurfaceSymbol ss = new SurfaceSymbolClass();
                    ss.Color = 0xcc00ff00;
                    ICurveSymbol cs = new CurveSymbolClass();
                    cs.Color          = 0xff00ff00;
                    cs.Width          = -5;
                    ss.BoundarySymbol = cs;
                    ISimplePointSymbol ps = new SimplePointSymbol();
                    ps.Size      = SystemInfo.Instance.SymbolSize;
                    ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                    IGeometry objGeo = dr["geo"] as IGeometry;
                    IPoint    pt     = null;
                    if (objGeo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                    {
                        double         x         = 0;
                        double         y         = 0;
                        double         z         = 0;
                        IMultiPolyline mPolyline = objGeo as IMultiPolyline;
                        for (int m = 0; m < mPolyline.GeometryCount; m++)
                        {
                            IPolyline polyline = mPolyline.GetPolyline(m);
                            IPoint    pttemp   = polyline.Midpoint;
                            x += pttemp.X;
                            y += pttemp.Y;
                            z += pttemp.Z;
                        }
                        x    = x / mPolyline.GeometryCount;
                        y    = y / mPolyline.GeometryCount;
                        z    = z / mPolyline.GeometryCount;
                        pt   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        pt.X = x;
                        pt.Y = y;
                        pt.Z = z;
                        IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                        rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                        rMPolyline.Glow(8000);
                        this._listRender.Add(rMPolyline.Guid);
                    }
                    else if (objGeo.GeometryType == gviGeometryType.gviGeometryMultiPolygon)
                    {
                        double        x        = 0;
                        double        y        = 0;
                        double        z        = 0;
                        IMultiPolygon mPolygon = objGeo as IMultiPolygon;
                        for (int m = 0; m < mPolygon.GeometryCount; m++)
                        {
                            IPolygon polygon = mPolygon.GetPolygon(m);
                            IPoint   pttemp  = polygon.Centroid;
                            x += pttemp.X;
                            y += pttemp.Y;
                            z += pttemp.Z;
                        }
                        x    = x / mPolygon.GeometryCount;
                        y    = y / mPolygon.GeometryCount;
                        z    = z / mPolygon.GeometryCount;
                        pt   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                        pt.X = x;
                        pt.Y = y;
                        pt.Z = z;
                        IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID);
                        rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                        rMPolygon.Glow(8000);
                        this._listRender.Add(rMPolygon.Guid);
                    }
                    else if (objGeo.GeometryType == gviGeometryType.gviGeometryPolyline)
                    {
                        IPolyline polyline = objGeo as IPolyline;
                        pt = polyline.Midpoint;
                        IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                        rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                        rPolyline.Glow(8000);
                        this._listRender.Add(rPolyline.Guid);
                    }
                    else if (objGeo.GeometryType == gviGeometryType.gviGeometryPoint)
                    {
                        IPoint point = objGeo as IPoint;
                        pt = point;
                        IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID);
                        rPoint.Glow(8000);
                        this._listRender.Add(rPoint.Guid);
                    }
                    else if (objGeo.GeometryType == gviGeometryType.gviGeometryPolygon)
                    {
                        IPolygon polygon = objGeo as IPolygon;
                        pt = polygon.Centroid;
                        IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID);
                        rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                        rPolygon.Glow(8000);
                        this._listRender.Add(rPolygon.Guid);
                    }
                    else
                    {
                        return;
                    }

                    ITableLabel tl = DrawTool.CreateTableLabel1(1);
                    tl.TitleText = dr["fcName"].ToString();
                    tl.SetRecord(0, 0, dr["Name"].ToString());
                    tl.Position = pt;

                    this._listRender.Add(tl.Guid);

                    app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo);
                }
                break;
            }
        }
Exemple #5
0
        private void GetResultSet(IFeatureClass fc, IQueryFilter filter, DataTable dt)
        {
            if (fc != null)
            {
                IFdeCursor cursor = null;
                try
                {
                    if (filter != null)
                    {
                        filter.PostfixClause = "order by oid asc";
                    }
                    // 查找所有记录
                    cursor = fc.Search(filter, true);
                    if (cursor != null)
                    {
                        dt.BeginLoadData();
                        IRowBuffer fdeRow = null;
                        DataRow    dr     = null;
                        while ((fdeRow = cursor.NextRow()) != null)
                        {
                            dr = dt.NewRow();
                            for (int i = 0; i < dt.Columns.Count; ++i)
                            {
                                string strColName = dt.Columns[i].ColumnName;
                                int    nPos       = fdeRow.FieldIndex(strColName);
                                if (nPos == -1 || fdeRow.IsNull(nPos))
                                {
                                    continue;
                                }
                                object v = fdeRow.GetValue(nPos);  // 从库中读取值
                                dr[i] = v;

                                if (i == 0)
                                {
                                    // 创建管子
                                    int       geoPos = fdeRow.FieldIndex("Geometry");
                                    IGeometry geo    = (IGeometry)fdeRow.GetValue(geoPos);
                                    if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                                    {
                                        IPolyline       pl  = (IPolyline)fdeRow.GetValue(geoPos);
                                        IRenderPipeLine rpl = this.axRenderControl1.ObjectManager.CreateRenderPipeLine(pl, rootId);
                                        rpl.Radius = 10;
                                        rpl.Color  = System.Drawing.Color.Red;
                                        ArrayList rpls = new ArrayList();
                                        rpls.Add(rpl);
                                        pipeMap.Add(v, rpls);
                                    }
                                    else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                                    {
                                        IMultiPolyline multiPolyline = geo as IMultiPolyline;
                                        ArrayList      rpls          = new ArrayList();
                                        for (int g = 0; g < multiPolyline.GeometryCount; g++)
                                        {
                                            IPolyline       plIndex = multiPolyline.GetGeometry(g) as IPolyline;
                                            IRenderPipeLine rpl     = this.axRenderControl1.ObjectManager.CreateRenderPipeLine(plIndex, rootId);
                                            rpl.Radius = 10;
                                            rpl.Color  = System.Drawing.Color.Red;
                                            rpls.Add(rpl);
                                        }
                                        pipeMap.Add(v, rpls);
                                    }
                                }
                            }
                            dt.Rows.Add(dr);
                        }
                        dt.EndLoadData();
                    }
                }
                catch (COMException ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
                finally
                {
                    if (cursor != null)
                    {
                        cursor.Dispose();
                        cursor = null;
                    }
                }
            }
        }
        private void GetData()
        {
            string   whereClause = _dict[_currentClass];
            SubClass sc          = _currentClass;

            if (sc.Parent == null)
            {
                return;
            }
            string[] arrFc3DId = sc.Parent.Fc3D.Split(';');
            if (arrFc3DId == null)
            {
                return;
            }
            foreach (string fc3DId in arrFc3DId)
            {
                DF3DFeatureClass dffc = DF3DFeatureClassManager.Instance.GetFeatureClassByID(fc3DId);
                if (dffc == null)
                {
                    continue;
                }
                FacilityClass facc = dffc.GetFacilityClass();
                IFeatureClass fc   = dffc.GetFeatureClass();
                if (fc == null || facc == null || facc.Name != this._facType)
                {
                    continue;
                }
                List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection;
                if (facFields == null || facFields.Count == 0)
                {
                    return;
                }

                ISpatialFilter filter = new SpatialFilter();
                filter.SpatialRel    = gviSpatialRel.gviSpatialRelIntersects;
                filter.Geometry      = this._geo;
                filter.GeometryField = "FootPrint";
                filter.WhereClause   = whereClause;
                _count = fc.GetCount(filter);
                if (_num > _count || _count == 0)
                {
                    return;
                }

                filter.ResultBeginIndex = _num - 1;
                filter.ResultLimit      = 1;
                IFdeCursor cursor = null;
                IRowBuffer row    = null;
                try
                {
                    cursor = fc.Search(filter, false);
                    if ((row = cursor.NextRow()) != null)
                    {
                        #region 定位
                        int geoindex = row.FieldIndex("Geometry");
                        if (geoindex == -1 || !(row.GetValue(geoindex) is IModelPoint))
                        {
                            continue;
                        }
                        DF3DApplication app = DF3DApplication.Application;
                        if (app != null && app.Current3DMapControl != null)
                        {
                            IModelPoint       geo = row.GetValue(geoindex) as IModelPoint;
                            IModelPointSymbol mps = new ModelPointSymbol();
                            mps.SetResourceDataSet(fc.FeatureDataSet);
                            IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(geo, mps, app.Current3DMapControl.ProjectTree.RootID);
                            //app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump);
                            render.Glow(5000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 5000);

                            ITableLabel tl = DrawTool.CreateTableLabel1(1);
                            tl.TitleText = "属性查询";
                            tl.SetRecord(0, 0, dffc.ToString());
                            IPoint ptTL          = null;
                            int    geoshapeindex = row.FieldIndex("Shape");
                            if (geoshapeindex != -1)
                            {
                                if (!row.IsNull(geoshapeindex))
                                {
                                    IGeometry geoShape = row.GetValue(geoshapeindex) as IGeometry;
                                    if (geoShape.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                                    {
                                        double         x         = 0;
                                        double         y         = 0;
                                        double         z         = 0;
                                        IMultiPolyline mPolyline = geoShape as IMultiPolyline;
                                        for (int m = 0; m < mPolyline.GeometryCount; m++)
                                        {
                                            IPolyline polyline = mPolyline.GetPolyline(m);
                                            IPoint    pttemp   = polyline.Midpoint;
                                            x += pttemp.X;
                                            y += pttemp.Y;
                                            z += pttemp.Z;
                                        }
                                        x      = x / mPolyline.GeometryCount;
                                        y      = y / mPolyline.GeometryCount;
                                        z      = z / mPolyline.GeometryCount;
                                        ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                        ptTL.X = x;
                                        ptTL.Y = y;
                                        ptTL.Z = z;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryMultiPolygon)
                                    {
                                        double        x        = 0;
                                        double        y        = 0;
                                        double        z        = 0;
                                        IMultiPolygon mPolygon = geoShape as IMultiPolygon;
                                        for (int m = 0; m < mPolygon.GeometryCount; m++)
                                        {
                                            IPolygon polygon = mPolygon.GetPolygon(m);
                                            IPoint   pttemp  = polygon.Centroid;
                                            x += pttemp.X;
                                            y += pttemp.Y;
                                            z += pttemp.Z;
                                        }
                                        x      = x / mPolygon.GeometryCount;
                                        y      = y / mPolygon.GeometryCount;
                                        z      = z / mPolygon.GeometryCount;
                                        ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                                        ptTL.X = x;
                                        ptTL.Y = y;
                                        ptTL.Z = z;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryPolyline)
                                    {
                                        ptTL = (geoShape as IPolyline).Midpoint;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryPoint)
                                    {
                                        ptTL = geoShape as IPoint;
                                    }
                                    else if (geoShape.GeometryType == gviGeometryType.gviGeometryPolygon)
                                    {
                                        ptTL = (geoShape as IPolygon).Centroid;
                                    }
                                }
                            }
                            if (ptTL != null)
                            {
                                tl.Position = ptTL;
                            }
                            else
                            {
                                tl.Position = geo;
                            }
                            app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo);
                            app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 5000);
                        }

                        #endregion

                        foreach (DFDataConfig.Class.FieldInfo facField in facFields)
                        {
                            if (!facField.CanQuery)
                            {
                                continue;
                            }
                            int index = row.FieldIndex(facField.Name);
                            if (index != -1 && !row.IsNull(index))
                            {
                                object     obj  = row.GetValue(index);
                                string     str  = "";
                                IFieldInfo fiFC = row.Fields.Get(index);
                                switch (fiFC.FieldType)
                                {
                                case gviFieldType.gviFieldBlob:
                                case gviFieldType.gviFieldUnknown:
                                case gviFieldType.gviFieldGeometry:
                                    continue;

                                case gviFieldType.gviFieldFloat:
                                case gviFieldType.gviFieldDouble:
                                    double d;
                                    if (double.TryParse(obj.ToString(), out d))
                                    {
                                        str = d.ToString("0.00");
                                    }
                                    break;

                                default:
                                    str = obj.ToString();
                                    break;
                                }
                                DataRow dr = this._dtShow.NewRow();
                                dr["Property"] = facField.ToString();
                                dr["Value"]    = str;
                                this._dtShow.Rows.Add(dr);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    if (cursor != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                        cursor = null;
                    }
                    if (row != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                        row = null;
                    }
                }
            }
        }
Exemple #7
0
        private void GetData()
        {
            if (this.cbLayer.SelectedItem == null)
            {
                return;
            }
            DF3DFeatureClass dffc = this.cbLayer.SelectedItem as DF3DFeatureClass;

            if (dffc == null)
            {
                return;
            }
            IFeatureClass fc = dffc.GetFeatureClass();

            if (fc == null)
            {
                return;
            }

            if (_num > _count || _count == 0)
            {
                return;
            }

            ISpatialFilter filter = this._filter;

            filter.ResultBeginIndex = _num - 1;
            filter.ResultLimit      = 1;
            IFdeCursor cursor = null;
            IRowBuffer row    = null;

            try
            {
                cursor = fc.Search(filter, false);
                if ((row = cursor.NextRow()) != null)
                {
                    #region 定位
                    int             geoindex = row.FieldIndex("Geometry");
                    DF3DApplication app      = DF3DApplication.Application;
                    if (geoindex != -1 && !row.IsNull(geoindex) && app != null && app.Current3DMapControl != null)
                    {
                        ISurfaceSymbol ss = new SurfaceSymbolClass();
                        ss.Color = 0xcc00ff00;
                        ICurveSymbol cs = new CurveSymbolClass();
                        cs.Color          = 0xff00ff00;
                        cs.Width          = -5;
                        ss.BoundarySymbol = cs;
                        ISimplePointSymbol ps = new SimplePointSymbol();
                        ps.Size      = SystemInfo.Instance.SymbolSize;
                        ps.FillColor = Convert.ToUInt32(SystemInfo.Instance.FillColor, 16);
                        IGeometry geo  = row.GetValue(geoindex) as IGeometry;
                        IPoint    ptTL = null;
                        if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                        {
                            double         x         = 0;
                            double         y         = 0;
                            double         z         = 0;
                            IMultiPolyline mPolyline = geo as IMultiPolyline;
                            for (int m = 0; m < mPolyline.GeometryCount; m++)
                            {
                                IPolyline polyline = mPolyline.GetPolyline(m);
                                IPoint    pttemp   = polyline.Midpoint;
                                x += pttemp.X;
                                y += pttemp.Y;
                                z += pttemp.Z;
                            }
                            x      = x / mPolyline.GeometryCount;
                            y      = y / mPolyline.GeometryCount;
                            z      = z / mPolyline.GeometryCount;
                            ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            ptTL.X = x;
                            ptTL.Y = y;
                            ptTL.Z = z;
                            IRenderMultiPolyline rMPolyline = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolyline(mPolyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                            rMPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rMPolyline.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rMPolyline.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rMPolyline.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolygon)
                        {
                            double        x        = 0;
                            double        y        = 0;
                            double        z        = 0;
                            IMultiPolygon mPolygon = geo as IMultiPolygon;
                            for (int m = 0; m < mPolygon.GeometryCount; m++)
                            {
                                IPolygon polygon = mPolygon.GetPolygon(m);
                                IPoint   pttemp  = polygon.Centroid;
                                x += pttemp.X;
                                y += pttemp.Y;
                                z += pttemp.Z;
                            }
                            x      = x / mPolygon.GeometryCount;
                            y      = y / mPolygon.GeometryCount;
                            z      = z / mPolygon.GeometryCount;
                            ptTL   = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            ptTL.X = x;
                            ptTL.Y = y;
                            ptTL.Z = z;
                            IRenderMultiPolygon rMPolygon = app.Current3DMapControl.ObjectManager.CreateRenderMultiPolygon(mPolygon, ss, app.Current3DMapControl.ProjectTree.RootID);
                            rMPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rMPolygon.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rMPolygon.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rMPolygon.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                        {
                            IPolyline polyline = geo as IPolyline;
                            ptTL = polyline.Midpoint;
                            IRenderPolyline rPolyline = app.Current3DMapControl.ObjectManager.CreateRenderPolyline(polyline, cs, app.Current3DMapControl.ProjectTree.RootID);
                            rPolyline.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rPolyline.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rPolyline.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rPolyline.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryPoint)
                        {
                            IPoint point = geo as IPoint;
                            ptTL = point;
                            IRenderPoint rPoint = app.Current3DMapControl.ObjectManager.CreateRenderPoint(point, ps, app.Current3DMapControl.ProjectTree.RootID);
                            rPoint.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rPoint.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rPoint.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryPolygon)
                        {
                            IPolygon polygon = geo as IPolygon;
                            ptTL = polygon.Centroid;
                            IRenderPolygon rPolygon = app.Current3DMapControl.ObjectManager.CreateRenderPolygon(polygon, ss, app.Current3DMapControl.ProjectTree.RootID);
                            rPolygon.HeightStyle = gviHeightStyle.gviHeightOnEverything;
                            rPolygon.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(rPolygon.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(rPolygon.Guid, gviActionCode.gviActionJump);
                        }
                        else if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint)
                        {
                            ptTL = (new GeometryFactory()).CreatePoint(gviVertexAttribute.gviVertexAttributeZ);
                            IModelPoint mp = geo as IModelPoint;
                            ptTL.X = mp.X;
                            ptTL.Y = mp.Y;
                            ptTL.Z = mp.Z;
                            IModelPointSymbol mps = new ModelPointSymbol();
                            mps.SetResourceDataSet(fc.FeatureDataSet);
                            IRenderGeometry render = app.Current3DMapControl.ObjectManager.CreateRenderModelPoint(mp, mps, app.Current3DMapControl.ProjectTree.RootID);
                            render.Glow(8000);
                            app.Current3DMapControl.ObjectManager.DelayDelete(render.Guid, 8000);
                            app.Current3DMapControl.Camera.FlyToObject(render.Guid, gviActionCode.gviActionJump);
                        }
                        if (ptTL != null)
                        {
                            ITableLabel tl = DrawTool.CreateTableLabel1(1);
                            tl.TitleText = "属性查询";
                            tl.SetRecord(0, 0, dffc.ToString());
                            if (ptTL != null)
                            {
                                tl.Position = ptTL;
                            }
                            app.Current3DMapControl.Camera.FlyToObject(tl.Guid, gviActionCode.gviActionFlyTo);
                            app.Current3DMapControl.ObjectManager.DelayDelete(tl.Guid, 8000);
                        }
                    }
                    #endregion
                    FacilityClass facc = dffc.GetFacilityClass();
                    if (facc == null)
                    {
                        IFieldInfoCollection fiCol = fc.GetFields();
                        for (int i = 0; i < fiCol.Count; i++)
                        {
                            IFieldInfo fi  = fiCol.Get(i);
                            object     obj = row.GetValue(i);
                            string     str = "";
                            switch (fi.FieldType)
                            {
                            case gviFieldType.gviFieldBlob:
                            case gviFieldType.gviFieldUnknown:
                            case gviFieldType.gviFieldGeometry:
                                continue;

                            case gviFieldType.gviFieldFloat:
                            case gviFieldType.gviFieldDouble:
                                double d;
                                if (double.TryParse(obj.ToString(), out d))
                                {
                                    str = d.ToString("0.00");
                                }
                                break;

                            default:
                                str = obj.ToString();
                                break;
                            }
                            DataRow dr = this._dtShow.NewRow();
                            dr["Property"] = string.IsNullOrEmpty(fi.Alias) ? fi.Name : fi.Alias;
                            dr["Value"]    = str;
                            this._dtShow.Rows.Add(dr);
                        }
                    }
                    else
                    {
                        List <DFDataConfig.Class.FieldInfo> facFields = facc.FieldInfoCollection;
                        if (facFields != null)
                        {
                            foreach (DFDataConfig.Class.FieldInfo facField in facFields)
                            {
                                if (!facField.CanQuery)
                                {
                                    continue;
                                }
                                int index = row.FieldIndex(facField.Name);
                                if (index != -1 && !row.IsNull(index))
                                {
                                    object     obj  = row.GetValue(index);
                                    string     str  = "";
                                    IFieldInfo fiFC = row.Fields.Get(index);
                                    switch (fiFC.FieldType)
                                    {
                                    case gviFieldType.gviFieldBlob:
                                    case gviFieldType.gviFieldUnknown:
                                    case gviFieldType.gviFieldGeometry:
                                        continue;

                                    case gviFieldType.gviFieldFloat:
                                    case gviFieldType.gviFieldDouble:
                                        double d;
                                        if (double.TryParse(obj.ToString(), out d))
                                        {
                                            str = d.ToString("0.00");
                                        }
                                        break;

                                    default:
                                        str = obj.ToString();
                                        break;
                                    }
                                    DataRow dr = this._dtShow.NewRow();
                                    dr["Property"] = facField.ToString();
                                    dr["Value"]    = str;
                                    this._dtShow.Rows.Add(dr);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (cursor != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
                if (row != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(row);
                    row = null;
                }
            }
        }
Exemple #8
0
        private void btnFindWC_Click(object sender, EventArgs e)
        {
            clear();
            clearDeep();

            IFdeCursor cursor = null;

            try
            {
                if (closestFacilitySolver == null)
                {
                    closestFacilitySolver = network.CreateClosestFacilitySolver();
                    closestFacilitySolver.ImpedanceAttributeName = "Length";
                }
                closestFacilitySolver.LocationSearchTolerance = double.Parse(txtSearchTolerance.Text);
                closestFacilitySolver.ClearFacilityLocations();
                closestFacilitySolver.ClearEventLocations();

                // 添加WC设施点
                foreach (IFeatureClass fc in fcMap_POI.Keys)
                {
                    if (fc.Name.Contains("WC"))
                    {
                        cursor = fc.Search(null, true);
                        IRowBuffer row = null;
                        while ((row = cursor.NextRow()) != null)
                        {
                            try
                            {
                                INetworkLocation facility = new NetworkLocation();
                                int    pos   = row.FieldIndex("Geometry");
                                IPoint point = row.GetValue(pos) as IPoint;
                                facility.Position = point;
                                facility.Name     = fc.Guid.ToString() + "_" + row.GetValue(0).ToString(); //设定名字"fcGUID_oid"
                                closestFacilitySolver.AddFacilityLocation(facility);
                            }
                            catch (COMException ex)
                            {
                            }
                        }
                        break;
                    }
                }
                if (closestFacilitySolver.FacilityLocationCount == 0)
                {
                    MessageBox.Show("添加的厕所数为0,请调整LocationSearchTolerance大小");
                    return;
                }

                // 添加人所在的位置
                INetworkEventLocation location = new NetworkEventLocation();
                this.axRenderControl1.Camera.GetCamera2(out fdepoint, out ang);
                location.Position            = fdepoint;
                location.Name                = "I'mHere";
                location.TargetFacilityCount = int.Parse(txtMaxNum.Text);
                location.SetCutoff("Length", double.Parse(txtCutoff.Text));
                closestFacilitySolver.AddEventLocation(location);
                // 可视化人的位置
                IImagePointSymbol ips = new ImagePointSymbol();
                ips.ImageName = "#(i)";
                ips.Size      = 50;
                renderPoint   = this.axRenderControl1.ObjectManager.CreateRenderPoint(fdepoint, ips, rootId);

                if (closestFacilitySolver.Solve())
                {
                    int routeCount = closestFacilitySolver.RouteCount;
                    if (routeCount == 0)
                    {
                        MessageBox.Show("没有厕所在指定范围内");
                        return;
                    }
                    for (int i = 0; i < routeCount; i++)
                    {
                        INetworkRoute route = closestFacilitySolver.GetRoute(i);
                        if (route != null)
                        {
                            // 可视化线路
                            ICurveSymbol lineSym = new CurveSymbol();
                            lineSym.Color = System.Drawing.Color.Yellow;
                            lineSym.Width = -2;
                            IGeometry geo = route.GetRouteGeometry();
                            if (geo.GeometryType == gviGeometryType.gviGeometryPolyline)
                            {
                                IPolyline line = geo as IPolyline;
                                renderLine = this.axRenderControl1.ObjectManager.CreateRenderPolyline(line, lineSym, rootId);
                                renderLine.MaxVisibleDistance = 10000;
                                renderLineArray.Add(renderLine);
                            }
                            else if (geo.GeometryType == gviGeometryType.gviGeometryMultiPolyline)
                            {
                                IMultiPolyline line = geo as IMultiPolyline;
                                multiRenderLine = this.axRenderControl1.ObjectManager.CreateRenderMultiPolyline(line, lineSym, rootId);
                                multiRenderLine.MaxVisibleDistance = 10000;
                                multiRenderLineArray.Add(multiRenderLine);
                            }

                            drawTempLine(route);

                            // 高亮厕所
                            int segmentCount = route.SegmentCount;
                            for (int j = 0; j < segmentCount; j++)
                            {
                                INetworkLocation endLocation = route.GetSegment(j).EndLocation;
                                string[]         strs        = endLocation.Name.Split('_');
                                foreach (IFeatureClass fc in fcMap_POI.Keys)
                                {
                                    if (fc.Guid.ToString() == strs[0])
                                    {
                                        this.axRenderControl1.FeatureManager.HighlightFeature(fc, int.Parse(strs[1]), System.Drawing.Color.Yellow);
                                        break;
                                    }
                                }

                                //////////////////////测试NetworkElement相关//////////////////////////////////
                                INetworkElementCollection elementCols = route.GetSegment(j).GetNetworkElements();
                                for (int c = 0; c < elementCols.Count; c++)
                                {
                                    INetworkElement element = elementCols.Get(c);
                                    if (element.Type == gviNetworkElementType.gviEdge)
                                    {
                                        INetworkEdge edge  = element as INetworkEdge;
                                        int          subId = edge.SubID;
                                    }
                                    else
                                    {
                                        INetworkJunction       junction = element as INetworkJunction;
                                        INetworkEdgeCollection edgeCol  = junction.IncomingEdges;
                                        for (int ee = 0; ee < edgeCol.Count; ee++)
                                        {
                                            INetworkEdge edge  = edgeCol.Get(ee);
                                            int          subId = edge.SubID;
                                        }
                                    }
                                }
                                //////////////////////////////////////////////////////////////////////////
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("查找失败");
                }
            }
            catch (COMException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                if (cursor != null)
                {
                    //Marshal.ReleaseComObject(cursor);
                    cursor = null;
                }
            }
        }
Exemple #9
0
        private void btnNavigate_Click(object sender, EventArgs e)
        {
            if (tour != null)
            {
                //是否相机跟随
                if (cbCameraFollow.Checked)
                {
                    if (renderModelPoint != null)
                    {
                        this.axRenderControl1.Camera.FlyToObject(renderModelPoint.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                    }
                    else if (skinMesh != null)
                    {
                        this.axRenderControl1.Camera.FlyToObject(skinMesh.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                    }
                }
                tour.Play();
                return;
            }

            tour           = this.axRenderControl1.ObjectManager.CreateDynamicObject(rootId);
            tour.CrsWKT    = dataset_Road.SpatialReference.AsWKT();
            tour.TurnSpeed = 100000;

            if (renderLine != null)
            {
                IPolyline line = renderLine.GetFdeGeometry() as IPolyline;
                for (int i = 0; i < line.PointCount; i++)
                {
                    fdepoint = line.GetPoint(i);
                    if (txtLocationNames.Text.Contains("I'm Here!"))
                    {
                        tour.AddWaypoint2(fdepoint, 30);
                    }
                    else
                    {
                        tour.AddWaypoint2(fdepoint, 100);
                    }
                }
            }
            else if (multiRenderLine != null)
            {
                IMultiPolyline mline = multiRenderLine.GetFdeGeometry() as IMultiPolyline;
                for (int i = 0; i < mline.GeometryCount; i++)
                {
                    IPolyline line = mline.GetPolyline(i);
                    for (int j = 0; j < line.PointCount; j++)
                    {
                        fdepoint = line.GetPoint(j);
                        if (txtLocationNames.Text.Contains("I'm Here!"))
                        {
                            tour.AddWaypoint2(fdepoint, 30);
                        }
                        else
                        {
                            tour.AddWaypoint2(fdepoint, 100);
                        }
                    }
                }
            }
            if (txtLocationNames.Text.Contains("I'm Here!"))
            {
                LoadPeople(tour);
            }
            else
            {
                LoadCar(tour);
            }
            //是否相机跟随
            if (cbCameraFollow.Checked)
            {
                if (renderModelPoint != null)
                {
                    this.axRenderControl1.Camera.FlyToObject(renderModelPoint.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                }
                else if (skinMesh != null)
                {
                    this.axRenderControl1.Camera.FlyToObject(skinMesh.Guid, gviActionCode.gviActionFollowBehindAndAbove);
                }
            }
            tour.Play();
        }