use of org.wikivoyage.listings.entity.Listing in project wikivoyage-listings by baturin.
the class DumpListingsIterator method next.
@Override
public Listing next() {
Listing result = currentListing;
if (currentListing == null) {
throw new NoSuchElementException();
}
getNext();
return result;
}
use of org.wikivoyage.listings.entity.Listing in project wikivoyage-listings by baturin.
the class JavaSerializedObject method write.
@Override
public void write(Iterable<Listing> pois, String outputFilename, String dumpDate) throws WriteOutputException {
try {
for (Listing poi : pois) {
FileOutputStream fos = new FileOutputStream(outputFilename, true);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeUnshared(poi);
oos.close();
fos.close();
}
} catch (Exception e) {
System.out.println(e.getMessage());
throw new WriteOutputException();
}
}
use of org.wikivoyage.listings.entity.Listing in project wikivoyage-listings by baturin.
the class KML method createXml.
@Override
public XMLSimpleNode createXml(Listing[] pois, String dumpDate) throws XMLSimpleNodeException {
XMLSimpleNode kmlNode = new XMLSimpleNode("kml", dumpDate).attrib("xmlns", "http://www.opengis.net/kml/2.2");
XMLSimpleNode documentNode = new XMLSimpleNode(kmlNode, "Document");
for (Listing poi : pois) {
XMLSimpleNode placemarkNode = new XMLSimpleNode(documentNode, "Placemark");
placemarkNode.textChild("name", poi.getTitle());
placemarkNode.textChild("description", poi.getDescription());
XMLSimpleNode pointNode = new XMLSimpleNode(placemarkNode, "Point");
pointNode.textChild("coordinates", poi.getLongitude() + "," + poi.getLatitude());
}
return kmlNode;
}
use of org.wikivoyage.listings.entity.Listing in project wikivoyage-listings by baturin.
the class Main method validate.
private static Iterable<Listing> validate(Iterable<Listing> listingIterable) {
Iterable<Listing> validatedIterable = listingIterable;
Validator[] validators = { new LatitudeValidator(), new LongitudeValidator(), new WebsiteURLValidator(), new EmailValidator(), new WikidataValidator() };
for (Validator validator : validators) {
validatedIterable = validator.validate(validatedIterable);
}
return validatedIterable;
}
use of org.wikivoyage.listings.entity.Listing in project wikivoyage-listings by baturin.
the class OsmXml method createXml.
public XMLSimpleNode createXml(Listing[] pois, String dumpDate) throws XMLSimpleNodeException {
XMLSimpleNode osmNode = new XMLSimpleNode("osm", dumpDate).attrib("version", "0.5").attrib("generator", "wikivoyage-pois-converter");
for (Listing poi : pois) {
XMLSimpleNode poiNode = new XMLSimpleNode(osmNode, "node").attrib("id", nodeId.toString()).attrib("visible", "true").attrib("lat", poi.getLatitude()).attrib("lon", poi.getLongitude());
nodeId++;
if (!userDefined) {
addTagNode(poiNode, "wikivoyage", poi.getType());
} else {
addTagNode(poiNode, "user_defined", "user_defined");
}
addTagNode(poiNode, "name", poi.getTitle());
addTagNode(poiNode, "description", poi.getDescription());
}
return osmNode;
}
Aggregations