Exemple #1
0
 protected override void OnClick()
 {
     #region
     try
     {
         CollisionRisk.GetCollisionRisk();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     #endregion
 }
Exemple #2
0
        public static async void GetCollisionRisk()
        {
            await CommonMethod.OpenMap(ConstDefintion.ConstMap_EncounterSafety);

            //计算DDV TDV
            await QueuedTask.Run(() =>
            {
                IList <Layer> listLayers   = MapView.Active.Map.GetLayersAsFlattenedList().ToList();
                FeatureLayer l_ownShip     = listLayers.First(l => l.Name == ConstDefintion.ConstLayer_OwnShipLayerName) as FeatureLayer;
                FeatureLayer l_targetShip  = listLayers.First(l => l.Name == ConstDefintion.ConstLayer_TargetShipLayerName) as FeatureLayer;
                FeatureClass fc_ownShip    = l_ownShip.GetFeatureClass();
                FeatureClass fc_targetShip = l_targetShip.GetFeatureClass();

                Feature f_ownShip;
                Feature f_targetShip;
                //获取本船的Feature
                QueryFilter qf = new QueryFilter()
                {
                    ObjectIDs = new List <long>()
                    {
                        1
                    }
                };
                RowCursor rowCursor1 = fc_ownShip.Search(qf, false);

                rowCursor1.MoveNext();
                Row row1 = rowCursor1.Current;

                f_ownShip = row1 as Feature;


                //遍历目标船的Feature
                using (RowCursor rowCursor = fc_targetShip.Search(null, false))
                {
                    while (rowCursor.MoveNext())
                    {
                        using (Row row = rowCursor.Current)
                        {
                            f_targetShip      = row as Feature;
                            long objectid     = f_targetShip.GetObjectID();
                            CollisionRisk ctd = new CollisionRisk(f_ownShip, f_targetShip);
                            if (ctd.Calculate())
                            {
                                using (Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(GeoDataTool.DefaultProject.DefaultGeodatabasePath))))
                                {
                                    gdb.ApplyEdits(() =>
                                    {
                                        Feature target = row as Feature;
                                        target[ConstDefintion.ConstFieldName_asemi]         = ctd.asemi;
                                        target[ConstDefintion.ConstFieldName_bsemi]         = ctd.bsemi;
                                        target[ConstDefintion.ConstFieldName_aoffset]       = ctd.aoffset;
                                        target[ConstDefintion.ConstFieldName_boffset]       = ctd.boffset;
                                        target[ConstDefintion.ConstFieldName_ddv]           = ctd.DDV;
                                        target[ConstDefintion.ConstFieldName_tdv1]          = ctd.TDV1;
                                        target[ConstDefintion.ConstFieldName_tdv2]          = ctd.TDV2;
                                        target[ConstDefintion.ConstFieldName_dcpa]          = ctd.DCPA;
                                        target[ConstDefintion.ConstFieldName_tcpa]          = ctd.TCPA;
                                        target[ConstDefintion.ConstFieldName_tmin]          = ctd.Tmin;
                                        target[ConstDefintion.ConstFieldName_tcr]           = ctd.TCR;
                                        target[ConstDefintion.ConstFieldName_CollisionRisk] = ctd.collisionRisk;

                                        target.Store();
                                    });
                                }
                            }
                        }
                    }
                }
                CreateAllDomain(fc_targetShip);
                //CreateVoyageMaskAsync(fc_targetShip);
            });
        }