HaversineFormula

Category: Modules
Subcategory: All

Overview

The haversine formula determines the great-circle distance between two points on a sphere given their longitudes and latitudes. Important in navigation, it is a special case of a more general formula in spherical trigonometry, the law of haversines, that relates the sides and angles of spherical triangles.

Documentation

Description

This module provides you a Java-action that allows you to calculate the bird’s-eye view distance between two geolocation points. If you want to know the distance between two points on a map, fill in the latitude and longitude of point A and the latitude and longitude of point B. The outcome of the Java-action will provide you the distance in km. You can find this Java-action in the _USE_ME-folder in the Resources-folder.

Other than that, there’s also a short example included. If you want to see the logic in action, view the pages and microflows in the Example-folder. Start from page Input_StartingPoint and you’re good to go.

Typical usage scenario

This functionality came in handy everytime I created something for a customer / PoC that included maps and geolocation. A very particular use case was the following: we had an overview of all the parking spots and their available parking space of a big city. As and end-user, when you wanted to plan a trip to the city, you could plan where to park your car, based on the availability and your destination. Of course, when you go to the city and park your car, you don’t want to walk all through the city, you want the available parking spot as close as possible to your destination. Then, the Haversine Formula comes in handy.

Features and limitations

Features:

  • It calculates the distance in km’s in bird’s-eye view from one geolocation to another one.

Limitations:

  • As mentioned, it’s bird’s-eye view, it doesn’t calculate the route by foot/by public transport ...

Dependencies:

  • The Java-action makes use of java.lang.Math and java.math.MathContext

Installation

No installation needed: just download the module and you’re all set. Plug and play!

Configuration

The Mendix developer can immediately start using the Java-action. There’s an example included in the folder ‘Example’ for more information. That way, he can experience how it’s used. You can verify this in the screenshots attached here.

Bugs

So far, none known.

Releases

Version: 1.0.0
Framework Version: 8.12.0
Release Notes: First release contains the custom Java action that returns the distance in bird's-eye view and an example application with several pages, microflows and according data model.