Skip to content

Commit

Permalink
feat: first release
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpujol committed Mar 4, 2024
0 parents commit 64dffda
Show file tree
Hide file tree
Showing 19 changed files with 6,936 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.DS_Store
node_modules
/dist
.env

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
15 changes: 15 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020
},
env: {
browser: true,
es2017: true,
node: true
}
};
29 changes: 29 additions & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish to npm

on:
release:
types: [published]

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Install dependencies
run: npm install

- name: Build package
run: npm run build

- name: Publish to npm
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
npm publish
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run unit tests

on:
push:
branches: [develop, main]
pull_request:
branches: [develop, main]

jobs:
unit-tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- run: npm ci
- run: npm test
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
logs
*.log
npm-debug.log*
node_modules/
.npm
.eslintcache
.env
dist
NOTES.md
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/src
/node_modules
.env
.DS_Store
tsconfig.json
tsup.config.js
NOTES.md
14 changes: 14 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.DS_Store
node_modules
/dist
/package
.env
.env.*
!.env.example
NOTES.md
README.md

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"useTabs": true,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.formatOnSave": true,
"cSpell.words": ["bbox", "fbbox", "geospatial", "juanpujol", "geospread", "tsup"],
"githubPullRequests.ignoredPullRequestBranches": ["develop"]
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- markdownlint-disable MD024 -->

# GeoSpread Changelog

## v0.1.0 (2024-03-03)

### First release 🚀

Shipping this small library to the world! 🌍
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Juan Pujol

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# GeoSpread

A library designed to filter a list of geographical points, ensuring that they are spread out from each other by a minimum distance in meters, optionally starting from a specific point. By applying the Haversine algorithm, GeoSpread prunes the input list to create a more evenly distributed set of points, suitable for various geospatial applications.

![example-01](./images/example-01.webp)

## Installation

You can install PolyUnion via npm:

```shell
npm install geospread
```

## Usage

```js
import geospread from 'geospread';

// Example GeoJSON FeatureCollection input
const points = [
[-73.9956, 40.7481],
[-73.9930, 40.7479],
[-73.9939, 40.7466],
[-73.9915, 40.7454],
[-73.9909, 40.7461]
];

const minDistance = 130;
const startPoint = [-73.9939, 40.7466];
const result = geospread(points, minDistance, startPoint);

console.log(result);
// [[ -73.9939, 40.7466 ], [ -73.9956, 40.7481 ], [ -73.9915, 40.7454 ]]
```

The function has 2 parameters:

- `points` - an array of points in the format `[longitude, latitude]`. Note the order is longitude first, latitude second.
- `minDistance` - the minimum distance in meters between each point
- `startPoint` - an optional starting point in the format `[longitude, latitude]`. Note the order is longitude first, latitude second.
Binary file added images/example-01.webp
Binary file not shown.
Loading

0 comments on commit 64dffda

Please sign in to comment.