Skip to content

Commit

Permalink
chore: use external release-config to publish new releases with autom…
Browse files Browse the repository at this point in the history
…ated CHANGELOG.md
  • Loading branch information
manuelbieh committed May 24, 2020
1 parent 15aa5eb commit 81b4bce
Show file tree
Hide file tree
Showing 6 changed files with 532 additions and 152 deletions.
35 changes: 0 additions & 35 deletions .releaserc

This file was deleted.

80 changes: 0 additions & 80 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,83 +1,3 @@
# Changelog

## Breaking Changes in 3.0.0 and migration from 2.x.x

In version 3.0.0 I'm trying to get a little bit _back to the roots_. **Geolib** was once started because I needed a handful of methods to perform very specific geo related tasks like getting the distance or the direction between two points. Since it was one of the very first libraries on npm back then to do these kind of things in a very simple way it became very popular (with more than 300k downloads per month as of April 2019!) and as a consequence got a lot of contributions over the years. Many of which I just merged as long as they had accompanying tests, without looking at consistency, conventions, complexity, coding style or even the overall quality of the functions that I sometimes didn't even fully understand.

I have now cleaned up the codebase completely, rebuilt the entire library "from scratch", unified all the function arguments, removed a few functions where I wasn't sure if they should be in here (feel free to add them back of you're using them!) or if they were even used (did a few searches on GitHub for the function names, turned out there are zero results).

