@Override
    public void generate(final Module module, final Element element) {
        // this is not necessary, it is done to avoid the namespace definition
        // in every item.
        Element root = element;
        while (root.getParent() != null && root.getParent() instanceof Element) {
            root = (Element) element.getParent();
        }
        root.addNamespaceDeclaration(GeoRSSModule.SIMPLE_NS);

        final GeoRSSModule geoRSSModule = (GeoRSSModule) module;

        final AbstractGeometry geometry = geoRSSModule.getGeometry();
        if (geometry instanceof Point) {
            final Position pos = ((Point) geometry).getPosition();

            final Element pointElement = new Element("point", GeoRSSModule.SIMPLE_NS);
            pointElement.addContent(pos.getLatitude() + " " + pos.getLongitude());
            element.addContent(pointElement);
        } else if (geometry instanceof LineString) {
            final PositionList posList = ((LineString) geometry).getPositionList();

            final Element lineElement = new Element("line", GeoRSSModule.SIMPLE_NS);

            lineElement.addContent(posListToString(posList));
            element.addContent(lineElement);
        } else if (geometry instanceof Polygon) {
            final AbstractRing ring = ((Polygon) geometry).getExterior();
            if (ring instanceof LinearRing) {
                final PositionList posList = ((LinearRing) ring).getPositionList();
                final Element polygonElement = new Element("polygon", GeoRSSModule.SIMPLE_NS);

                polygonElement.addContent(posListToString(posList));
                element.addContent(polygonElement);
            } else {
                LOG.error("GeoRSS simple format can't handle rings of type: " + ring.getClass().getName());
            }
            if (((Polygon) geometry).getInterior() != null && !((Polygon) geometry).getInterior().isEmpty()) {
                LOG.error("GeoRSS simple format can't handle interior rings (ignored)");
            }
        } else if (geometry instanceof Envelope) {
            final Envelope envelope = (Envelope) geometry;
            final Element boxElement = new Element("box", GeoRSSModule.SIMPLE_NS);
            boxElement.addContent(envelope.getMinLatitude() + " " + envelope.getMinLongitude() + " " + envelope.getMaxLatitude() + " "
                    + envelope.getMaxLongitude());
            element.addContent(boxElement);
        } else {
            LOG.error("GeoRSS simple format can't handle geometries of type: " + geometry.getClass().getName());
        }
    }
@ Override public void generate ( final Module module , final Element element ) { Element root = element ; while ( root . getParent ( ) != null && root . getParent ( ) instanceof Element ) { root = ( Element ) element . getParent ( ) ; } root . addNamespaceDeclaration ( GeoRSSModule . SIMPLE_NS ) ; final GeoRSSModule geoRSSModule = ( GeoRSSModule ) module ; final AbstractGeometry geometry = geoRSSModule . getGeometry ( ) ; if ( geometry instanceof Point ) { final Position pos = ( ( Point ) geometry ) . getPosition ( ) ; final Element pointElement = new Element ( "point" , GeoRSSModule . SIMPLE_NS ) ; pointElement . addContent ( pos . getLatitude ( ) + " " + pos . getLongitude ( ) ) ; element . addContent ( pointElement ) ; } else if ( geometry instanceof LineString ) { final PositionList posList = ( ( LineString ) geometry ) . getPositionList ( ) ; final Element lineElement = new Element ( "line" , GeoRSSModule . SIMPLE_NS ) ; lineElement . addContent ( posListToString ( posList ) ) ; element . addContent ( lineElement ) ; } else if ( geometry instanceof Polygon ) { final AbstractRing ring = ( ( Polygon ) geometry ) . getExterior ( ) ; if ( ring instanceof LinearRing ) { final PositionList posList = ( ( LinearRing ) ring ) . getPositionList ( ) ; final Element polygonElement = new Element ( "polygon" , GeoRSSModule . SIMPLE_NS ) ; polygonElement . addContent ( posListToString ( posList ) ) ; element . addContent ( polygonElement ) ; } else { LOG . error ( "GeoRSS simple format can't handle rings of type: " + ring . getClass ( ) . getName ( ) ) ; } if ( ( ( Polygon ) geometry ) . getInterior ( ) != null && ! ( ( Polygon ) geometry ) . getInterior ( ) . isEmpty ( ) ) { LOG . error ( "GeoRSS simple format can't handle interior rings (ignored)" ) ; } } else if ( geometry instanceof Envelope ) { final Envelope envelope = ( Envelope ) geometry ; final Element boxElement = new Element ( "box" , GeoRSSModule . SIMPLE_NS ) ; boxElement . addContent ( envelope . getMinLatitude ( ) + " " + envelope . getMinLongitude ( ) + " " + envelope . getMaxLatitude ( ) + " " + envelope . getMaxLongitude ( ) ) ; element . addContent ( boxElement ) ; } else { LOG . error ( "GeoRSS simple format can't handle geometries of type: " + geometry . getClass ( ) . getName ( ) ) ; } }
/*
(non-Javadoc)
@see com.rometools.rome.io.ModuleGenerator#generate(com.rometools.rome.feed.module.Module,
org.jdom2.Element)