Esempio n. 1
0
 public static void ChangeCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0,
                                           ISpatialReference ispatialReference_0, bool bool_0)
 {
     if (ispatialReference_0 != null)
     {
         bool geoDatasetPrecision            = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);
         IControlPrecision2 controlPrecision = ispatialReference_0 as IControlPrecision2;
         if (controlPrecision.IsHighPrecision != geoDatasetPrecision)
         {
             controlPrecision.IsHighPrecision = geoDatasetPrecision;
             double num;
             double num2;
             double num3;
             double num4;
             ispatialReference_0.GetDomain(out num, out num2, out num3, out num4);
             if (bool_0)
             {
                 ISpatialReferenceResolution spatialReferenceResolution =
                     ispatialReference_0 as ISpatialReferenceResolution;
                 spatialReferenceResolution.ConstructFromHorizon();
                 spatialReferenceResolution.SetDefaultXYResolution();
                 ISpatialReferenceTolerance spatialReferenceTolerance =
                     ispatialReference_0 as ISpatialReferenceTolerance;
                 spatialReferenceTolerance.SetDefaultXYTolerance();
             }
         }
     }
 }
Esempio n. 2
0
        private void method_0(ISpatialReference ispatialReference_0)
        {
            bool geoDatasetPrecision      = false;
            IGeodatabaseRelease release   = this.iworkspace_0 as IGeodatabaseRelease;
            IControlPrecision2  precision = ispatialReference_0 as IControlPrecision2;

            geoDatasetPrecision       = GeodatabaseTools.GetGeoDatasetPrecision(release);
            precision.IsHighPrecision = geoDatasetPrecision;
            ISpatialReferenceResolution resolution = ispatialReference_0 as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (ispatialReference_0 as ISpatialReferenceTolerance).SetDefaultXYTolerance();
        }
Esempio n. 3
0
        private ISpatialReference method_0(bool bool_1)
        {
            new SpatialReferenceEnvironmentClass();
            ISpatialReference   reference = new UnknownCoordinateSystemClass();
            IGeodatabaseRelease release   = this.ifeatureWorkspace_0 as IGeodatabaseRelease;
            IControlPrecision2  precision = reference as IControlPrecision2;

            bool_1 = GeodatabaseTools.GetGeoDatasetPrecision(release);
            precision.IsHighPrecision = bool_1;
            ISpatialReferenceResolution resolution = reference as ISpatialReferenceResolution;

            resolution.ConstructFromHorizon();
            resolution.SetDefaultXYResolution();
            (reference as ISpatialReferenceTolerance).SetDefaultXYTolerance();
            return(reference);
        }
Esempio n. 4
0
        public static ISpatialReference ConstructCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0)
        {
            bool geoDatasetPrecision = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);

            ISpatialReference  spatialReference = new UnknownCoordinateSystem() as ISpatialReference;
            IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2;

            controlPrecision.IsHighPrecision = geoDatasetPrecision;
            ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution;

            spatialReferenceResolution.ConstructFromHorizon();
            spatialReferenceResolution.SetDefaultXYResolution();
            ISpatialReferenceTolerance spatialReferenceTolerance = spatialReference as ISpatialReferenceTolerance;

            spatialReferenceTolerance.SetDefaultXYTolerance();
            return(spatialReference);
        }
Esempio n. 5
0
        protected override async void OnClick()
        {
            try
            {
                Module1.Current.MapFinishedLoading = false;
                int    idxSQ4         = 3;
                string strAnalysisGdb = GeodatabaseTools.GetGeodatabasePath(Module1.Current.Aoi.FilePath, GeodatabaseNames.Analysis);
                await MapTools.UpdateMapAsync(strAnalysisGdb, Constants.FILES_SEASON_PRECIP_CONTRIB[idxSQ4], Module1.Current.DisplayedSeasonalPrecipContribMap,
                                              Constants.LAYER_NAMES_SEASON_PRECIP_CONTRIB[idxSQ4], "SEASONAL PRECIP CONTRIBUTION: SEP, OCT, & NOV", "% Annual Precipitation", true, Constants.FILE_EXPORT_MAPS_SEASONAL_PRECIP_CONTRIB[idxSQ4]);

                Module1.Current.MapFinishedLoading = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to display Seasonal Precipitation Q4 map!!" + e.Message, "BAGIS-PRO");
            }
        }