Elevation support was dropped, as well as a few functions that unnecessarily made the library really large in size (e.g. `isPointInsideRobust` alone was over 700[!] lines of code and was basically taken from a [different library](https://github.com/mikolalysenko/robust-point-in-polygon)).

I removed Grunt from the build process, added "modern" tools like ESLint and Prettier. I switched from Travis CI to Circle CI and I am in the process of further automating the release process of new versions using `semantic-release` and `conventional-commits`. I also switched from pure JavaScript to TypeScript because I think it does have some benefits.

- All functions are pure functions now. No input data is mutated anymore. You give the same input, you get the same output. No side effects or whatsoever.
- I changed the default `getDistance` function from being the slow, accurate one to being the fast, slightly inaccurate one. The old `getDistance` function is now named `getPreciseDistance` while the old `getDistanceSimple` function is now the default `getDistance` function. You can, however, pass `getPreciseDistance` as argument to any function that uses distance calculation internally.
- Artificial limitation to 8 decimal places in decimal coordinates was removed
- `getBoundsOfDistance()` now returns the _exact_ coordinates due to the removal of the artificial 8 decimal place limitation
- `getCompassDirection()` does no longer return an object with an _exact_ and a _rough_ direction but only the exact direction as string
- third argument to `getCompassDirection()` is no longer a string ("circle", "line") but a function to determine the bearing (you can pass `getRhumbLineBearing` or `getGreatCircleBearing`). The function receives the origin and the destination as first and second argument. If no 3rd argument was given, `getRhumbLineBearing(origin, dest)` is used by default.
- There is now a new helper function `roughCompassDirection(exact)` if you _really_ only need a very rough (and potentially inaccurate or inappropriate) direction. Better don't use it.
- `orderByDistance()` does no longer modify its input so does not add a `distance` and `key` property to the returned coordinates.
- The result of `getSpeed()` is now always returned as **meters per second**. It can be converted using the new convenience function `convertSpeed(mps, targetUnit)`
- Relevant value (usually point or distance) is now consistently the **first** argument for each function (it wasn't before, how confusing is that?)
- `findNearest()` does no longer take `offset` and `limit` arguments. It's only a convenience method to get the single one nearest point from a set of coordinates. If you need more than one, have a look at the implementation and implement your own logic using `orderByDistance`
- Whereever distances are involved, they are returned as meters or meters per second. No more inconsistent defaults like kilometers or kilometers per hour.
- The method how sexagesimal is formatted differs a little bit. It may now potentially return ugly float point units like `52° 46' 21.0004"` in rare cases but it is also more accurate than it was before.
- Dropped support for Meteor (feel free to add it back if you like)

### ✅ Functions with the same name

- `computeDestinationPoint`
- `getBounds`
- `getBoundsOfDistance`
- `getCenter`
- `getCenterOfBounds`
- `getCompassDirection`
- `getDistanceFromLine`
- `getPathLength`
- `getRhumbLineBearing`
- `getSpeed`
- `isDecimal`
- `isPointInLine`
- `isPointNearLine`
- `isSexagesimal`
- `orderByDistance`

### ❗ Renamed functions

- `getKeys` renamed to `getCoordinateKeys`
- `validate` renamed to `isValidCoordinate`
- `getLat` renamed to `getLatitude`
- `getLon` renamed to `getLongitude`
- `latitude` -> renamed to `getLatitude`
- `longitude` -> renamed to `getLongitude`
- `convertUnit` -> remamed to convertDistance, because name was too ambiguous
- `useDecimal` renamed to `toDecimal`
- `decimal2sexagesimal` renamed to `decimalToSexagesimal`
- `sexagesimal2decimal` renamed to `sexagesimalToDecimal`
- `getDistance` renamed to `getPreciseDistance`
- `getDistanceSimple` renamed to `getDistance`
- `isPointInside` renamed to `isPointInPolygon`
- `isPointInCircle` renamed to `isPointWithinRadius`
- `getBearing` renamed to `getGreatCircleBearing` to be more explicit

### 🗑 Removed functions

- `getElev` -> removed
- `elevation` -> removed
- `coords` -> removed (might be re-added as getCoordinate or getNormalizedCoordinate)
- `ll` -> removed (because wtf?)
- `preparePolygonForIsPointInsideOptimized` -> removed due to missing documentation and missing tests
- `isPointInsideWithPreparedPolygon` -> removed due to missing documentation
- `isInside` alias -> removed (too ambiguous) - use `isPointInPolygon` or `isPointWithinRadius`
- `withinRadius` -> removed, use `isPointWithinRadius`
- `getDirection` alias -> removed (unnecessary clutter) - use `getCompassDirection`

### 🆕 Added functions

- `getAreaOfPolygon` to calculate the area of a polygon
- `getCoordinateKey` to get a property name (e.g. `lat` or `lng` of an object based on an array of possible names)

## v2.0.24

- Dropped support for IE6, IE7, IE8
Expand Down
82 changes: 80 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Geolib

Library to provide basic geospatial operations like distance calculation, conversion of decimal coordinates to sexagesimal and vice versa, etc. This library is currently **2D**, meaning that altitude/elevation is not yet supported by any of its functions!

[![CircleCI](https://circleci.com/gh/manuelbieh/geolib/tree/master.svg?style=svg)](https://circleci.com/gh/manuelbieh/geolib/tree/master)
![](https://badgen.net/bundlephobia/minzip/geolib)
![](https://badgen.net/npm/dm/geolib)
![](https://badgen.net/github/license/manuelbieh/geolib)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)

Library to provide basic geospatial operations like distance calculation, conversion of decimal coordinates to sexagesimal and vice versa, etc. This library is currently **2D**, meaning that altitude/elevation is not yet supported by any of its functions!

## Changelog

A detailed changelog can be found in [CHANGELOG.md](./CHANGELOG.md)
Expand Down Expand Up @@ -564,3 +564,81 @@ geolib.wktToPolygon('POLYGON ((30 10.54321, 40 40, 20 40, 10 20, 30 10))');
```

Returns the array of coordinates.

## Breaking Changes in 3.0.0 and migration from 2.x.x

In version 3.0.0 I'm trying to get a little bit _back to the roots_. **Geolib** was once started because I needed a handful of methods to perform very specific geo related tasks like getting the distance or the direction between two points. Since it was one of the very first libraries on npm back then to do these kind of things in a very simple way it became very popular (with more than 300k downloads per month as of April 2019!) and as a consequence got a lot of contributions over the years. Many of which I just merged as long as they had accompanying tests, without looking at consistency, conventions, complexity, coding style or even the overall quality of the functions that I sometimes didn't even fully understand.

I have now cleaned up the codebase completely, rebuilt the entire library "from scratch", unified all the function arguments, removed a few functions where I wasn't sure if they should be in here (feel free to add them back of you're using them!) or if they were even used (did a few searches on GitHub for the function names, turned out there are zero results).

Elevation support was dropped, as well as a few functions that unnecessarily made the library really large in size (e.g. `isPointInsideRobust` alone was over 700[!] lines of code and was basically taken from a [different library](https://github.com/mikolalysenko/robust-point-in-polygon)).

I removed Grunt from the build process, added "modern" tools like ESLint and Prettier. I switched from Travis CI to Circle CI and I am in the process of further automating the release process of new versions using `semantic-release` and `conventional-commits`. I also switched from pure JavaScript to TypeScript because I think it does have some benefits.

- All functions are pure functions now. No input data is mutated anymore. You give the same input, you get the same output. No side effects or whatsoever.
- I changed the default `getDistance` function from being the slow, accurate one to being the fast, slightly inaccurate one. The old `getDistance` function is now named `getPreciseDistance` while the old `getDistanceSimple` function is now the default `getDistance` function. You can, however, pass `getPreciseDistance` as argument to any function that uses distance calculation internally.
- Artificial limitation to 8 decimal places in decimal coordinates was removed
- `getBoundsOfDistance()` now returns the _exact_ coordinates due to the removal of the artificial 8 decimal place limitation
- `getCompassDirection()` does no longer return an object with an _exact_ and a _rough_ direction but only the exact direction as string
- third argument to `getCompassDirection()` is no longer a string ("circle", "line") but a function to determine the bearing (you can pass `getRhumbLineBearing` or `getGreatCircleBearing`). The function receives the origin and the destination as first and second argument. If no 3rd argument was given, `getRhumbLineBearing(origin, dest)` is used by default.
- There is now a new helper function `roughCompassDirection(exact)` if you _really_ only need a very rough (and potentially inaccurate or inappropriate) direction. Better don't use it.
- `orderByDistance()` does no longer modify its input so does not add a `distance` and `key` property to the returned coordinates.
- The result of `getSpeed()` is now always returned as **meters per second**. It can be converted using the new convenience function `convertSpeed(mps, targetUnit)`
- Relevant value (usually point or distance) is now consistently the **first** argument for each function (it wasn't before, how confusing is that?)
- `findNearest()` does no longer take `offset` and `limit` arguments. It's only a convenience method to get the single one nearest point from a set of coordinates. If you need more than one, have a look at the implementation and implement your own logic using `orderByDistance`
- Whereever distances are involved, they are returned as meters or meters per second. No more inconsistent defaults like kilometers or kilometers per hour.
- The method how sexagesimal is formatted differs a little bit. It may now potentially return ugly float point units like `52° 46' 21.0004"` in rare cases but it is also more accurate than it was before.
- Dropped support for Meteor (feel free to add it back if you like)

### ✅ Functions with the same name

- `computeDestinationPoint`
- `getBounds`
- `getBoundsOfDistance`
- `getCenter`
- `getCenterOfBounds`
- `getCompassDirection`
- `getDistanceFromLine`
- `getPathLength`
- `getRhumbLineBearing`
- `getSpeed`
- `isDecimal`
- `isPointInLine`
- `isPointNearLine`
- `isSexagesimal`
- `orderByDistance`

### ❗ Renamed functions

- `getKeys` renamed to `getCoordinateKeys`
- `validate` renamed to `isValidCoordinate`
- `getLat` renamed to `getLatitude`
- `getLon` renamed to `getLongitude`
- `latitude` -> renamed to `getLatitude`
- `longitude` -> renamed to `getLongitude`
- `convertUnit` -> remamed to convertDistance, because name was too ambiguous
- `useDecimal` renamed to `toDecimal`
- `decimal2sexagesimal` renamed to `decimalToSexagesimal`
- `sexagesimal2decimal` renamed to `sexagesimalToDecimal`
- `getDistance` renamed to `getPreciseDistance`
- `getDistanceSimple` renamed to `getDistance`
- `isPointInside` renamed to `isPointInPolygon`
- `isPointInCircle` renamed to `isPointWithinRadius`
- `getBearing` renamed to `getGreatCircleBearing` to be more explicit

### 🗑 Removed functions

- `getElev` -> removed
- `elevation` -> removed
- `coords` -> removed (might be re-added as getCoordinate or getNormalizedCoordinate)
- `ll` -> removed (because wtf?)
- `preparePolygonForIsPointInsideOptimized` -> removed due to missing documentation and missing tests
- `isPointInsideWithPreparedPolygon` -> removed due to missing documentation
- `isInside` alias -> removed (too ambiguous) - use `isPointInPolygon` or `isPointWithinRadius`
- `withinRadius` -> removed, use `isPointWithinRadius`
- `getDirection` alias -> removed (unnecessary clutter) - use `getCompassDirection`

### 🆕 Added functions

- `getAreaOfPolygon` to calculate the area of a polygon
- `getCoordinateKey` to get a property name (e.g. `lat` or `lng` of an object based on an array of possible names)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@typescript-eslint/eslint-plugin": "^2.14.0",
"@typescript-eslint/parser": "^2.14.0",
"@werkzeugkiste/eslint-config": "1.0.6",
"@werkzeugkiste/release-config": "1.0.1",
"babel-eslint": "10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
Expand All @@ -59,7 +60,7 @@
"eslint-plugin-react-hooks": "2.3.0",
"eslint-plugin-security": "1.4.0",
"eslint-plugin-unicorn": "15.0.1",
"husky": "^3.1.0",
"husky": "3.1.0",
"install-deps-postmerge": "^1.0.5",
"jest": "^24.9.0",
"lint-staged": "^9.5.0",
Expand Down
1 change: 1 addition & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('@werkzeugkiste/release-config/release.config');
Loading

0 comments on commit 81b4bce

Please sign in to comment.