Пример #1
0
        public ConfigCsvFileViewModel(FeatureLayer featureLayer)
            : base()
        {
            this.featureLayer = featureLayer;

            shapeTypes = new Collection <GeneralShapeFileType>();
            shapeTypes.Add(GeneralShapeFileType.Point);
            shapeTypes.Add(GeneralShapeFileType.Line);
            shapeTypes.Add(GeneralShapeFileType.Area);
            allCsvColumns = new ObservableCollection <AddNewCsvColumnViewModel>();
            allCsvColumns.CollectionChanged += new NotifyCollectionChangedEventHandler(AllCsvColumns_CollectionChanged);
            CsvFeatureLayer delimitedFeatureLayer = this.featureLayer as CsvFeatureLayer;

            if (delimitedFeatureLayer != null)
            {
                LoadFromLayer(delimitedFeatureLayer);
            }
            else
            {
                IsShapeTypeEnabled = true;
                IsLayerNameEnabled = true;
                IsDelimiterEnabled = true;
                IsOutputEnabled    = true;
                SelectedShapeType  = GeneralShapeFileType.Point;
                SelectedDelimiter  = new KeyValuePair <string, string>("Comma", ",");
                outputFolder       = ConfigShapeFileViewModel.GetDefaultOutputPath();
            }
        }
Пример #2
0
 public ConfigLayerStructureViewModel(FeatureLayer featureLayer)
     : base()
 {
     shpFileType          = GeneralShapeFileType.Area;
     columnListItemSource = new ObservableCollection <FeatureSourceColumnItem>();
     FeatureLayer         = featureLayer;
     LayerPlugin          = new ShapeFileFeatureLayerPlugin();
     isAliasEnabled       = true;
     layerUri             = new Uri(ConfigShapeFileViewModel.GetDefaultOutputPath());
 }
Пример #3
0
        public ConfigShapeFileUserControl(ShapeFileFeatureLayer shapeFileFeatureLayer)
        {
            InitializeComponent();

            if (EditorUIPlugin.IsRelateAndAliasEnabled)
            {
                GridView.Columns.Insert(1, (GridViewColumn)Resources["AliasColumn"]);
            }

            createNewShapeFileViewModel = new ConfigShapeFileViewModel(shapeFileFeatureLayer);
            DataContext = createNewShapeFileViewModel;

            tempIdColumnNames = new Dictionary <string, string>();
            if (!string.IsNullOrEmpty(FolderHelper.LastSelectedFolder) && createNewShapeFileViewModel.ShpFileFeatureLayer == null)
            {
                createNewShapeFileViewModel.FolderPath = FolderHelper.LastSelectedFolder;
            }
        }
Пример #4
0
        protected override ConfigureFeatureLayerParameters GetFeatureLayerInfoCore()
        {
            ConfigShapeFileViewModel        viewModel  = DataContext as ConfigShapeFileViewModel;
            ConfigureFeatureLayerParameters parameters = new ConfigureFeatureLayerParameters();

            Collection <FeatureSourceColumn> originalColumns = new Collection <FeatureSourceColumn>();

            if (createNewShapeFileViewModel.ShpFileFeatureLayer != null)
            {
                createNewShapeFileViewModel.ShpFileFeatureLayer.SafeProcess(() =>
                {
                    originalColumns = createNewShapeFileViewModel.ShpFileFeatureLayer.FeatureSource.GetColumns();
                });
            }

            IEnumerable <DbfColumn>           addedColumns       = viewModel.ColumnListItemSource.Where(c => isSorted || c.ChangedStatus == FeatureSourceColumnChangedStatus.Added).Select(l => l.DbfColumn);
            IEnumerable <DbfColumnItem>       updatedColumnItems = viewModel.ColumnListItemSource.Where(c => c.ChangedStatus == FeatureSourceColumnChangedStatus.Updated);
            IEnumerable <FeatureSourceColumn> deletedColumns     = originalColumns.Where(o => isSorted || (viewModel.ColumnListItemSource.All(c => c.ColumnName != o.ColumnName) && updatedColumnItems.All(u => u.OrignalColumnName != o.ColumnName)));

            foreach (var item in deletedColumns)
            {
                parameters.DeletedColumns.Add(item);
            }

            foreach (var item in updatedColumnItems)
            {
                parameters.UpdatedColumns[item.OrignalColumnName] = item.DbfColumn;
            }

            if (viewModel.TruncatedColumns.Count > 0)
            {
                viewModel.ShpFileFeatureLayer.SafeProcess(() =>
                {
                    foreach (var feature in viewModel.ShpFileFeatureLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns))
                    {
                        foreach (var truncatedColumn in viewModel.TruncatedColumns)
                        {
                            string tempValue = feature.ColumnValues[truncatedColumn.Key];
                            if (tempValue.Length > truncatedColumn.Value)
                            {
                                feature.ColumnValues[truncatedColumn.Key] = tempValue.Substring(0, truncatedColumn.Value);
                            }
                        }
                        parameters.UpdatedFeatures[feature.Id] = feature;
                    }
                });
            }

            foreach (var item in addedColumns)
            {
                item.MaxLength = item.MaxLength;
                parameters.AddedColumns.Add(item);
            }

            foreach (var item in viewModel.ColumnListItemSource)
            {
                if (item.AliasName != item.ColumnName)
                {
                    parameters.CustomData[item.ColumnName] = item.AliasName;
                }
            }

            string pathFileName = string.Format(@"{0}\{1}.shp", viewModel.FolderPath, viewModel.LayerName);

            parameters.LayerUri = new Uri(Path.GetFullPath(pathFileName));
            switch (viewModel.ShpFileType)
            {
            case GeneralShapeFileType.Point:
                parameters.WellKnownType = WellKnownType.Point;
                break;

            case GeneralShapeFileType.Multipoint:
                parameters.WellKnownType = WellKnownType.Multipoint;
                break;

            case GeneralShapeFileType.Line:
                parameters.WellKnownType = WellKnownType.Line;
                break;

            case GeneralShapeFileType.Area:
                parameters.WellKnownType = WellKnownType.Polygon;
                break;

            default:
                parameters.WellKnownType = WellKnownType.Invalid;
                break;
            }

            return(parameters);
        }
Пример #5
0
 public ConfigTinyGeoFileUserControl(FeatureLayer featureLayer)
 {
     InitializeComponent();
     lbxFeatureLayers.ItemsSource = GisEditor.ActiveMap.GetFeatureLayers();
     txtOutput.Text = ConfigShapeFileViewModel.GetDefaultOutputPath();
 }