Esempio n. 6
0
 private static void ChangeCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0,
                                            ISpatialReference ispatialReference_0, bool bool_0)
 {
     if (ispatialReference_0 != null)
     {
         bool geoDatasetPrecision = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);
         IControlPrecision2 ispatialReference0 = ispatialReference_0 as IControlPrecision2;
         if (ispatialReference0.IsHighPrecision != geoDatasetPrecision)
         {
             ispatialReference0.IsHighPrecision = geoDatasetPrecision;
             if (bool_0)
             {
                 ISpatialReferenceResolution spatialReferenceResolution =
                     ispatialReference_0 as ISpatialReferenceResolution;
                 spatialReferenceResolution.ConstructFromHorizon();
                 spatialReferenceResolution.SetDefaultXYResolution();
                 (ispatialReference_0 as ISpatialReferenceTolerance).SetDefaultXYTolerance();
             }
         }
     }
 }
Esempio n. 7
0
        protected async override void OnClick()
        {
            try
            {
                OpenItemDialog selectAoiDialog = new OpenItemDialog()
                {
                    Title           = "Select AOI Folder",
                    InitialLocation = System.IO.Directory.GetCurrentDirectory(),
                    MultiSelect     = false,
                    Filter          = ItemFilters.folders
                };
                bool?boolOk = selectAoiDialog.ShowDialog();
                if (boolOk == true)
                {
                    IEnumerable <Item> selectedItems = selectAoiDialog.Items;
                    foreach (Item selectedItem in selectedItems)    // there will only be one
                    {
                        FolderType fType = await GeodatabaseTools.GetAoiFolderTypeAsync(selectedItem.Path);

                        if (fType != FolderType.AOI)
                        {
                            ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("!!The selected folder does not contain a valid AOI", "BAGIS Pro");
                        }
                        else
                        {
                            // Initialize AOI object
                            BA_Objects.Aoi oAoi = new BA_Objects.Aoi(System.IO.Path.GetFileName(selectedItem.Path), selectedItem.Path);
                            // Store current AOI in Module1
                            Module1.Current.Aoi = oAoi;
                            ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("AOI is set to " + oAoi.Name + "!", "BAGIS PRO");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred while trying to set the AOI!! " + e.Message, "BAGIS PRO");
            }
        }
Esempio n. 8
0
        protected async override void OnClick()
        {
            try
            {
                // Query for the drainage area
                Uri    gdbUri      = new Uri(GeodatabaseTools.GetGeodatabasePath(Module1.Current.Aoi.FilePath, GeodatabaseNames.Aoi, true));
                string strAreaSqKm = await GeodatabaseTools.QueryTableForSingleValueAsync(gdbUri, Constants.FILE_SNOTEL_POURPOINT,
                                                                                          Constants.FIELD_AOI_AREA, new QueryFilter());

                double areaSqKm = -1;
                bool   isDouble = Double.TryParse(strAreaSqKm, out areaSqKm);

                //Query min/max from dem
                IList <double> lstResult = await GeoprocessingTools.GetDemStatsAsync(Module1.Current.Aoi.FilePath, 0.005);

                double elevMinMeters = -1;
                double elevMaxMeters = -1;
                if (lstResult.Count == 2)   // We expect the min and max values in that order
                {
                    elevMinMeters = lstResult[0];
                    elevMaxMeters = lstResult[1];
                }

                //Test querying metadata; Layer metadata methods not currently available in Pro
                //string snowCourseSitesPath = GeodatabaseTools.GetGeodatabasePath(Module1.Current.Aoi.FilePath, GeodatabaseNames.Layers, true) +  Constants.FILE_SNOW_COURSE;
                //Item featureClassItem = ItemFactory.Instance.Create(snowCourseSitesPath);
                //IMetadata fcMetadataItem = featureClassItem as IMetadata;

                // Counting Snotel Sites in AOI boundary
                gdbUri = new Uri(GeodatabaseTools.GetGeodatabasePath(Module1.Current.Aoi.FilePath, GeodatabaseNames.Aoi, false));
                Uri sitesGdbUri   = new Uri(GeodatabaseTools.GetGeodatabasePath(Module1.Current.Aoi.FilePath, GeodatabaseNames.Layers, false));
                int snotelInBasin = await GeodatabaseTools.CountPointsWithinInFeatureAsync(sitesGdbUri, Constants.FILE_SNOTEL,
                                                                                           gdbUri, Constants.FILE_AOI_VECTOR);

                int snotelInBuffer = 0;
                int totalSites     = await GeodatabaseTools.CountFeaturesAsync(sitesGdbUri, Constants.FILE_SNOTEL);

                if (totalSites > 0)
                {
                    snotelInBuffer = totalSites - snotelInBasin;
                }

                // Counting Snow Course Sites in AOI boundary
                int scosInBasin = await GeodatabaseTools.CountPointsWithinInFeatureAsync(sitesGdbUri, Constants.FILE_SNOW_COURSE,
                                                                                         gdbUri, Constants.FILE_AOI_VECTOR);

                int scosInBuffer = 0;
                totalSites = await GeodatabaseTools.CountFeaturesAsync(sitesGdbUri, Constants.FILE_SNOW_COURSE);

                if (totalSites > 0)
                {
                    scosInBuffer = totalSites - scosInBasin;
                }


                // Serialize the title page object
                BA_Objects.ExportTitlePage tPage = new BA_Objects.ExportTitlePage
                {
                    aoi_name                 = Module1.Current.Aoi.Name,
                    comments                 = "This is a test",
                    publisher                = "Lesley Bross",
                    local_path               = Module1.Current.Aoi.FilePath,
                    streamgage_station       = "USGS XXXXXXX",
                    drainage_area_sqkm       = areaSqKm,
                    elevation_min_meters     = elevMinMeters,
                    elevation_max_meters     = elevMaxMeters,
                    snotel_sites_in_basin    = snotelInBasin,
                    snotel_sites_in_buffer   = snotelInBuffer,
                    snotel_sites_buffer_size = "???",
                    scos_sites_in_basin      = scosInBasin,
                    scos_sites_in_buffer     = scosInBuffer,
                    scos_sites_buffer_size   = "???",
                    date_created             = DateTime.Now
                };
                string publishFolder = Module1.Current.Aoi.FilePath + "\\" + Constants.FOLDER_MAP_PACKAGE;
                string myXmlFile     = publishFolder + "\\" + Constants.FILE_TITLE_PAGE_XML;
                System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(tPage.GetType());
                using (System.IO.FileStream fs = System.IO.File.Create(myXmlFile))
                {
                    writer.Serialize(fs, tPage);
                }

                // Process the title page through the xsl template
                string               myStyleSheet = GeneralTools.GetAddInDirectory() + "\\" + Constants.FILE_TITLE_PAGE_XSL;
                XPathDocument        myXPathDoc   = new XPathDocument(myXmlFile);
                XslCompiledTransform myXslTrans   = new XslCompiledTransform();
                myXslTrans.Load(myStyleSheet);
                XmlTextWriter myWriter = new XmlTextWriter(publishFolder + @"\result.html", null);
                myXslTrans.Transform(myXPathDoc, null, myWriter);
                MessageBox.Show("Title page created!!");
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred while trying to parse the XML!! " + e.Message, "BAGIS PRO");
            }
        }
Esempio n. 9
0
 public static string SnapRasterPath(string aoiPath)
 {
     return(GeodatabaseTools.GetGeodatabasePath(aoiPath, GeodatabaseNames.Surfaces, true)
            + Constants.FILE_DEM_FILLED);
 }
Esempio n. 10
0
        protected async override void OnClick()
        {
            ReportType rType = ReportType.Watershed;

            try
            {
                string outputDirectory = Module1.Current.Aoi.FilePath + "\\" + Constants.FOLDER_MAP_PACKAGE;
                if (!System.IO.Directory.Exists(outputDirectory))
                {
                    System.IO.Directory.CreateDirectory(outputDirectory);
                }

                // Delete any old PDF files
                //string[] arrFilesToDelete = Constants.FILES_EXPORT_WATERSHED_PDF.Concat(Constants.FILES_EXPORT_SITE_ANALYSIS_PDF).ToArray();
                foreach (var item in Constants.FILES_EXPORT_WATERSHED_PDF)
                {
                    string strPath = GeneralTools.GetFullPdfFileName(item);
                    if (System.IO.File.Exists(strPath))
                    {
                        try
                        {
                            System.IO.File.Delete(strPath);
                        }
                        catch (Exception)
                        {
                            System.Windows.MessageBoxResult res =
                                MessageBox.Show("Unable to delete file before creating new pdf. Do you want to close the file and try again?",
                                                "BAGIS-PRO", System.Windows.MessageBoxButton.YesNo);
                            if (res == System.Windows.MessageBoxResult.Yes)
                            {
                                return;
                            }
                        }
                    }
                }

                Layout oLayout = await MapTools.GetDefaultLayoutAsync(Constants.MAPS_DEFAULT_LAYOUT_NAME);

                // Load the maps if they aren't in the viewer already
                BA_ReturnCode success      = BA_ReturnCode.Success;
                string        strTestState = Constants.STATES_WATERSHED_MAP_BUTTONS[0];
                //if (rType.Equals(ReportType.SiteAnalysis))
                //{
                //    strTestState = Constants.STATES_SITE_ANALYSIS_MAP_BUTTONS[0];
                //}
                if (!FrameworkApplication.State.Contains(strTestState))
                {
                    success = await MapTools.DisplayMaps(Module1.Current.Aoi.FilePath, oLayout, true);

                    success = await MapTools.DisplayLegendAsync(Constants.MAPS_DEFAULT_MAP_FRAME_NAME, oLayout,
                                                                "ArcGIS Colors", "1.5 Point", true);
                }

                if (success != BA_ReturnCode.Success)
                {
                    MessageBox.Show("Unable to load maps. The map package cannot be exported!!", "BAGIS-PRO");
                    return;
                }

                if (oLayout != null)
                {
                    bool bFoundIt = false;
                    //A layout view may exist but it may not be active
                    //Iterate through each pane in the application and check to see if the layout is already open and if so, activate it
                    foreach (var pane in FrameworkApplication.Panes)
                    {
                        if (!(pane is ILayoutPane layoutPane))  //if not a layout view, continue to the next pane
                        {
                            continue;
                        }
                        if (layoutPane.LayoutView != null &&
                            layoutPane.LayoutView.Layout == oLayout) //if there is a match, activate the view
                        {
                            (layoutPane as Pane).Activate();
                            bFoundIt = true;
                        }
                    }
                    if (!bFoundIt)
                    {
                        ILayoutPane iNewLayoutPane = await FrameworkApplication.Panes.CreateLayoutPaneAsync(oLayout); //GUI thread

                        (iNewLayoutPane as Pane).Activate();
                    }
                }
                success = await MapTools.PublishMapsAsync(rType); // export the maps to pdf

                if (success != BA_ReturnCode.Success)
                {
                    MessageBox.Show("An error occurred while generating the maps!!", "BAGIS-PRO");
                }
                // Only run critical precip for watershed report
                if (rType.Equals(ReportType.Watershed))
                {
                    success = await GeneralTools.GenerateTablesAsync(false);   // export the tables to pdf

                    if (success != BA_ReturnCode.Success)
                    {
                        MessageBox.Show("An error occurred while generating the Excel tables!!", "BAGIS-PRO");
                    }
                    else
                    {
                        // Generate the crtical precip map; It has to follow the tables
                        Uri uriAnalysis = new Uri(GeodatabaseTools.GetGeodatabasePath(Module1.Current.Aoi.FilePath, GeodatabaseNames.Analysis));
                        if (await GeodatabaseTools.FeatureClassExistsAsync(uriAnalysis, Constants.FILE_CRITICAL_PRECIP_ZONE))
                        {
                            success = await MapTools.DisplayCriticalPrecipitationZonesMap(uriAnalysis);

                            string strButtonState = "MapButtonPalette_BtnCriticalPrecipZone_State";
                            if (success.Equals(BA_ReturnCode.Success))
                            {
                                Module1.ActivateState(strButtonState);
                            }
                            int      foundS1      = strButtonState.IndexOf("_State");
                            string   strMapButton = strButtonState.Remove(foundS1);
                            ICommand cmd          = FrameworkApplication.GetPlugInWrapper(strMapButton) as ICommand;
                            Module1.Current.ModuleLogManager.LogDebug(nameof(OnClick),
                                                                      "About to toggle map button " + strMapButton);
                            if ((cmd != null))
                            {
                                do
                                {
                                    await Task.Delay(TimeSpan.FromSeconds(0.4));  // build in delay until the command can execute
                                }while (!cmd.CanExecute(null));
                                cmd.Execute(null);
                            }

                            do
                            {
                                await Task.Delay(TimeSpan.FromSeconds(0.4));       // build in delay so maps can load
                            }while (Module1.Current.MapFinishedLoading == false);
                            success = await GeneralTools.ExportMapToPdfAsync(150); // export map to pdf

                            if (success == BA_ReturnCode.Success)
                            {
                                // append the map and chart together for posting
                                IList <string> lstToConcat = new List <string>();
                                lstToConcat.Add(GeneralTools.GetFullPdfFileName(Constants.FILE_EXPORT_MAP_CRITICAL_PRECIPITATION_ZONES_PDF));
                                lstToConcat.Add(GeneralTools.GetFullPdfFileName(Constants.FILE_EXPORT_TABLE_PRECIP_REPRESENT_PDF));
                                success = GeneralTools.ConcatenatePagesInPdf(GeneralTools.GetFullPdfFileName(Constants.FILE_EXPORT_CRITICAL_PRECIPITATION_ZONES_PDF),
                                                                             lstToConcat);
                            }
                            else
                            {
                                MessageBox.Show("Unable to generate critical precipitation zones map!!", "BAGIS-PRO");
                            }
                        }
                    }
                }

                success = await GeneralTools.GenerateSitesTableAsync(Module1.Current.Aoi);

                string strPublisher = (string)Module1.Current.BatchToolSettings.Publisher;
                success = await GeneralTools.GenerateMapsTitlePageAsync(rType, strPublisher, "");

                string outputPath = GeneralTools.GetFullPdfFileName(Constants.FILE_EXPORT_WATERSHED_REPORT_PDF);
                //if (rType.Equals(ReportType.SiteAnalysis))
                //{
                //    outputPath = GeneralTools.GetFullPdfFileName(Constants.FILE_EXPORT_SITE_ANALYSIS_REPORT_PDF);
                //}
                GeneralTools.PublishFullPdfDocument(outputPath, rType);    // Put it all together into a single pdf document

                MessageBox.Show("Map package exported to " + outputPath + "!!", "BAGIS-PRO");
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred while trying to export the maps!! " + e.Message, "BAGIS PRO");
            }
        }