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

Search on Recreation.gov for permits #281

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

Conversation

changlan
Copy link

@changlan changlan commented Jul 7, 2023

Description

I took a stab at #82 and #22 to add support for searching on recreation.gov for permits. Similar to campgrounds, there is a 3-level hierarchy for permits: rec-area -> facility -> permit / trails. So I (ab)use the existing cli commands with the following mapping:

  • rec-area -> rec-area
  • campground -> facility (e.g. Mt Whitney)
  • campsite -> permit / trail (e.g. JM35)

Let me know if this is a good idea. I would like to collect some feedback before moving on to adding documentations, etc.

Has This Been Tested?

List facilities in a rec-area

camply --provider=RecreationDotGovPermit campgrounds --rec-area=1064
[2023-07-06 22:19:09] CAMPLY   camply, the campsite finder ⛺️                                                          
[2023-07-06 22:19:09] INFO     Using Camply Provider: "RecreationDotGovPermit"
[2023-07-06 22:19:09] INFO     Retrieving Facility Information for Recreation Area ID: `1064`.
[2023-07-06 22:19:11] INFO     3 Matching Campgrounds Found
[2023-07-06 22:19:11] INFO     ⛰  Inyo National Forest, CA (#1064) - 🏕  (Old) Mt. Whitney (Old) (#233260)
[2023-07-06 22:19:11] INFO     ⛰  Inyo National Forest, CA (#1064) - 🏕  Inyo National Forest - Wilderness Permits
                               (#233262)
[2023-07-06 22:19:11] INFO     ⛰  Inyo National Forest, USA (#1064) - 🏕  Mt. Whitney (#445860)
[2023-07-06 22:19:11] CAMPLY   Exiting camply 👋

List permits in a rec-area

camply --provider=RecreationDotGovPermit list-campsites --rec-area=2991
[2023-07-06 22:17:01] CAMPLY   camply, the campsite finder ⛺️                                                          
[2023-07-06 22:17:01] INFO     Using Camply Provider: "RecreationDotGovPermit"
[2023-07-06 22:17:01] INFO     Retrieving Facility Information for Recreation Area ID: `2991`.
[2023-07-06 22:17:03] INFO     2 Matching Campgrounds Found
[2023-07-06 22:17:03] INFO     ⛰  Yosemite National Park, CA (#2991) - 🏕  Half Dome Permits (#234652)
[2023-07-06 22:17:03] INFO     ⛰  Yosemite National Park, USA (#2991) - 🏕  Yosemite National Park Wilderness Permits
                               (#445859)
[2023-07-06 22:17:03] INFO     Searching for campsites to list
[2023-07-06 22:17:04] INFO     Found 2 campgrounds to search
[2023-07-06 22:17:04] INFO     Found 12 Campsites
[2023-07-06 22:17:04] INFO     🏕  Half Dome Permits - (#234652)
[2023-07-06 22:17:04] INFO         ⛺️ Half Dome Cables - (#31)                                                         
[2023-07-06 22:17:04] INFO     🏕  Yosemite National Park Wilderness Permits - (#445859)
[2023-07-06 22:17:04] INFO         ⛺️ Beehive Meadows - (#44585904)                                                    
[2023-07-06 22:17:04] INFO         ⛺️ Cathedral Lakes - (#44585907)                                                    
[2023-07-06 22:17:04] INFO         ⛺️ Glen Aulin - (#44585914)                                                         
[2023-07-06 22:17:04] INFO         ⛺️ Glen Aulin -> Cold Canyon/Waterwheel (pass through) - (#44585915)                
[2023-07-06 22:17:04] INFO         ⛺️ Happy Isles -> Little Yosemite Valley (No Donohue Pass) - (#44585917)
[2023-07-06 22:17:04] INFO         ⛺️ Happy Isles -> Past LYV (Donohue Pass Eligible) - (#44585918)
[2023-07-06 22:17:04] INFO         ⛺️ Lyell Canyon (Donohue Pass Eligible) - (#44585921)
[2023-07-06 22:17:04] INFO         ⛺️ May Lake - (#44585924)
[2023-07-06 22:17:04] INFO         ⛺️ Rafferty Creek -> Vogelsang - (#44585940)
[2023-07-06 22:17:04] INFO         ⛺️ Sunrise - (#44585945)
[2023-07-06 22:17:04] INFO         ⛺️ Young Lakes via Glen Trail - (#44585956)
[2023-07-06 22:17:04] CAMPLY   Exiting camply 👋

Search permits

camply --provider=RecreationDotGovPermit campsites --rec-area=2991 --campsite=44585917 --campsite=44585918 --start-date=2023-07-01 --end-date=2023-07-31 --search-forever

Checklist:

  • I've read the contributing guidelines of this project
  • I've installed and used .pre_commit on all my code
  • I have documented my code, particularly in hard-to-understand areas
  • I have made any necessary corresponding changes to the documentation

@juftin
Copy link
Owner

juftin commented Jul 9, 2023

👏 nice, very exciting. I would love to have this as part of camply. I'm on a long extended trip right now, I won't be home for a couple more weeks before I can take a closer look at this. I'll try to add some questions and comments as I can in the meantime. My first reaction is that everything looks very clean. Excited to dive deeper on this.

Comment on lines +49 to +64
facility_permit_map = {
# Yosemite National Park Wilderness Permits
445859: {
44585904: "Beehive Meadows",
44585907: "Cathedral Lakes",
44585914: "Glen Aulin",
44585915: "Glen Aulin -> Cold Canyon/Waterwheel (pass through)",
44585917: "Happy Isles -> Little Yosemite Valley (No Donohue Pass)",
44585918: "Happy Isles -> Past LYV (Donohue Pass Eligible)",
44585921: "Lyell Canyon (Donohue Pass Eligible)",
44585924: "May Lake",
44585940: "Rafferty Creek -> Vogelsang",
44585945: "Sunrise",
44585956: "Young Lakes via Glen Trail",
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Is there any way to rely on the Recreation.gov API for this? Camply has a built-in API key to talk to the RIDB API here: https://ridb.recreation.gov/docs#/Permit%20Entrances/getFacilityPermitEntrances

Choose a reason for hiding this comment

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

@juftin looking through #22 comments, there are multiple end points for permit search. Would searching through each of them for a given query be a good idea or would it be out of scope for Camply?

Copy link
Owner

Choose a reason for hiding this comment

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

If possible, I don't want to hit every endpoint. It looks like which endpoint to use is actually handled here: https://github.com/changlan/camply/blob/e5425eebd811256d04d7108bd786a439fa11e8fb/camply/providers/recreation_dot_gov/recdotgov_permits.py#L66-L96

It seems like everyone uses the same generic endpoint, unless they show up on this mapping: https://www.recreation.gov/api/permitcontent/permitmapping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants