PSU-CSAR / vb-bagis

Source code for BAGIS V3 ESRI Add-In
0 stars 1 forks source link

BAGIS Basin Analysis - Export maps & diagrams as a pdf #74

Closed jdduh closed 5 years ago

jdduh commented 5 years ago

This tool is for the implementation of the portal for sharing Basin Analysis results.

lbross commented 5 years ago

ArcObjects provides the capability to export each map as a .pdf. Excel provides the capability to print a spreadsheet to .pdf. I am experimenting with the third-party library PdfSharp to concatenate the pages together.

I'm not sure how the sizes of the current Excel charts were selected, but they don't look very good when printed to .pdf. Most of them break in the middle of a chart. It might make sense to resize/reposition these so they fit better on a series of 8.5 x 11 pages.

Attaching sample concatenated .pdf file if you want to upload to the portal. ConcatenatedDocument1_tempfile.pdf

lbross commented 5 years ago

I have been experimenting with publishing a map to AGOL where we can toggle the zones layers like we do in the BAGIS maps interface. I have been using ArcGIS Pro because it has better integration with AGOL. The closest I have gotten to success is a web map called 'Animas_PRMS_3857' in the 'animas' folder. It is shared with our organization. To get this far, I had to use a base map provided by AGOL and reproject the layers to the default web projection (WKID 3857). In order to toggle the visibility of the layers, each layer has to be its own service. The problem with publishing a web map with raster layers is that the publishing process merges them together into a single tiled map service layer so you can only see one and they can't be toggled. If publishing a map service worked, I thought we might be able to create a map with all the layers symbolized and then use either Python or C# to swap the layers in for a different AOI, reset the center of the map, and publish the updated map to AGOL. But if the raster layers can't operate independently, there is no point. Would NWCC be opposed to converting the raster zones layers to vectors before publishing? If this is okay, we might try going down that path. Another possibility is to publish the layers as separate tiled map services and then add them to a map using the ArcGIS Javascript API. I think we would have to host the web app on a server other than AGS Online and I know we're trying to get away from that. However our web app could still be accessed through the Portal that you are building. I know the .pdf solution would be simpler but it seems that we lose much of the functionality that web GIS is supposed to provide. I don't think what we're trying to should be that hard but there don't seem to be any OOTB solutions.

jdduh commented 5 years ago

I agree that serving live maps is more powerful than static pdf images. From Gus' perspective, he needs something that can generate reports easily on a couple hundred AOIs and that these reports are managed (or indexed) in a meaningful way. Standalone pdf files have the benefit of being easily searched in a file system or linked to the features in an ArcGIS layer. We will continue working on a prototype, but NWCC needs a functional tool now.

lbross commented 5 years ago

I just shared the beginnings of a design document on google drive. Please review and provide input where you can. After you review, I will manually generate a prototype document that you can post to ArcGIS for NWCC to review.

lbross commented 5 years ago

I posted a sample animas_AOI_prms map book to the nrcs portal. It has a title page, the main maps, and the excel charts. I didn't include site scenarios since I wasn't sure if that was needed. Let me know what you think. This was created manually as a POC.

jdduh commented 5 years ago

Looks good. I will run it by NWCC and let you know if there is any update.

jdduh commented 5 years ago

I have also put some notes on the last page of the design document.

lbross commented 5 years ago

Attached are some samples of the chart enhancements you asked for:

  1. Allocating one chart per page
  2. Adding the AOI name as the title for each page
  3. Adding a description box for each page

The pdf is a mock-up of what the pdf documents look like. The .xlsx is the source for the pdf and is also what the analyst will see if they interactively click the Tables button from the Maps form. The tables are spaced further apart and also include the description boxes as requested. None of this is coded yet. Just worked up in Excel. sample_charts.pdf TablesWithCaptions.xlsx

lbross commented 5 years ago

Do you have a sense for how this tool will be used? Would it be better to have a separate menu item that allows the user to select an AOI and then to export the maps/charts? Or will they frequently be configuring the intervals from the maps screen immediately before exporting? I want to add it where it will be easiest for them to use it. If they're not configuring the intervals for export, it would be faster to use a second menu item.

