Revision 8913 branches/v10/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/testPostGis.java
testPostGis.java | ||
---|---|---|
97 | 97 |
System.exit(1); */ |
98 | 98 |
|
99 | 99 |
|
100 |
String dburl = "jdbc:postgresql://localhost/latin1"; |
|
101 |
String dbuser = "postgres"; |
|
102 |
String dbpass = "aquilina"; |
|
100 |
// String dburl = "jdbc:postgresql://localhost/latin1"; |
|
101 |
// String dbuser = "postgres"; |
|
102 |
// String dbpass = "aquilina"; |
|
103 |
|
|
104 |
String dburl = "jdbc:postgresql://192.168.0.217/postgis"; |
|
105 |
String dbuser = "gvsig"; |
|
106 |
String dbpass = ""; |
|
107 |
|
|
103 | 108 |
|
104 |
String dbtable = "reservados2";
|
|
109 |
String dbtable = "carreteras_lin_5k_t10";
|
|
105 | 110 |
|
106 | 111 |
Connection conn = null; |
107 | 112 |
System.out.println("Creating JDBC connection..."); |
... | ... | |
163 | 168 |
*/ |
164 | 169 |
// String strSQL = "select AsBinary(the_geom) as geom, nom_provin from " + dbtable; |
165 | 170 |
// String strSQL = "select ASBINARY(the_geom) as geom, gid from " + dbtable; |
166 |
String strSQL = "select ASBINARY(geometria) as geom, fecha_inicio_evento, fecha_fin_evento, date1, time1 from " + dbtable; |
|
171 |
// String strSQL = "select ASBINARY(geometria) as geom, fecha_inicio_evento, fecha_fin_evento, date1, time1 from " + dbtable; |
|
172 |
String strSQL = "select ASBINARY(the_geom) as geom from " + dbtable; |
|
167 | 173 |
// strSQL = "select ASTEXT(the_geom), nom_provin as geom from " + dbtable; |
168 | 174 |
/* String strSQL = "SELECT gid, rd_3, rd_5, rd_6, rd_10, rd_11, rd_12, rd_13, rd_14,"; |
169 | 175 |
strSQL = strSQL + " rd_15, rd_16, kilometers, cost, metros, AsText(force_2d(the_geom)) FROM vias"; |
... | ... | |
216 | 222 |
* Print things out. |
217 | 223 |
*/ |
218 | 224 |
// Object obj = r.getObject(2); |
219 |
// byte[] arrayByte = r.getBytes(1);
|
|
225 |
byte[] arrayByte = r.getBytes(1); |
|
220 | 226 |
|
221 | 227 |
// IGeometry gp = parser.parse(arrayByte); |
222 |
// IGeometry gp2 = parser2.parse(arrayByte);
|
|
228 |
IGeometry gp2 = parser2.parse(arrayByte); |
|
223 | 229 |
|
224 |
String strAux = r.getString(5); |
|
225 |
System.out.println("Straux = " + strAux); |
|
230 |
// String strAux = r.getString(5);
|
|
231 |
// System.out.println("Straux = " + strAux);
|
|
226 | 232 |
// long asLong = r.getLong(2); |
227 | 233 |
// double asDouble = r.getDouble(2); |
228 | 234 |
// Date asDate = r.getDate(2); |
229 |
byte[] data1 = r.getBytes(2); |
|
230 |
byte[] data2 = r.getBytes(3); |
|
231 |
byte[] bdate1 = r.getBytes(4); |
|
232 |
byte[] btime1 = r.getBytes(5); |
|
233 |
ByteBuffer buf = ByteBuffer.wrap(data1); |
|
234 |
ByteBuffer bufDate1 = ByteBuffer.wrap(bdate1); |
|
235 |
ByteBuffer bufTime1 = ByteBuffer.wrap(btime1); |
|
236 |
|
|
237 |
long daysAfter2000 = bufDate1.getInt() + 1; |
|
238 |
long msecs = daysAfter2000*24*60*60*1000; |
|
239 |
long real_msecs_date1 = (long) (num_msSecs2000 + msecs); |
|
240 |
Date realDate1 = new Date(real_msecs_date1); |
|
241 |
System.err.println("Date1 = " + realDate1 + " diff = " + (real_msecs_date1 - num_msSecs2000)); |
|
242 |
|
|
243 |
Calendar cal = new GregorianCalendar(); |
|
244 |
cal.setTimeInMillis(0); |
|
245 |
// bufTime1.order(ByteOrder.LITTLE_ENDIAN); |
|
246 |
long microsecs = bufTime1.getLong(); |
|
247 |
long real_msecs = microsecs - 3600000; // le quitamos una hora. |
|
248 |
cal.setTimeInMillis(real_msecs); |
|
249 |
long milis = cal.getTimeInMillis(); |
|
250 |
Time mytime1 = new Time(real_msecs); |
|
251 |
Date mytime1asdate = new Date(real_msecs); |
|
252 |
System.err.println("microsecs = " + microsecs + " TIME1 = " + mytime1); |
|
253 |
System.err.println("microsecs = " + (long)num_msSecs2000 + " TIME1ASDATE = " + mytime1asdate); |
|
254 |
|
|
255 |
|
|
256 |
double n1 = buf.getDouble(0); // num segs after 2000 |
|
257 |
// Timestamp ts2000 = new Timestamp(2000-1900, 0, 1, 0, 0 , 0, 0); |
|
258 |
// int offset = ts2000.getTimezoneOffset() * 60 * 1000; |
|
259 |
|
|
260 |
// double num_msSecs2000 = ts2000.getTime() + offset; |
|
261 |
long real_msecs2 = (long) (num_msSecs2000 + n1*1000); |
|
262 |
Timestamp real = new Timestamp(real_msecs2); |
|
263 |
|
|
264 |
// int id = r.getInt(2); |
|
265 |
System.out.println("Fila " + id + ": fecha:" + real); |
|
266 |
id++; |
|
267 |
// Geometry regeom = PGgeometry.geomFromString(obj.toString()); |
|
268 |
|
|
269 |
// PGgeometry geom = (PGgeometry)obj; |
|
270 |
// int id = r.getInt(2); |
|
271 |
// System.out.println("Row " + id + ":" + strAux); |
|
272 |
// System.out.println(geom.toString()); |
|
273 |
// System.out.println("provin=" + r.getString(2)); |
|
274 |
/* if ((id % fetchSize) == 0) |
|
275 |
{ |
|
276 |
r = s.executeQuery("fetch forward " + fetchSize + " in wkb_cursor"); |
|
277 |
} */ |
|
235 |
// byte[] data1 = r.getBytes(2);
|
|
236 |
// byte[] data2 = r.getBytes(3);
|
|
237 |
// byte[] bdate1 = r.getBytes(4);
|
|
238 |
// byte[] btime1 = r.getBytes(5);
|
|
239 |
// ByteBuffer buf = ByteBuffer.wrap(data1);
|
|
240 |
// ByteBuffer bufDate1 = ByteBuffer.wrap(bdate1);
|
|
241 |
// ByteBuffer bufTime1 = ByteBuffer.wrap(btime1);
|
|
242 |
// |
|
243 |
// long daysAfter2000 = bufDate1.getInt() + 1;
|
|
244 |
// long msecs = daysAfter2000*24*60*60*1000;
|
|
245 |
// long real_msecs_date1 = (long) (num_msSecs2000 + msecs);
|
|
246 |
// Date realDate1 = new Date(real_msecs_date1);
|
|
247 |
// System.err.println("Date1 = " + realDate1 + " diff = " + (real_msecs_date1 - num_msSecs2000));
|
|
248 |
// |
|
249 |
// Calendar cal = new GregorianCalendar();
|
|
250 |
// cal.setTimeInMillis(0);
|
|
251 |
// // bufTime1.order(ByteOrder.LITTLE_ENDIAN);
|
|
252 |
// long microsecs = bufTime1.getLong();
|
|
253 |
// long real_msecs = microsecs - 3600000; // le quitamos una hora.
|
|
254 |
// cal.setTimeInMillis(real_msecs);
|
|
255 |
// long milis = cal.getTimeInMillis();
|
|
256 |
// Time mytime1 = new Time(real_msecs);
|
|
257 |
// Date mytime1asdate = new Date(real_msecs);
|
|
258 |
// System.err.println("microsecs = " + microsecs + " TIME1 = " + mytime1);
|
|
259 |
// System.err.println("microsecs = " + (long)num_msSecs2000 + " TIME1ASDATE = " + mytime1asdate);
|
|
260 |
// |
|
261 |
// |
|
262 |
// double n1 = buf.getDouble(0); // num segs after 2000
|
|
263 |
//// Timestamp ts2000 = new Timestamp(2000-1900, 0, 1, 0, 0 , 0, 0);
|
|
264 |
//// int offset = ts2000.getTimezoneOffset() * 60 * 1000;
|
|
265 |
// |
|
266 |
//// double num_msSecs2000 = ts2000.getTime() + offset;
|
|
267 |
// long real_msecs2 = (long) (num_msSecs2000 + n1*1000);
|
|
268 |
// Timestamp real = new Timestamp(real_msecs2);
|
|
269 |
// |
|
270 |
// // int id = r.getInt(2);
|
|
271 |
// System.out.println("Fila " + id + ": fecha:" + real);
|
|
272 |
// id++;
|
|
273 |
// // Geometry regeom = PGgeometry.geomFromString(obj.toString());
|
|
274 |
// |
|
275 |
// // PGgeometry geom = (PGgeometry)obj;
|
|
276 |
// // int id = r.getInt(2);
|
|
277 |
// // System.out.println("Row " + id + ":" + strAux);
|
|
278 |
// // System.out.println(geom.toString());
|
|
279 |
// // System.out.println("provin=" + r.getString(2));
|
|
280 |
// /* if ((id % fetchSize) == 0)
|
|
281 |
// {
|
|
282 |
// r = s.executeQuery("fetch forward " + fetchSize + " in wkb_cursor");
|
|
283 |
// } */
|
|
278 | 284 |
|
279 | 285 |
} |
280 | 286 |
// s.execute("end"); |
Also available in: Unified diff