public GeocoderWizardSharedObject()
        {
            progressBarVisibility = Visibility.Visible;
            errorTableVisibility  = Visibility.Collapsed;

            inputFileColumns = new ObservableCollection <string>();
            geocoderColumns  = new ObservableCollection <string>();
            retainedColumns  = new ObservableCollection <string>();

            GeocoderMatchType       = GeocoderType.Default;
            IsColumnNamesInFirstRow = false;
            DelimiterDictionary delimiterDictionary = new DelimiterDictionary();

            Dictionary <string, string> .Enumerator enu = delimiterDictionary.GetEnumerator();
            if (enu.MoveNext())
            {
                SelectedDelimiter = enu.Current;
            }
        }
Exemplo n.º 2
0
        private void LoadFromLayer(CsvFeatureLayer delimitedFeatureLayer)
        {
            bool iswkt = !string.IsNullOrEmpty(delimitedFeatureLayer.WellKnownTextColumnName);
            Collection <CsvColumnType> csvColumnTypes = new Collection <CsvColumnType>();

            csvColumnTypes.Add(CsvColumnType.String);
            if (iswkt)
            {
                csvColumnTypes.Add(CsvColumnType.WKT);
            }
            else
            {
                csvColumnTypes.Add(CsvColumnType.Longitude);
                csvColumnTypes.Add(CsvColumnType.Latitude);
            }


            FileName     = delimitedFeatureLayer.Name;
            OutputFolder = Path.GetDirectoryName(delimitedFeatureLayer.DelimitedPathFilename);

            delimitedFeatureLayer.SafeProcess(() =>
            {
                foreach (FeatureSourceColumn item in delimitedFeatureLayer.QueryTools.GetColumns())
                {
                    AddNewCsvColumnViewModel addNewCsvColumnViewModel = new AddNewCsvColumnViewModel(csvColumnTypes);
                    addNewCsvColumnViewModel.ColumnName = item.ColumnName;
                    if (item.ColumnName == delimitedFeatureLayer.WellKnownTextColumnName)
                    {
                        addNewCsvColumnViewModel.SelectedCsvColumnType = CsvColumnType.WKT;
                    }
                    else if (item.ColumnName == delimitedFeatureLayer.XColumnName)
                    {
                        addNewCsvColumnViewModel.SelectedCsvColumnType = CsvColumnType.Longitude;
                    }
                    else if (item.ColumnName == delimitedFeatureLayer.YColumnName)
                    {
                        addNewCsvColumnViewModel.SelectedCsvColumnType = CsvColumnType.Latitude;
                    }
                    else
                    {
                        addNewCsvColumnViewModel.SelectedCsvColumnType = CsvColumnType.String;
                    }

                    allCsvColumns.Add(addNewCsvColumnViewModel);
                }
            });

            DelimiterDictionary delimiterDictionary = new DelimiterDictionary();

            if (delimiterDictionary.ContainsValue(delimitedFeatureLayer.Delimiter))
            {
                SelectedDelimiter = delimiterDictionary.FirstOrDefault(item => item.Value == delimitedFeatureLayer.Delimiter);
            }
            else
            {
                SelectedDelimiter        = delimiterDictionary.FirstOrDefault(item => item.Key == "Custom");
                Delimiter                = delimitedFeatureLayer.Delimiter;
                IsCustomDelimiterEnabled = false;
            }
            if (!iswkt)
            {
                SelectedShapeType = GeneralShapeFileType.Point;
            }
            else
            {
                delimitedFeatureLayer.SafeProcess(() =>
                {
                    Feature firstFeature = delimitedFeatureLayer.QueryTools.GetFeatureById("1", ReturningColumnsType.NoColumns);
                    if (firstFeature != null)
                    {
                        BaseShape baseShape = firstFeature.GetShape();
                        if (baseShape is AreaBaseShape)
                        {
                            SelectedShapeType = GeneralShapeFileType.Area;
                        }
                        else if (baseShape is LineBaseShape)
                        {
                            SelectedShapeType = GeneralShapeFileType.Line;
                        }
                        else if (baseShape is PointBaseShape)
                        {
                            SelectedShapeType = GeneralShapeFileType.Point;
                        }
                    }
                    else
                    {
                        SelectedShapeType = GeneralShapeFileType.Point;
                    }
                });
            }
        }