use of org.wikivoyage.listings.utils.XMLSimpleNode in project wikivoyage-listings by baturin.
the class NavigationXMLOutputFormat method write.
@Override
public void write(Iterable<Listing> pois, String outputFilename, String dumpDate) throws WriteOutputException {
try {
LinkedList<Listing> filteredPois = new LinkedList<>();
for (Listing poi : pois) {
if (!poi.isPositionalDataEmpty()) {
// POIs with no positional data are useless for navigation - do not add them
// to reduce size of output file
filteredPois.add(poi);
}
}
Listing[] filteredPoisArr = filteredPois.toArray(new Listing[filteredPois.size()]);
XMLSimpleNode rootNode = createXml(filteredPoisArr, dumpDate);
rootNode.writeToFile(outputFilename);
} catch (XMLSimpleNodeException e) {
throw new WriteOutputException();
}
}
use of org.wikivoyage.listings.utils.XMLSimpleNode in project wikivoyage-listings by baturin.
the class OsmAndGPX method createXml.
@Override
public XMLSimpleNode createXml(Listing[] pois, String dumpDate) throws XMLSimpleNodeException {
XMLSimpleNode gpxNode = new XMLSimpleNode("gpx", dumpDate).attrib("version", "1.1").attrib("creator", "wikivoyage-pois-converter").attrib("xmlns", "http://www.topografix.com/GPX/1/1").attribNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation", "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
for (Listing poi : pois) {
String name = poi.getTitle() + " (" + poi.getArticle() + ", " + poi.getType() + ")";
new XMLSimpleNode(gpxNode, "wpt").attrib("lat", poi.getLatitude()).attrib("lon", poi.getLongitude()).textChild("name", name);
}
return gpxNode;
}
use of org.wikivoyage.listings.utils.XMLSimpleNode 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.utils.XMLSimpleNode 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;
}
use of org.wikivoyage.listings.utils.XMLSimpleNode in project wikivoyage-listings by baturin.
the class Xml method createXml.
public XMLSimpleNode createXml(Listing[] pois, String dumpDate) throws XMLSimpleNodeException {
XMLSimpleNode genericNode = new XMLSimpleNode("wikivoyage", dumpDate).attrib("version", "0.5").attrib("generator", "wikivoyage-pois-converter");
for (Listing poi : pois) {
XMLSimpleNode poiNode = new XMLSimpleNode(genericNode, "node").attrib("id", nodeId.toString()).attrib("article", poi.getArticle()).attrib("type", poi.getType()).attrib("title", poi.getTitle()).attrib("alt", poi.getAlt()).attrib("wikidata", poi.getWikidata()).attrib("wikipedia", poi.getWikipedia()).attrib("address", poi.getAddress()).attrib("directions", poi.getDirections()).attrib("phone", poi.getPhone()).attrib("tollFree", poi.getTollFree()).attrib("email", poi.getEmail()).attrib("fax", poi.getFax()).attrib("url", poi.getUrl()).attrib("lat", poi.getLatitude()).attrib("lon", poi.getLongitude()).attrib("hours", poi.getHours()).attrib("checkIn", poi.getCheckIn()).attrib("checkOut", poi.getCheckOut()).attrib("image", poi.getImage()).attrib("price", poi.getPrice()).attrib("wifi", poi.getWifi()).attrib("accessibility", poi.getAccessibility()).attrib("lastEdit", poi.getLastEdit()).attrib("description", poi.getDescription());
nodeId++;
}
return genericNode;
}
Aggregations