private void refresh() throws IOException { _log.info("refreshing vehicle positions"); URL url = _vehiclePositionsUri.toURL(); FeedMessage feed = FeedMessage.parseFrom(url.openStream()); boolean hadUpdate = processDataset(feed); if (hadUpdate) { if (_dynamicRefreshInterval) { updateRefreshInterval(); } } _executor.schedule(_refreshTask, _refreshInterval, TimeUnit.SECONDS); }
try { in = urlConnection.getInputStream(); return FeedMessage.parseFrom(in, _registry); } catch (IOException ex) { _log.error("connection issue with url " + url + ", ex=" + ex);
public void setJsonFeedMessage(byte[] byteFeedMessage) { InputStream is = new ByteArrayInputStream(byteFeedMessage); GtfsRealtime.FeedMessage feedMessage = null; try { feedMessage = GtfsRealtime.FeedMessage.parseFrom(is); } catch (IOException e) { e.printStackTrace(); } this.jsonFeedMessage = JsonFormat.printToString(feedMessage); } }
GtfsRealtime.FeedMessage message; try { message = GtfsRealtime.FeedMessage.parseFrom(protobuf); } catch (InvalidProtocolBufferException e) { _log.error("Error reading GTFS-rt message from byte array, skipping to next file: " + e);
in = downloadChannelSftp.get(downloadFile.getName()); return FeedMessage.parseFrom(in, _registry); } catch (JSchException ex) { _log.error("connection issue with sftp url " + url);
feedMessage = FeedMessage.parseFrom(codedStream); logger.info("Parsing GTFS-realtime file into a FeedMessage took " + "{} msec", timer.elapsedMsec());
/** * Gets GTFS realtime feed all routes from URL and return FeedMessage * * @return the FeedMessage to be processed */ private FeedMessage getExternalPredictions() { // Will just read all data from gtfs-rt url URL url=null; logger.info("Getting predictions from API using URL={}", getGtfstripupdateurl().getValue()); try { // Create the connection url = new URL(getGtfstripupdateurl().getValue()); FeedMessage feed = FeedMessage.parseFrom(url.openStream()); logger.info("Prediction read successfully from URL={}",getGtfstripupdateurl().getValue()); return feed; } catch (Exception e) { logger.error("Problem when getting data from GTFS realtime trip updates URL={}", url, e); return null; } }
public void setFeedprotobuf(byte[] feedprotobuf) { String s = ""; if (feedprotobuf == null) { return; } try { GtfsRealtime.FeedMessage feedMessage = GtfsRealtime.FeedMessage.parseFrom(feedprotobuf); s = JsonFormat.printToString(feedMessage); s.replace('\\', ' '); } catch (InvalidProtocolBufferException e) { e.printStackTrace(); } this.feedprotobuf = s; } }
private FeedMessage parseMessage(byte[] buf) { try { return FeedMessage.parseFrom(buf); } catch (InvalidProtocolBufferException ex) { throw new IllegalStateException(ex); } } }