aisstream / issues

7 stars 3 forks source link

[Feature Request] Missing AIS data for a given area? #44

Open mttchpmn opened 1 year ago

mttchpmn commented 1 year ago

Firstly, thanks for making such a great API. Would love to contribute if you're looking for contributors.

I'm currently consuming the AIS stream to get vessel information for Auckland, NZ. However when I compare the data I'm receiving to the data available on a tracker such as marinetraffic.com, I seem to be missing the data for a lot of ships?

Why is this? Do other services provide more coverage for a given area? This is important as I need to be able to trust that I am getting reliable coverage for a given area.

Here is the flutter code I am using, for reference. Note that I am only using the PositionReport, StandardClassBPositionReport, and ExtendedClassBPositionReport types. Should I be using others for position reports as well?

Example: My App (using aisstream.io)

image

Example: Marinetraffic.com (Has additional position data that I do not)

image
import 'dart:async';
import 'dart:convert';
import 'package:chartr/models/ais_position_report.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

class AisService {
  final StreamController<AisShipPosition> _controller =
      StreamController.broadcast();
  late WebSocketChannel channel;

  final String aisApiKey = dotenv.env['AIS_API_KEY'] ?? "";
  final List<double> topLeft = [-30, 160];
  final List<double> bottomRight = [-50, 180];

  AisService() {
    if (aisApiKey == "") {
      throw Exception("AIS_API_KEY is unset");
    }

    channel = WebSocketChannel.connect(
      Uri.parse('wss://stream.aisstream.io/v0/stream'),
    );

    final Map<String, dynamic> subscriptionMessage = {
      'Apikey': aisApiKey,
      'BoundingBoxes': [
        [topLeft, bottomRight]
      ],
      'FilterMessageTypes': ['PositionReport', 'StandardClassBPositionReport', 'ExtendedClassBPositionReport'],
    };

    channel.sink.add(jsonEncode(subscriptionMessage));

    channel.stream.listen((event) {
      String data = event is String ? event : String.fromCharCodes(event);
      Map<String, dynamic> parsedData = jsonDecode(data);

      var positionReport = AisShipPosition.fromJson(parsedData);

      print("Received AIS message:");
      print(positionReport.toString());

      _controller.add(positionReport);
    });
  }

  Stream<AisShipPosition> get stream => _controller.stream;

  void close() {
    channel.sink.close();
    _controller.close();
  }
}
aisstream commented 1 year ago

Just a quick answer to your comparison with MarineTraffic. Marinetraffic will have significantly better coverage than aisstream.io. They include both satellite and ground AIS where we do not ingest satellite nor have as complete ground coverage as them.

mttchpmn commented 1 year ago

Ah okay. Thanks for your answer. Are there plans to implement support for satellite / ground in future? Would love to collaborate if you're looking for contributors

ALROCHARARI commented 1 year ago

Are these boats not boats under 43 foot. If yes, see other reported issue.

julidbaper commented 7 months ago

Hi, may I ask if there are plans to increase the coverage (to include satellite and/or additional ground stations) for this stream since the previous answer provided in Aug 2023? Thanks for this stream, it has made AIS data much more readily accessible