Giter Site home page Giter Site logo

position-api's Introduction

locationsource

Solution to access machine readable AIS Data. This solution uses the free web solutions to crawl the data and returns them in json.

As this repo is a successor to the ais-api, lecacy parts are added (see legacy) Those will be removed in future versions.

Install on local machine

Requirements: npm & nodejs.

  1. clone this repo

  2. run npm install

  3. run npm run dev

Location Format

All locations are returned in this format: { timestamp: ISO 8601 latitude: longitude: course: in deg speed: in kn source: source_type: e.g. ais raw_data: (contains all the raw data) }

Legacy Paths

As this repo is a successor to the ais-api, some legacy paths are added. Those will be removed in future versions

/legacy/getLastPosition/:mmsi

Takes position from MT and from VT and returns the newest example: http://localhost:5000/legacy/getLastPosition/211879870

/legacy/getLastPositionFromVF/:mmsi

Returns position from VF example: http://localhost:5000/legacy/getLastPositionFromVF/211281610

/legacy/getLastPositionFromMT/:mmsi

Returns position from MT example: http://localhost:5000/legacy/getLastPositionFromMT/211281610

/legacy/getVesselsInArea/:area

Returns all vessels in area, defined by a list of area keywords example: http://localhost:5000/legacy/getVesselsInArea/WMED,EMED

/legacy/getVesselsNearMe/:lat/:lng/:distance

Returns all vessels near me, defined by a location in latitude, longitude, and distance example: http://localhost:5000/legacy/getVesselsNearMe/51.74190/3.89773/2

[{
  name: vessel.SHIPNAME,
  id: vessel.SHIP_ID,
  lat: Number(vessel.LAT),
  lon: Number(vessel.LON),
  timestamp: vessel.LAST_POS,
  mmsi: vessel.MMSI,
  imo: vessel.IMO,
  callsign: vessel.CALLSIGN,
  speed: Number(vessel.SPEED),
  area: vessel.AREA_CODE,
  type: vessel.TYPE_SUMMARY,
  country: vessel.COUNTRY,
  destination: vessel.DESTINATION,
  port_current_id: vessel.PORT_ID,
  port_current: vessel.CURRENT_PORT,
  port_next_id: vessel.NEXT_PORT_ID,
  port_next: vessel.NEXT_PORT_NAME,
},]

/legacy/getVesselsInPort/:shipPort

Returns all vessels in a port, named after the MT nomenclature example: http://localhost:5000/legacy/getVesselsInPort/piraeus

Output format identical to getVesselsInArea

Paths

/:sourcetype/:source/:vehicleidentifier/location/latest

find latest position for vehicle for specified sourcetype and source example: http://localhost:5000/ais/mt/211281610/location/latest

/:source/:placeidentifier/vehicles/

/:source/area/vehicles

position-api's People

Contributors

niczem avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

position-api's Issues

How do you change the port the server runs on?

I have another process running on port 5000 which is causing an error when I start the server. How can I change the port the server runs on?

I would guess it is by changing the "PORT=" value the in .env.template. However, doing so does not seem to affect the port. For example, I change the port to 5003 and restart the server. However, I then continue to receive the same error:
node:events:497
[1] throw er; // Unhandled 'error' event
[1] ^
[1]
[1] Error: listen EADDRINUSE: address already in use :::5000
[1] at Server.setupListenHandle [as _listen2] (node:net:1872:16)
[1] at listenInCluster (node:net:1920:12)
[1] at Server.listen (node:net:2008:7)
[1] at Function.listen (/Users/mwalther/Downloads/position-api-main/node_modules/express/lib/application.js:635:24)
[1] at Server.init (/Users/mwalther/Downloads/position-api-main/dist/classes/server.js:27:18)
[1] at new Server (/Users/mwalther/Downloads/position-api-main/dist/classes/server.js:14:14)
[1] at Object. (/Users/mwalther/Downloads/position-api-main/dist/index.js:13:1)
[1] at Module._compile (node:internal/modules/cjs/loader:1376:14)
[1] at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
[1] at Module.load (node:internal/modules/cjs/loader:1207:32)
[1] Emitted 'error' event on Server instance at:
[1] at emitErrorNT (node:net:1899:8)
[1] at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
[1] code: 'EADDRINUSE',
[1] errno: -48,
[1] syscall: 'listen',
[1] address: '::',
[1] port: 5000
[1] }
[1]
[1] Node.js v21.2.0

License request

Hello, thank you for your work on this project. Would you mind adding a license ?

Cannot GET PATH

Hi.
Start side works normally but when I try to get data I get Error: Cannot GET "Path". I tried all functions on win10 and debian everytime with the same result.

I'm not into web dev so maybe I missed some obvious step. Can you please help?

