本文整理匯總了Java中com.rometools.modules.georss.GeoRSSUtils類的典型用法代碼示例。如果您正苦於以下問題:Java GeoRSSUtils類的具體用法?Java GeoRSSUtils怎麽用?Java GeoRSSUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GeoRSSUtils類屬於com.rometools.modules.georss包,在下文中一共展示了GeoRSSUtils類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: assertTestInputStream
import com.rometools.modules.georss.GeoRSSUtils; //導入依賴的package包/類
/**
* test expected latitude and longitude values in items of test file.
*
* @param in testfeed
* @param expectedLat expected latitude values
* @param expectedLng expected longitude values
* @throws Exception if file not found or not accessible
*/
private void assertTestInputStream(final InputStream in, final Double[] expectedLat, final Double[] expectedLng) throws Exception {
final SyndFeedInput input = new SyndFeedInput();
final SyndFeed feed = input.build(new XmlReader(in));
final List<SyndEntry> entries = feed.getEntries();
for (int i = 0; i < entries.size(); i++) {
final SyndEntry entry = entries.get(i);
final GeoRSSModule geoRSSModule = GeoRSSUtils.getGeoRSS(entry);
final Position position = geoRSSModule.getPosition();
if (expectedLat[i] == null || expectedLng[i] == null) {
assertNull("position " + i, position);
} else {
assertEquals("lat " + i, expectedLat[i], position.getLatitude(), DELTA);
assertEquals("lng " + i, expectedLng[i], position.getLongitude(), DELTA);
}
}
}
示例2: load
import com.rometools.modules.georss.GeoRSSUtils; //導入依賴的package包/類
/**
* Check a RSS flow from an URL
*
* @param dataProducer {@link IDataProducer} contains the data queue
* @see WeatherProducerConnector#source
* @see WeatherProducerConnector#METRICS_LOGGER
*/
@Override
public void load(IDataProducer dataProducer) {
Objects.requireNonNull(dataProducer);
while (!Thread.currentThread().isInterrupted()) {
try {
SyndFeedInput input = new SyndFeedInput(false, Locale.FRANCE);
XmlReader reader = new XmlReader(url);
SyndFeed feed = input.build(reader);
long start = System.currentTimeMillis();
feed.getEntries().forEach(entry -> {
Date date = entry.getPublishedDate();
String description = entry.getDescription().getValue();
GeoRSSModule module = GeoRSSUtils.getGeoRSS(entry);
if (date == null) {
date = Date.from(Instant.now());
}
if (description == null) {
description = "no description";
}
if (module != null && module.getPosition() != null) {
LatLong latLong = new LatLong(module.getPosition().getLatitude(), module.getPosition().getLongitude());
Event event = new Event(latLong, date, date, description, source);
dataProducer.push(event);
long end = System.currentTimeMillis();
long result = end - start;
METRICS_LOGGER.log("time_process_" + this.source, result);
LOGGER.info("Event " + event + " has been pushed");
}
});
} catch (IOException | FeedException e) {
LOGGER.error(e.getMessage());
return;
}
}
}