private void SaveFeaturesToTempFile(string tempFilePath) { var featuresToSimplify = GetFeaturesToSimplify(); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(featuresToSimplify, GetColumns(), tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
private void ExportCore(FileExportInfo info) { try { ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); } catch (Exception ex) { GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); UpdatingTaskProgressEventArgs e = new UpdatingTaskProgressEventArgs(TaskState.Canceled); e.Error = new ExceptionInfo(ex.Message, ex.StackTrace, ex.Source); OnUpdatingProgress(e); } }
private void PrepareTaskParameters(BufferTaskPlugin plugin) { FeatureSource featureSource = null; if (CurrentLayerHasSelectedFeatures && OnlyBufferSelectedFeatures) { ShapeFileExporter shpExporter = new ShapeFileExporter(); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); if (GisEditor.SelectionManager.GetSelectionOverlay() != null) { var features = GisEditor.SelectionManager.GetSelectionOverlay().HighlightFeatureLayer .InternalFeatures.Where(f => f.Tag == SelectedFeatureLayer); FileExportInfo info = new FileExportInfo(features, GetColumns(), tempShpFilePath, projectionInWKT); shpExporter.ExportToFile(info); } featureSource = new ShapeFileFeatureSource(tempShpFilePath); } else { featureSource = SelectedFeatureLayer.FeatureSource; } if (featureSource.IsOpen) { featureSource.Close(); } if (OutputMode == OutputMode.ToFile) { plugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; plugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } plugin.FeatureSource = featureSource; plugin.Distance = Distance; plugin.Smoothness = Smoothness; plugin.Capstyle = CapStyle; plugin.MapUnit = GisEditor.ActiveMap.MapUnit; plugin.DistanceUnit = SelectedDistanceUnit; plugin.DisplayProjectionParameters = GisEditor.ActiveMap.DisplayProjectionParameters; plugin.Dissolve = NeedDissolve; }
private void SaveFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "BlendTemp.shp"); List <Feature> featuresToBlend = null; if (BlendSelectedFeaturesOnly) { featuresToBlend = FilterSelectedFeatures(); } //rename the IDs, becaue features from different layers may have the same ID. //and the exporter can not export features that have the same IDs featuresToBlend = RenameFeatureIds(featuresToBlend); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); var columns = ColumnsToInclude.Select(c => c.ToFeatureSourceColumn()).ToList(); if (IsIntersect) { tempFilesForIntersect = new List <string>(); var featureGroups = featuresToBlend.GroupBy(feature => feature.Tag).ToList(); foreach (var group in featureGroups) { string path = Path.Combine(tempDir, string.Format("BlendTemp{0}.shp", ((Layer)group.Key).Name)); tempFilesForIntersect.Add(path); FileExportInfo info = new FileExportInfo(group, columns, path, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); } } else { FileExportInfo info = new FileExportInfo(featuresToBlend, columns, tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); } }
private void SaveSelectedFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "DissolveTemp.shp"); Collection <Feature> featuresToDissolve = GetFeaturesToDissolve(); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(featuresToDissolve, GetColumnsOfSelectedLayer(), tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
private void SaveSelectedFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "SplitTemp.shp"); var selectedFeatures = HighlightFeatureLayer.InternalFeatures.Where(f => f.Tag == SelectedLayerToSplit); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(selectedFeatures, ColumnsInSelectedLayer, tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
private void SaveClippingLayer() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } clippingLayerTempPath = Path.Combine(tempDir, "ClippingTemp.shp"); Collection <Feature> clippingFeatures = null; var clipLayers = this.ClippingLayers.Where(l => l.IsSelected).Select(l => l.FeatureLayer); if (this.IsUseSelectedFeatures) { Collection <Feature> selectedFeatures = new Collection <Feature>(); var selectionOverlay = GisEditor.SelectionManager.GetSelectionOverlay(); if (selectionOverlay != null) { var selectedFeaturesInThisLayer = selectionOverlay.HighlightFeatureLayer.InternalFeatures.Where(tmpFeature => clipLayers.Contains(tmpFeature.Tag)); foreach (var feature in selectedFeaturesInThisLayer) { selectedFeatures.Add(feature); } } if (selectedFeatures.Count > 0) { clippingFeatures = selectedFeatures; } } //we don't need columns from the clipping layers string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(clippingFeatures, new FeatureSourceColumn[] { new FeatureSourceColumn("None", "String", 10) }, clippingLayerTempPath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
private void SaveSelectedFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "MergeTemp.shp"); var selectionOverlay = GisEditor.SelectionManager.GetSelectionOverlay(); if (selectionOverlay != null) { var selectedFeatures = selectionOverlay.HighlightFeatureLayer.InternalFeatures .Where(tmpFeature => SelectedLayers.Contains((Layer)tmpFeature.Tag)); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(selectedFeatures, GetColumnsOfSelectedLayers(), tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); } }