School navigation

LiveWhale Support

LiveWhale Push Updated

By David McKelvey

 

Today I completed a significant update to LiveWhale Push, our open source push notifications module for LiveWhale, to account for the addition of LiveWhale Places last week. LiveWhale Push now allows subscribers to use two new parameters for filtering updates based on location: place_id and radius.

When place_id is specified, the news story, event or blurb must be located within the radius (in miles up to 10) of the place. And, radius can be zero, to keep updates limited to those geo-tagged with just that place.

Adapting LiveWhale Push did take a good bit of work for various reasons, but among them was the calculation of the radius for each subscription each time someone updates their content. The equations for calculating distance based on the latitude and longitude are somewhat complex and at first I opted to use MySQL’s built in spatial functions normally used for GIS.

However, there was a downside as those functions were based on the assumption of flat cartesian space, and not distance wrapped around a curved globe. I did some approximation to account for this, but MySQL also left me with the usable distance in degrees radians, which was not helpful, so in the end I switched to using an equation that allowed me to keep my distances in miles.

There’s a number of equations that will help you with this like the haversine or equirectangular approximation — to varying degrees of accuracy. In the end I chose the spherical law of cosines as I was limiting radius to ten miles and LiveWhale UI encourages more than a few meters distance between places. MySQL is still doing all the calculations, but it keeps everything in location-relevant distance.

And now that the paint isn’t even dry, I’ll be taking Push for a spin using it for our new digital displays. (If you’re still wondering what LiveWhale Push is, read the announcement.)

Ask a Question

If you have questions about this or any other topic related to your work on the Lewis & Clark website, we want to hear from you! 

Share this story on

LiveWhale Support

Contact Us