jdduh commented 5 years ago

I'm thinking adding the function to the pull-down menu, similar to the Export Map that's available now. The Export Map function can export PDF but doesn't create a combined PDF that includes all maps and Excel diagrams. We can change the Export Map to Create PDF. The Create PDF function provides users the option of "Create PDF from the current map" or "Create PDF of all maps and Excel diagrams."

image

lbross commented 5 years ago

I updated the design document based on your most recent comment and our discussion on Friday. I put the updates in blue and it seems that most of the document is an update :-)

Please review and let me know what you think.

lbross commented 5 years ago

See attached a prototype of the new dockable window that manages the export process. Let me know if you have any changes. ExportPackage

jdduh commented 5 years ago

The dialog window GUI looks good. Per my comments on the Google slide document, remove the select button and add the output pdf name to the "Export Folder," rename "Export Folder" to "Output file."

We need another dialog window for the "Export Map Package" function to summarize the export actions. The contents of the dialog window can be used directly on the title page, to include:

The "customized map settings" status is difficult to tell, but we do know if a map was published with default settings. Maps without an existing pdf or created by overwriting an existing pdf are published with default settings.

lbross commented 5 years ago

Thanks! I would like to add the additional elements to the existing GUI if we can. There is extra space and it would be easier to manage a single window. If you think there is too much going on, maybe move the button to export a single map to a command button in the maps menu?

My thoughts:

I have not dynamically written a Word document before with code, but we will see how that goes. It should be possible.

lbross commented 5 years ago

Please see attached proposed title page. Do we want to add a list of the attached maps and charts, like a table of contents? Do you want to keep the advertising for BAGIS at the bottom of the page? Any other suggestions? title_page.docx

jdduh commented 5 years ago

The title page looks good. Keep the BAGIS message at the end. Would writing to html format be easier? If so, then it might not be too difficult to convert an html to pdf.

lbross commented 5 years ago

I was considering html as well. Will take a look at both options and let you know what I find. Maybe look at Wordpad too?

UPDATED: I plan to go with an xml/xsl/html solution similar to what we do for publishing the site scenario report. Publishing with Word requires adding the Word library an I prefer not to do that.

UPDATED: This was harder than it looked. There isn't an immediate solution to convert html to pdf. I found another third party library derived from PDF Sharp that publishes an html string to .pdf. The difficulty is that it has its own interpretation of html which makes using the style tags tricky. Attached is what I currently have. Hopefully it will work. title_page.pdf

lbross commented 5 years ago

Attached is a current sample of the output. The maps are generated 1 by 1 from the new menu item and the charts are generated as a batch when the map package is created. Still to do is some of the checking when overwriting documents and the batch map .pdf generation process. all_maps_charts.pdf

lbross commented 5 years ago

I added the AOI name to the top of the charts. Capitalized to match the maps. I published a sample pdf to the NRCS portal under the NWCC_NRCS user. I deleted an old one under your user name. url

lbross commented 5 years ago

I have implemented the saving of the .mxd and checking for open files. I believe these are all the enhancements you requested. Let me know when you are ready for a new .addIn file.

jdduh commented 5 years ago

The implementation is excellent! Thanks! Here are a few issues.

  1. Yes/No/Cancel option when overwriting existing individual pdfs. This is before a map package is created. The current Yes/No dialog box won't allow users to exit the step. image

  2. Phantom excel workbook. When a map package is published, an excel workbook (Book1) was created but hidden. It remains hidden until users open another excel workbook. Please either kill the workbook or make it visible (so that users can close it manually) after a map package is published.

lbross commented 5 years ago

I have resolved these issues and published a new add-in to GitHub. Let me know if I should publish it to basins FTP.

jdduh commented 5 years ago

Thanks! I have the captions for the charts and have them for NWCC/Gus review. We can release the final version to ftp after the captions are added to the code.

jdduh commented 5 years ago

I'm closing this issue and will reopen when we have feedback from NWCC.