JSPM

reproject-line

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 29213
  • Score
    100M100P100Q148672F
  • License CC0-1.0

Re-project a line.

Package Exports

  • reproject-line
  • reproject-line/reproject-line.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (reproject-line) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

reproject-line

smart line reprojection

install

npm install reproject-line

basic usage

import proj4 from "proj4-fully-loaded";
import reproject_line from "reproject-line";

// reproject line from UTM to Lat/Lng
const reproject = proj4("EPSG:4326", "EPSG:32610").forward;

const line = [
  [-119.016667, 35.366667], // Bakersfield, CA
  [-119.766667, 36.75], // Fresno, CA, USA
];

reproject_line(line, reproject);
[
  [861953.7586231146,3920995.6805079672], // Bakersfield in UTM
  [788672.26444508,4072016.1098799286] // Fresno in UTM
]

advanced usage

point densification

number of points

You can also increase the number of vertices in each line segment before reprojection.

// adds 3 points to every line segment
reproject_line(line, reproject, { densify: 3 });

strategy

By default, reproject-line takes an "optimal" approach of only adding vertices if they are necessary, in other words, only adding if the line segment bends when reprojected. If you would like to add points to each line segment regardless of whether it's still straight when reprojected, pass strategy: "always"

// always add 3 point to each line segment even if unnecessary
reproject_line(line, reproject, { densify: 3, strategy: "always" });