Response parse error.

[1] A request was started: https://www.marinetraffic.com/en/reports?asset_type=vessels&columns=time_of_latest_position:desc,flag,shipname,photo,recognized_next_port,reported_eta,reported_destination,current_port,imo,ship_type,show_on_live_map,area,lat_of_latest_position,lon_of_latest_position&time_of_latest_position_between=60,525600&near_me=51.74190,3.89773,2
[1] A request was started: https://www.marinetraffic.com/cdn-cgi/styles/cf.errors.css
[1] undefined:1
[1]
[1] ^
[1]
[1] SyntaxError: Unexpected token '<', ")
[1] at HTTPResponse.json (/Users/krishna.kumar/Workspace/ocean-open/position-api/node_modules/puppeteer-core/lib/cjs/puppeteer/api/HTTPResponse.js:111:21)
[1] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[1] at async /Users/krishna.kumar/Workspace/ocean-open/position-api/dist/legacy/lib/puppeteer.js:24:26
[1]
[1] Node.js v21.6.2

Looks like its trying to parse http as a json. Anything missed here ?

Errors on starting Node

Thanks for this awesome project! I am getting the following errors when trying to start the server, which are preventing startup.

0] src/classes/sources/adsb/adsbe.ts(7,31): error TS2339: Property 'timestamp' does not exist on type 'object'.
[0] src/classes/sources/adsb/adsbe.ts(8,30): error TS2339: Property 'latitude' does not exist on type 'object'.
[0] src/classes/sources/adsb/adsbe.ts(9,31): error TS2339: Property 'longitude' does not exist on type 'object'.
[0] src/classes/sources/adsb/adsbe.ts(10,28): error TS2339: Property 'course' does not exist on type 'object'.
[0] src/classes/sources/adsb/adsbe.ts(11,27): error TS2339: Property 'speed' does not exist on type 'object'.
[0] src/classes/sources/adsb/adsbe.ts(12,25): error TS2339: Property 'raw' does not exist on type 'object'.
[0] src/classes/sources/adsb/adsbe.ts(36,13): error TS2322: Type 'null' is not assignable to type 'BodyInit | undefined'.
[0] src/classes/sources/adsb/adsbe.ts(75,13): error TS2322: Type 'null' is not assignable to type 'BodyInit | undefined'.
[0] src/classes/sources/ais/mst.ts(5,31): error TS2339: Property 'timestamp' does not exist on type 'object'.
[0] src/classes/sources/ais/mst.ts(6,30): error TS2339: Property 'latitude' does not exist on type 'object'.
[0] src/classes/sources/ais/mst.ts(7,31): error TS2339: Property 'longitude' does not exist on type 'object'.
[0] src/classes/sources/ais/mst.ts(8,28): error TS2339: Property 'course' does not exist on type 'object'.
[0] src/classes/sources/ais/mst.ts(9,27): error TS2339: Property 'speed' does not exist on type 'object'.
[0] src/classes/sources/ais/mt.ts(5,31): error TS2339: Property 'timestamp' does not exist on type 'object'.
[0] src/classes/sources/ais/mt.ts(6,30): error TS2339: Property 'latitude' does not exist on type 'object'.
[0] src/classes/sources/ais/mt.ts(7,31): error TS2339: Property 'longitude' does not exist on type 'object'.
[0] src/classes/sources/ais/mt.ts(8,28): error TS2339: Property 'course' does not exist on type 'object'.
[0] src/classes/sources/ais/mt.ts(9,27): error TS2339: Property 'speed' does not exist on type 'object'.
[0] src/classes/sources/ais/mt.ts(31,21): error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?
[0] src/classes/sources/Source.ts(8,12): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
[0] src/classes/sources/Source.ts(9,20): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
[0] src/classes/sources/Source.ts(11,9): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
[0] src/classes/sources/Source.ts(17,13): error TS2345: Argument of type '{ headless: true; defaultViewport: { width: number; height: number; }; waitUntil: string; args: string[]; }' is not assignable to parameter of type 'PuppeteerLaunchOptions'.
[0] Object literal may only specify known properties, and 'waitUntil' does not exist in type 'PuppeteerLaunchOptions'.
[0] src/classes/sources/Source.ts(20,16): error TS2683: 'this' implicitly has type 'any' because it does not have a type annotation.
[0] src/classes/sources/Source.ts(33,42): error TS2345: Argument of type 'String' is not assignable to parameter of type 'RequestInfo'.
[0]
[0] 1:40:24 PM - Found 25 errors. Watching for file changes.

How to call the new position-api?

I can see the default request provided but upon requesting we get 403 instantly on all routes. So wondering what has changed, are you using an auth param?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.