Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
 private void InitializePlugin(BlendTaskPlugin plugin, List <FeatureLayer> featureSources)
 {
     if (OutputMode == OutputMode.ToFile)
     {
         plugin.OutputPathFileName = OutputPathFileName;
     }
     else
     {
         string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp";
         plugin.OutputPathFileName = tempPathFileName;
         OutputPathFileName        = tempPathFileName;
     }
     plugin.FeatureLayers               = featureSources;
     plugin.RenameDictionary            = FeatureSourceColumnDefinition.RenameDictionary;
     plugin.IsIntersect                 = IsIntersect;
     plugin.IsCombine                   = IsCombine;
     plugin.OutputToFile                = OutputToFile;
     plugin.DisplayProjectionParameters = GisEditor.ActiveMap.DisplayProjectionParameters;
     plugin.ColumnsToInclude            = ColumnsToInclude.Select(c => c.ToFeatureSourceColumn()).ToList();
 }