Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Fmu): Download shapefiles from Admin #499

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

santostiago
Copy link
Contributor

@santostiago santostiago commented Jun 23, 2024

Allows downloading the FMU's shapefiles.

It allows downloading it from the show page, the list page, and to bulk download.
I tested importing the zip into mapbox and everything works as expected.

Note: It requires installing GDAL on the computer.

Pull request checklist

Please check if your PR fulfills the following requirements:

  • Make sure you are requesting to pull a topic/feature/bugfix branch (right side). Don't request your master!
  • Make sure you are making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Check the commit's or even all commits' message styles matches our requested structure.
  • Check your code additions will fail neither code linting checks nor unit test.

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: https://www.pivotaltracker.com/story/show/187271041

What is the new behavior?

Does this introduce a breaking change?

  • Yes
  • No

Other information

@santostiago santostiago self-assigned this Jun 23, 2024
@tsubik
Copy link
Collaborator

tsubik commented Jun 26, 2024

When I was looking for some online shapefile tester, the second google search suggestion was "shapefile must die" haha. I wonder if actually simpler geojson is not enough for our case. Although, I tested and the exported shapefile was correctly imported into mapshaper.org.

@santostiago santostiago marked this pull request as ready for review June 30, 2024 15:10
@@ -19,6 +19,29 @@ def scoped_collection
scope -> { I18n.t("active_admin.all") }, :all, default: true
scope -> { I18n.t("active_admin.free") }, :filter_by_free_aa

batch_action :destroy, false
batch_action :download_shapefiles do |ids|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I tested it and it works great, but my concern is that it only download one page and not all filtered fmus, and that was the goal. Is it possible to download all?

Copy link
Collaborator

@tsubik tsubik Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that feature is not planned for AA, which is weird as I think that very useful (activeadmin/activeadmin#2375), but there are other solutions like https://github.com/activeadmin-plugins/active_admin_scoped_collection_actions (or I did similar thing without any plugin which will be probably better, example here https://github.com/Vizzuality/laws_and_pathways/blob/develop/app/admin/cp_assessments.rb#L27)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the plugin takes either selected items or all filtered records, so that would be the best behavior, giving enormous flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But is it the goal? I can ask Sophie. I thought it was to select the FMUs they'd like to download.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think she said to be able to download for example all FMU's for a country or filtered either way. Now, she will have to click through all pages and download them separately.

end

def self.generate_prj_content
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,' \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Information for the prj file.
It sets up the geographical projection.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, ok.

@santostiago
Copy link
Contributor Author

santostiago commented Jul 13, 2024

When I was looking for some online shapefile tester, the second google search suggestion was "shapefile must die" haha. I wonder if actually simpler geojson is not enough for our case. Although, I tested and the exported shapefile was correctly imported into mapshaper.org.

@tsubik but that was the requirement: to export into ESRI shapefiles.

@santostiago santostiago force-pushed the feat_download-shapefiles branch 2 times, most recently from 6af7858 to ce14ce2 Compare July 13, 2024 13:40
Allows downloading the FMU's shapefiles.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants