Revision 1755 branches/FMap_SLD/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/PostGisGeometryIterator.java

View differences:

PostGisGeometryIterator.java
45 45

  
46 46
import java.sql.ResultSet;
47 47
import java.sql.SQLException;
48
import java.sql.Statement;
48 49

  
49 50
import com.iver.cit.gvsig.fmap.core.IGeometry;
51
import com.iver.cit.gvsig.fmap.drivers.WKBParser;
50 52
import com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator;
51 53
import com.vividsolutions.jts.io.ParseException;
52 54

  
......
57 59
 * Window - Preferences - Java - Code Generation - Code and Comments
58 60
 */
59 61
public class PostGisGeometryIterator implements GeometryIterator {
60
    private WKTParser parser = new WKTParser();
62
    private WKBParser parser = new WKBParser();
61 63
    ResultSet rs;
64
    Statement st;
62 65
    String strAux;
63 66
    IGeometry geom;
64 67
    /**
......
74 77
     * @see com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator#hasNext()
75 78
     */
76 79
    public boolean hasNext() throws SQLException {
77
        if (rs.isAfterLast())
80
        try
78 81
        {
79
            rs.close();
80
            return false;
82
	        if (rs.isAfterLast())
83
	        {            
84
	            rs.close();
85
	            return false;
86
	        }
87
	        else
88
	            return true;
81 89
        }
82
        else
83
            return true;
90
        catch (Exception e)
91
        {
92
            e.printStackTrace();
93
        }
94
        return false;
84 95
    }
85 96

  
86 97
    /* (non-Javadoc)
......
88 99
     */
89 100
    public IGeometry next() throws SQLException {
90 101
        rs.next();
91
        strAux = rs.getString(1);	        
92
        try {
93
            geom = parser.read(strAux);
94
        } catch (ParseException e) {
95
            // TODO Auto-generated catch block
96
            e.printStackTrace();
97
        }                
102
        byte[] data = rs.getBytes(1);	        
103
        geom = parser.parse(data);
98 104
        return geom;
99 105
    }
100 106

  

Also available in: Unified diff