Search in sources :

Example 21 with Listing

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;
}
Also used : Listing(org.wikivoyage.listings.entity.Listing) NoSuchElementException(java.util.NoSuchElementException)

Example 22 with Listing

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();
    }
}
Also used : Listing(org.wikivoyage.listings.entity.Listing) FileOutputStream(java.io.FileOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 23 with Listing

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;
}
Also used : XMLSimpleNode(org.wikivoyage.listings.utils.XMLSimpleNode) Listing(org.wikivoyage.listings.entity.Listing)

Example 24 with Listing

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;
}
Also used : WikidataValidator(org.wikivoyage.listings.validators.WikidataValidator) EmailValidator(org.wikivoyage.listings.validators.EmailValidator) Listing(org.wikivoyage.listings.entity.Listing) LatitudeValidator(org.wikivoyage.listings.validators.LatitudeValidator) WebsiteURLValidator(org.wikivoyage.listings.validators.WebsiteURLValidator) LongitudeValidator(org.wikivoyage.listings.validators.LongitudeValidator) LongitudeValidator(org.wikivoyage.listings.validators.LongitudeValidator) WebsiteURLValidator(org.wikivoyage.listings.validators.WebsiteURLValidator) EmailValidator(org.wikivoyage.listings.validators.EmailValidator) LatitudeValidator(org.wikivoyage.listings.validators.LatitudeValidator) WikidataValidator(org.wikivoyage.listings.validators.WikidataValidator) Validator(org.wikivoyage.listings.validators.Validator)

Example 25 with Listing

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;
}
Also used : XMLSimpleNode(org.wikivoyage.listings.utils.XMLSimpleNode) Listing(org.wikivoyage.listings.entity.Listing)

Aggregations

Listing (org.wikivoyage.listings.entity.Listing)30 Test (org.junit.Test)16 XMLSimpleNode (org.wikivoyage.listings.utils.XMLSimpleNode)5 BufferedWriter (java.io.BufferedWriter)3 FileWriter (java.io.FileWriter)3 IOException (java.io.IOException)3 French (org.wikivoyage.listings.language.french.French)3 WebsiteURLValidator (org.wikivoyage.listings.validators.WebsiteURLValidator)3 LinkedList (java.util.LinkedList)2 EmailValidator (org.wikivoyage.listings.validators.EmailValidator)2 WikidataValidator (org.wikivoyage.listings.validators.WikidataValidator)2 FileOutputStream (java.io.FileOutputStream)1 ObjectOutputStream (java.io.ObjectOutputStream)1 ArrayList (java.util.ArrayList)1 NoSuchElementException (java.util.NoSuchElementException)1 ParserConfig (org.sweble.wikitext.parser.ParserConfig)1 WikitextPreprocessor (org.sweble.wikitext.parser.WikitextPreprocessor)1 WtNode (org.sweble.wikitext.parser.nodes.WtNode)1 SimpleParserConfig (org.sweble.wikitext.parser.utils.SimpleParserConfig)1 StringConversionException (org.sweble.wikitext.parser.utils.StringConversionException)1