Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Calculate great circles routes.
Algorithms from http://williams.best.vwh.net/avform.htm#Intermediate
For NodeJS usage, install with npm:
npm install -g
Require the library in node.js like:
var arc = require('arc');
Use in the browser like:
<script src="./arc.js"></script>
The API works like so:
1) Create start and end coordinates
First we need to declare where the arc should start and end
var start = new arc.Coord(-122, 48);
var end = new arc.Coord(-77, 39);
These are [lon,lat]
pairs like GeoJSON. Be aware that Leaflet uses [lat,lon]
order currently.
2) Create GreatCircle object
Next we pass the start/end to the GreatCircle
constructor, along with an optional object representing the properties for this future line.
var gc = new arc.GreatCircle(start, end, {'name': 'Seattle to DC'});
3) Generate a line
Then call the Arc
function to generate a line:
var npoints = 6;
var line = gc.Arc(npoints);
The npoints
argument specifies the number of intermediate vertices you want in the resulting line. The higher the number the more dense and accurate the line will be.
Then line
will be a raw sequence of the start and end coordinates plus an arc of
intermediate coordinate pairs.
> line
{ properties: { name: 'Seattle to DC' },
coords:
[ [ -122, 48.00000000000001 ],
[ -112.06161978373486, 47.7241672604096 ],
[ -102.38404317022653, 46.60813199882492 ],
[ -93.22718895342909, 44.716217302635705 ],
[ -84.74823988299501, 42.14415510795357 ],
[ -77, 38.99999999999999 ] ],
length: 6 }
You can then serialize to a GeoJSON geometry:
> line.json();
{ geometry:
{ type: 'LineString',
coordinates: [ [Object], [Object], [Object], [Object], [Object], [Object] ] },
type: 'Feature',
properties: { name: 'Seattle to DC' } }
Or to WKT (Well known text):
> line.wkt();
'LINESTRING(-122 48.00000000000001,-112.06161978373486 47.7241672604096,-102.38404317022653 46.60813199882492,-93.22718895342909 44.716217302635705,-84.74823988299501 42.14415510795357,-77 38.99999999999999)'
It is then up to you to add up these features to create fully fledged geodata. See the examples/ directory for sample code to create GeoJSON feature collection from multiple routes.
FAQs
draw great circle arcs
The npm package arc receives a total of 12,626 weekly downloads. As such, arc popularity was classified as popular.
We found that arc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.