Organizing Data by Location
Any project that involves a relatively large amount of information has typically put some thought into how that information is organized. For example, the different ways that information is categorized or how one type of information is related to another.
Most often, information is categorized with keywords or explicitly related by connecting one object of information to another. Maintaining all of these connections can sometimes become time consuming and error-prone.
The location of specific information (its precise place in the world) can often be a very effective way to organize information. However, this method is often not used because querying information by location usually requires considerable additional development time and infrastructure. However, using Elebase, organizing and relating data by location is relatively easy because of the platform's built-in tools.
This all may seem kind of abstract, so let me provide a specific case study so that it hopefully makes more sense.
Connecting Local Businesses to Trailheads
The Montana Wilderness Association has developed the hike.wildmontana.org site to help inspire people to get outside and explore trails in wilderness areas and areas that are in need of wilderness protection. The organization also wanted to promote local businesses that are nearby a trailhead.
The requirement was to link a trailhead to local businesses. There were a few ways it could be accomplished:
• Every time a new business was added, manually link that business to the nearby trails.
The downside to this approach is that new trails are added all the time—as well as new businesses. Trying to keep-up with manually linking the trails and the businesses would be a pretty time-consuming and error-prone task.
• Every time a new trail is added, manually link that business to the nearby businesses.
See previous approach. Same problems, just from the opposite approach.
• Automatically connect the nearest by radius proximity.
This is the most common approach to solving this 'proximity' linking problem. It is relatively simple API request that will find all points (geographical coordinates) within a set radius of another point. For example, one could look for all businesses locations that fall within 30 radius miles of a trailhead.
There are some downsides to this approach. The primary downside is that the radius "as the crow flies" can often be much different than the real-world distance. For example, a trailhead in Montana might be within a long valley. A business that is within 30 miles (as the crow flies) might actually be in the next valley over, and in practical reality is actually 100 or miles away.
• Automatically connect points within an area (aka 'polygon').
An area can be whatever shape it needs to be. That means it could span the length of a narrow valley, or cover the unique aspects of where a transportation network provides access.
In hike.wildmontana.org, the connection between a trail and a business is made automatically using an area (polygon) search using an Elebase endpoint that easily allows for this.
How it is done.
New trails and new businesses are added independent of each other using the Elebase app. When a business or trail is added, the trailhead location and the business location are added using a Geo Element.
A Trail's Geolocation is Added
A 'Nearby Business Area' Polygon is Added
Editor or Manager level users are also able to create the 'Nearby Business Area' location for that trailhead, easily drawing a polygon that reflects the natural area for location businesses associated with the trailhead.
Businesses Within the Business Area are Automatically Related
When trail details are loaded in hike.wildmontana.org, the businesses that are within the "Nearby Business Area" for that trail are automatically loaded.
Using the Elebase API, getting that information is simply a matter of passing the polygon as a parameter. You can learn more about this parameter here: https://elebase.io/learn/api/entries#retrieve-entries