本文整理汇总了Java中dk.dma.ais.reader.AisReaders.createReaderFromInputStream方法的典型用法代码示例。如果您正苦于以下问题:Java AisReaders.createReaderFromInputStream方法的具体用法?Java AisReaders.createReaderFromInputStream怎么用?Java AisReaders.createReaderFromInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dk.dma.ais.reader.AisReaders
的用法示例。
在下文中一共展示了AisReaders.createReaderFromInputStream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doesNotDetectStocMarciasDriftOnOct02_2014
import dk.dma.ais.reader.AisReaders; //导入方法依赖的package包/类
@Test
public void doesNotDetectStocMarciasDriftOnOct02_2014() {
Tracker tracker = injector.getInstance(EventEmittingTracker.class);
EventRepository eventRepository = injector.getInstance(EventRepository.class);
InputStream testDataStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("ais/212123000_drift_1.ais");
AisReader aisReader = AisReaders.createReaderFromInputStream(testDataStream);
context.checking(new Expectations() {{
never(eventRepository).findOngoingEventByVessel(212123000, DriftEvent.class);
never(eventRepository).save(with(any(DriftEvent.class)));
}});
driftAnalysis.start();
aisReader.registerPacketHandler(aisPacket -> {
tracker.update(aisPacket);
});
aisReader.run();
context.assertIsSatisfied();
}
示例2: detectsFriosDriftOnSep28_2014
import dk.dma.ais.reader.AisReaders; //导入方法依赖的package包/类
@Test
public void detectsFriosDriftOnSep28_2014() {
Tracker tracker = injector.getInstance(EventEmittingTracker.class);
EventRepository eventRepository = injector.getInstance(EventRepository.class);
InputStream testDataStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("ais/538004030_drift_1.ais");
AisReader aisReader = AisReaders.createReaderFromInputStream(testDataStream);
final ArgumentCaptor<DriftEvent> eventCaptor = ArgumentCaptor.forClass(DriftEvent.class);
context.checking(new Expectations() {{
atLeast(1).of(eventRepository).findOngoingEventByVessel(538004030, DriftEvent.class);
atLeast(1).of(eventRepository).save(with(eventCaptor.getMatcher()));
}});
driftAnalysis.start();
aisReader.registerPacketHandler(aisPacket -> {
tracker.update(aisPacket);
});
aisReader.run();
context.assertIsSatisfied();
assertTrue(eventCaptor.getCapturedObject().getDescription().startsWith("FRIO is drifting"));
assertEquals(MILLIS_TO_LOCALDATETIME_UTC.apply(1411923004556L), eventCaptor.getCapturedObject().getStartTime());
}
示例3: canDetectLotusSuddenSpeedChangeOnOct05_2014
import dk.dma.ais.reader.AisReaders; //导入方法依赖的package包/类
@Test
public void canDetectLotusSuddenSpeedChangeOnOct05_2014() {
Tracker tracker = injector.getInstance(EventEmittingTracker.class);
EventRepository eventRepository = injector.getInstance(EventRepository.class);
InputStream testDataStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("ais/219165000_ssc_1.ais");
AisReader aisReader = AisReaders.createReaderFromInputStream(testDataStream);
final ArgumentCaptor<SuddenSpeedChangeEvent> eventCaptor = ArgumentCaptor.forClass(SuddenSpeedChangeEvent.class);
context.checking(new Expectations() {{
atLeast(1).of(eventRepository).findOngoingEventByVessel(219165000, SuddenSpeedChangeEvent.class);
atLeast(1).of(eventRepository).save(with(eventCaptor.getMatcher()));
}});
analysis.start();
aisReader.registerPacketHandler(aisPacket -> {
tracker.update(aisPacket);
});
aisReader.run();
context.assertIsSatisfied();
assertTrue(eventCaptor.getCapturedObject().getDescription().startsWith("Sudden speed change of LOTUS"));
assertEquals(LocalDateTime.ofInstant(Instant.ofEpochMilli(1412525411424L), ZoneOffset.UTC), eventCaptor.getCapturedObject().getStartTime());
}
示例4: createKml
import dk.dma.ais.reader.AisReaders; //导入方法依赖的package包/类
/**
* Produce KML output for POSTed AIS data in NMEA format.
*
* Use 'curl -X POST -T <ais-data-file> http://127.0.0.1:8090/store/history/kml' to test
* Or with expression filter:
* 'curl -X POST -T <ais-data-file> http://127.0.0.1:8090/store/history/kml?filter="m.mmsi=247469000" > test.kmz'
*/
@POST
@Path("/history/kml")
@Produces(MEDIA_TYPE_KMZ)
public Response createKml(@QueryParam("filter") String filterExpression, InputStream inputStream) {
LOG.debug("Filter expression: " + filterExpression);
Predicate<AisPacket> filter = isBlank(filterExpression) ? p->true : AisPacketFilters.parseExpressionFilter(filterExpression);
ArrayList<AisPacket> packets = new ArrayList<>();
AisReader reader = AisReaders.createReaderFromInputStream(inputStream);
reader.registerPacketHandler(
aisPacket -> { if (filter.test(aisPacket)) packets.add(aisPacket); }
);
reader.start();
try {
reader.join();
} catch (InterruptedException e) {
LOG.error(e.getMessage(), e);
return Response.serverError().build();
}
StreamingOutput output = StreamingUtil.createZippedStreamingOutput(packets, AisPacketOutputSinks.newKmlSink(), "history.kml");
return Response
.ok()
.entity(output)
.type(MEDIA_TYPE_KMZ).build();
}