GetSparseSimilarites() public méthode

public GetSparseSimilarites ( PivotTableEntry baseVector, PivotTable vectors, bool logarithm, bool onlyBase ) : PivotTable
baseVector PivotTableEntry
vectors PivotTable
logarithm bool
onlyBase bool
Résultat PivotTable
        private void ButRunSignatureClick(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.cbFocusLayer.Text == null || this.cbFocusLayer.Text == "")
                {
                    MessageBox.Show("You must select a layer");
                    return;
                }
                var layers = this.GetFeatureLayersFromToc(this.GetActiveViewFromArcMap(ArcMap.Application));
                var layerWithSelection = this.GetLayerByName(layers, this.cbFocusLayer.Text);
                if (layerWithSelection == null)
                {
                    MessageBox.Show("Layer does not exist");
                    return;
                }
                this.pbarChangeDet.Minimum = 0;
                this.pbarChangeDet.Maximum = layerWithSelection.FeatureClass.FeatureCount(null);
                this.pbarChangeDet.Value = 0;
                Application.DoEvents();

                var outPut = this.GetSelectedFeatureFromLayerByName(layers, this.cbFocusLayer.Text);
                var cols = new List<string>();
                var outputCols = new Dictionary<string, string>();
                if (outPut.Count == 0)
                {
                    MessageBox.Show("No features in focus layer are selected. Make a selection");
                    return;
                }

                var signature = this.FeaturesToPivotTable(outPut, "GeoHash", null);
                var ignoreCols = new List<string> { "OBJECTID", "SHAPE", "SHAPE_Length", "SHAPE_Area" };

                var analyzer = new PivotTableAnalyzer(this.UpdatePBar, this.SetPBarProperties);
                this.UpdateStatusLabel("Preparing and caching AOI layer");
                Application.DoEvents();

                var aoiPivotTable = this.FeatureLayerToPivotTable(layerWithSelection, "GeoHash", null);

                this.UpdateStatusLabel("Processing Signature");

                Application.DoEvents();

                if (signature.Count > 1)
                {
                    var res =
                        MessageBox.Show(
                            "You have multiple cells selected. Would you like to use an average of the selected features as the signature? If NO is selected, a new layer will be generated for every selected cell. If YES is selected an average will be generated as the signature, one layer will be generated, and typically the resulting similarity distribution may be narrower. Also, diff columns are based on the averages.",
                            "Multiple Selected Cells",
                            MessageBoxButtons.YesNo);
                    if (res == DialogResult.Yes)
                    {
                        var graph = analyzer.GetSimilarityGraph(signature);

                        foreach (var key in graph.Keys)
                        {
                            var formattedGraph = "Graph for rowkey: " + key + "\n";
                            foreach (var innerKey in graph[key].Keys)
                            {
                                var sim = graph[key][innerKey];
                                formattedGraph += "\t" + innerKey + " :: " + sim + "\n";
                            }
                            var box = new ScrollableMessageBox();
                            box.Show(formattedGraph);
                        }
                        var resGraph = MessageBox.Show("Continue?", "Graph", MessageBoxButtons.YesNoCancel);
                        if (resGraph == DialogResult.No || resGraph == DialogResult.Cancel)
                        {
                            this.UpdatePBar(0);
                            this.UpdateStatusLabel("Status");
                            return;
                        }
                        signature = analyzer.GenerateAverageVector(signature);
                    }
                }

                foreach (var entry in signature)
                {
                    var res = analyzer.GetSparseSimilarites(entry, aoiPivotTable, true, false);
                    foreach (var colName in res[0].Data.Keys)
                    {
                        if (!outputCols.ContainsKey(colName))
                        {
                            if (!ignoreCols.Contains(colName))
                            {
                                outputCols.Add(colName, colName);
                            }
                        }
                    }
                    var ws = Jarvis.OpenWorkspace(Settings.Default.geoDatabase);

                    var fcName = "mlt_" + entry.RowKey + "_" + DateTime.Now.Millisecond;
                    var featureClass = Jarvis.CreateStandaloneFeatureClass(ws, fcName, outputCols, false, 0);
                    this.UpdateStatusLabel("Loading Feature Class");
                    Application.DoEvents();

                    this.InsertPivoTableRowsToFeatureClass(featureClass, res, outputCols);
                    this.AddLayerToArcMap(fcName);

                    this.lblPbarStatus.Content = "Done";
                    this.pbarChangeDet.Value = 0;
                    Application.DoEvents();
                }
            }
            catch (Exception ex)
            {
                Jarvis.Logger.Error(ex);
                MessageBox.Show("An unhandled exception occurred");
            }
        }