Determine the bounding box based on the specified distance in miles and the latitude and longitude coordinates provided

I am in need of a solution to calculate the Bounding Box for a given latitude, longitude, and distance. The distance can be in Miles, meters, or feet.

While I have come across many articles on how to calculate the Bounding Box in kilometers, I have not been able to find information on doing so in Miles, meters, or Feet. Can anyone assist me with this?

This thread provides information on calculating in KM: How to calculate the bounding box for a given lat/lng location?

I am open to either Javascript or C# code solutions. Ideally, I am looking for a simple formula as we will be implementing this in PowerApps.

Any assistance would be greatly appreciated.

Answer №1

To incorporate that intricate formula into Power Apps, you can refer to the following example, which is a modified version of the initial response in the linked post. This solution assumes that the latitude, longitude, and half length values in kilometers are stored in text input controls named txtLat, txtLong, and txtHalfSideKm, respectively.

Set(
    bounds,
    With(
        {
            WGS84_a: 6378137.0, // Major semiaxis [m]
            WGS84_b: 6356752.3, // Minor semiaxis [m]
            lat: Radians(Value(txtLat.Text)), lon: Radians(Value(txtLon.Text)),
            halfSideMeters: Value(txtHalfSideKm.Text) * 1000
        },
        With(
            {
                An: WGS84_a * WGS84_a * Cos(lat), Bn: WGS84_b * WGS84_b * Sin(lat),
                Ad: WGS84_a * Cos(lat), Bd: WGS84_b * Sin(lat)
            },
            With(
                { Radius: Sqrt( (An*An + Bn*Bn) / (Ad*Ad + Bd*Bd) ) },
                With(
                    { pRadius: Radius * Cos(lat) },
                    {
                        latMin: Degrees(lat - halfSideMeters / Radius),
                        latMax: Degrees(lat + halfSideMeters / Radius),
                        lonMin: Degrees(lon - halfSideMeters / pRadius),
                        lonMax: Degrees(lon + halfSideMeters / pRadius)
                    }
                )
            )
        )
    )
)

If you wish to use a different unit for the half-side measurement, you only need to adjust the halfSideMeters definition to include the appropriate conversion factor.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The absence of a key is causing an issue - deletion cannot be completed

I need assistance with removing a question after it has been answered, but I am encountering an error message stating that my key is undefined. Error: DELETE http://api/Remove/undefined 400 (Bad Request) state={ qBank:[{id=1,question:'dd',answers ...

My goal is to retrieve and print the duplicated values only once from an associative array

Given an associative array, I need to print all the department names without any repetitions. <h3>2. List out all department names</h3> <div class="all"> </div> Here is my JavaScript code: var employee=[{"firstName":"Zahir","last ...

Use an input to swap out a cube for a sphere in three.js

I need to switch the cube with a sphere of the same size, but when I try to add a function in JavaScript, the cube disappears. How can I adjust the dimensions of the cube? I am unsure how to connect the function modifie with the numeric inputs (length, w ...

Implement Spacing Between Components in React Native

Seeking assistance in resolving the issue of overlapping views within my react native app, specifically requiring spacing between them. Upon clicking the plus sign twice in the top right corner, the two Views overlap without any space between them (referr ...

Looking to pull data for several IDs at once using Data Adapter and DataSet?

I am looking to retrieve a DataSet containing the full record set of users with unique IDs from the Users table. The IDs include 1478, 8906, 4677, and more. What is the best way to achieve this using a DataAdapter? ...

Ways to display a default view in React

I am working on a React website that has three different routes. My goal is to have the first route, named Home, automatically displayed when a user lands on the site. Below is the code snippet from my App.js: <Router> <Navigation /> <Sw ...

Trouble displaying JSON data when using a search box filter in React

My webpage is using JSON dummy data that can be filtered by keywords entered into a search box. Previously, all the data displayed correctly before creating filteredJson, but now nothing is showing up. What could be causing this issue? I want to send the ...

Identifying when a page-loading or reloading event has been canceled

When the Cancel button is pressed during page load/reload, the content of the page loads partially. Is there a more effective way to address this issue rather than displaying incomplete content? For instance, consider showing a message such as "Page load ...

Determining if a string is empty: string.IsNullOrEmpty() or string.IsNullOrWhiteSpace()

When evaluating a string in .NET 4.0 and above, is it frowned upon to use string.IsNullOrEmpty(string) instead of string.IsNullOrWhiteSpace(string)? ...

Searching for particular information within an array of objects

Seeking guidance as a newbie on how to extract a specific object from an array. Here is an example of the Array I am dealing with: data { "orderid": 5, "orderdate": "testurl.com", "username": "chris", "email": "", "userinfo": [ ...

Use Cypress to make requests to GraphQL endpoints using the .request method

Despite my efforts to search for information on using Cypress requests with GraphQL, I come across terms like "mock up server" and "stub" without a clear example. I am struggling to find a comprehensive guide on how to effectively utilize GraphQL with cy ...

What's more efficient in terms of performance, checking for a class versus adding a class?

When dealing with a function that triggers on a scroll event, which method is more efficient? Checking if a class is already added and adding it if not Simply adding the class without any checks each time $(document).on('scroll', function ( ...

Create a visual representation of a hierarchical structure from a JSON data

I am looking to create a tree view using jQuery and JSON. Here is an example of my JSON data for a single folder: [{"id":"076ac97d","path":"\/test\/undefined","name":"undefined","parentDirName":"test","parentDirId":"70b77ddd-6c15"}, .... ] If ...

Is there a way to verify the presence of a selector in Puppeteer?

How can I use Puppeteer to check if #idProductType exists and if not, assign producttype to ""? I have tried multiple solutions but none seem to work. const urls = [myurls, ...] const productsList = []; for (let i = 0; i < urls.length; i++) ...

Ways to swap out element within ViewContainerRef in Angular

I am currently expanding my knowledge of Angular and I have encountered a challenge regarding dynamically creating components and swapping them within a single container. Here is the setup: <ng-container #container></ng-container> Here are the ...

Building a React.js application and fetching information with Ajax

In my quest to create a high-speed React.js application that functions as a game, I find myself in need of displaying real-time data. However, the traditional method of loading this data from the server using Ajax doesn't quite align with the reactive ...

Managing simultaneous tasks with multiple event handlers for a single event

Within the realm of HTML, you may encounter an <input type="file"> element that can be linked to one or more event handlers. However, if one event handler includes asynchronous code, it will pause at that point and move on to the next event ...

What sets xhr.response apart from xhr.responseText in XMLHttpRequest?

Is there any difference between the values returned by xhr.response and xhr.responseText in a 'GET' request? ...

Using Javascript/jQuery to show measurements in the format of feet and inches

I am currently developing a BMI calculator and facing an issue. I would like the height, which is in inches, to be displayed in feet and inches format. Additionally, I want the weight in pounds to be shown in stones and pounds. Here is the code snippet I ...

Transforming a request from Angular to PHP through formatting

I am currently working on creating an add function for my Angular application that communicates with my PHP back-end. I am attempting to send data to the server using a transformationRequest, but I am unsure about the correct format that matches the $_POST ...