Geographically ranked Postgres full text search

Here’s a problem: You have 20,000 records each with latitude and longitude coordinates. You want a search function for these records to show the results closest to the user’s current position on a map. What do you do?

Thanks to Postgres’ full text search and Earthdistance extension we can implement this logic entirely in the database and it’s lightning fast to boot.

This is exactly the problem I had when I was working on my recent project Pirep. The core functionality of the website is based around a map which displays ~20,000 airports in the US provided by the FAA’s database. The map has a search feature on it and I wanted it to display results based on the area the user was looking at on the map. For example, searching for Portland when looking at New England would return the Portland, Maine airport rather than the Portland, Oregon airport even though Oregon would likely be the more common result given it’s a larger city.

As far as searching goes, given a database with all of the airports in it, indexing by airport name and location isn’t difficult. The difficulty comes in when trying to rank search results based on the proximity to the user’s current location. It’s not exactly feasible to read every record, calculate its distance to the user, sort by distance, and then take your search results in realtime. You could conceivably index airports by their state and only return results from the same state as the user then calculate distance on those results and sort by that. That may be a “good enough” solution, but in my case I wanted, for example, a search for port when looking at the south Puget Sound to return Port Orchard, WA at the top of the list instead of the further away Port Angeles, WA. Thanks to the Earthdistance extension it’s possible to do this type of calculation entirely in the database and in realtime.

Coexisting Rails Import Maps with Yarn

I dislike Webpack. I even more strongly dislike Webpack when integrated with Rails. My prior experience with it has always been one of those tools that when it works silently in the background doing what you expect it’s fine, but when it doesn’t do what you expect, well, there goes the rest of your day debugging it and endlessly tinkering with obscure configuration files. Then again, JavaScript in general has never been my forte, but all the more reason for a desire to not have JavaScript tooling continually get in the way of focusing on my actual application.

Regardless, when I started work on my recent project, Pirep, circa two years ago I read about a new gem installed by default with Rails 7 applications: importmap-rails. It described itself as such in its README:

You can build modern JavaScript applications using JavaScript libraries made for ES modules (ESM) without the need for transpiling or bundling. This frees you from needing Webpack, Yarn, npm, or any other part of the JavaScript toolchain. All you need is the asset pipeline that’s already included in Rails.

All of this was absolute music to my ears. I instantly adopted it into my application and forwent any type of JavaScript build system. And it worked wonderfully. There was one rough edge, however: third party dependency management.

Generating map tiles for FAA sectional charts with GDAL

Recently I launched the initial version of Pirep, a collaborative website for pilots to collect & share their local knowledge about airports such as transient parking location, crew car availability, nearby attractions/restaurants, camping information, etc. The central component of Pirep being the map page where airports are charted and filterable based on what amenities exist at them.

While it’s easy to get a map with satellite imagery, naturally one would also want the FAA VFR sectional charts as a layer on the map as well. This turned out to be fairly easy to get a proof of concept for, but much more tedious to get to a production-ready state.

A vision for the future of skiing in the PNW

Scattered across various online skiing forums, overheard in lift lines, and discussed on the skin track are conversations about the problems facing skiing in the PNW and potential solutions for the future. I have been participant to my fair share of these but they have always felt to me as being light on specific details and lacking a unified vision. As such, the desire was created to assess the depth of the problems and feasibility of the solutions to the problems we face around access to our mountains. The end goal being the establishment of my vision for the future of skiing in the PNW.

Previously in this series I wrote about how the Cascades snowpack is responding to climate change, what prevented expansion of our ski areas, and where our existing ski areas could expand. The theme of these being that skiing in the PNW is facing the following major issues:

  1. Washington’s rapidly growing population causing overcrowding at existing ski areas
  2. Corporate consolidation leading to ski area owners not having the sport’s best short or long term interests in mind
  3. Climate change causing some existing areas to become nonviable in the foreseeable future
  4. The lack of potential expansion locations due to land use restrictions

The conclusion of all this being that in order to meet demand while keeping our mountains and winter recreation accessible Washington needs to consider the possibility of an entirely new ski area. Specifically, there are four areas of focus that would go a long way to providing sufficient access not just for mechanized skiers, but backcountry skiers, snowshoers, and general snow play (sledding for children and families):

  • Expansions of existing ski areas (see my previous post for details on this point)
  • Creation of a new ski area to provide competition to the large ski corporations
  • Winter maintenance to high elevation trailheads for ski touring, snowshoeing, and sledding
  • Increased focus on winter recreation community groups for ongoing advocacy

This final post attempts to answer the feasibility of doing so. Mainly, why is a new ski area needed, where could it be located, how would it be funded, and how would it operate?

Where can PNW ski areas expand?

Here we are a month or so past the end of the 2021/2022 ski season. On trend with the previous two years, it was another challenging season that demonstrated the problems skiing faces in the PNW. This post is part of a series about the future of skiing and winter recreation in the PNW and how we can potentially go about addressing those problems. Previously I explored what prevented expansion of our ski areas and how the Cascades snowpack is responding to climate change.

This third post explores what our existing ski areas can do to adapt to the overwhelming demand resulting from growing popularity of winter sports and the rapid Western Washington population growth. Specifically, how this can be done through expansion of terrain and chairlift capacity.