npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

marinetraffic

v0.0.3

Published

Fetch data from http://marinetraffic.com

Downloads

16

Readme

Marinetraffic

Node module to fetch a ships track from http://marinetraffic.com and convert it to json/geojson to be analysed or plotted on a (Leaflet) map.

Please note that this should be used for personal convenience only and not in production websites.

Usage example

npm install marinetraffic

var marinetraffic = require('marinetraffic');

marinetraffic(mmsi, function (err, result) {
	console.log(result);
});

API

marinetraffic(mmsi, callback(err, result))

Fetches the track for vessel with mmsi, calls callback when ready, with err and a result object as arguments.

marinetraffic.toGeoJson(json, options)

Convert json to GeoJSON with optional options.

marinetraffic.fromJson(json)

Constructs a result object from the JSON representation of the track, for example from a cached file.

marinetraffic.xml2json(xml, callback(err, result))

Converts xml reply from marinetraffic to json.

result object

Example of a result object:

{ raw:
	[	{	latlng: [Object],
			speed: 0.1,
			course: 122,
			timestamp: '2013-08-30T15:51:00' },
		{ latlng: [Object],
			speed: 0.1,
			course: 122,
			timestamp: '2013-08-30T16:01:00' },

	[...]

		{ latlng: [Object],
			speed: 1.7,
			course: 337,
			timestamp: '2013-08-31T11:41:00' } ],
	union: [Function],
	toGeoJson: [Function] }

result.raw

The raw member contains a JSON representation of all the points.

result.union(otherResult)

Returns the union of result and otherResult by looking at the timestamps of each trackpoint, keeping the reference to result.

result.toGeoJson([options])

Returns a GeoJSON representation of the track. It takes an optional options object to tune the output:

{
	points: false,              // output Point features for each track point
	speedThreshold: 0.51,       // ignore points with speeds below threshold,
	timeThreshold: 2 * 60 * 60  // create new linestring if diff exeeds 2h
}

Example

To start the example, after cloning the repo, running

npm install && cd example && npm install && npm start

will start the server on http://localhost:8888.