---
name: "GIS::Distance::Formula"
section: "3pm"
platform: "linux"
package: "libgis-distance-perl"
version: "0.20-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/GIS::Distance::Formula"
---

# GIS::Distance::Formula(3pm)

Formula base class.

## NAME

GIS::Distance::Formula - Formula base class.

## DESCRIPTION

This is the parent class for all GIS::Distance formula classes such as those listed at "FORMULAS" in GIS::Distance.

To author your own formula class:

```
    package My::Formula;

    use parent 'GIS::Distance::Formula';

    sub _distance {
        my ($lat1, $lon1, $lat2, $lon2) = @_;

        # ...

        return $kilometers;
    }

    1;
```

Then use it:

```
    my $gis = GIS::Distance->new('My::Formula');
    my $km = $gis->distance( @coords );
```

The global `$GIS::Distance::Formula::SELF` is available when your `"_distance()"` subroutine is called if, and only if, the entry point was "distance" in GIS::Distance and NOT "distance\_metal" in GIS::Distance or otherwise.

Much of the interface described in GIS::Distance is actually implemented by this module.

## SUPPORT

See "SUPPORT" in GIS::Distance.

## AUTHORS

See "AUTHORS" in GIS::Distance.

## LICENSE

See "LICENSE" in GIS::Distance.
