Revision 1957
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/DXFMemoryDriver.java | ||
---|---|---|
401 | 401 |
return attr; |
402 | 402 |
} |
403 | 403 |
|
404 |
/** |
|
405 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
|
406 |
*/ |
|
407 |
public int[] getPrimaryKeys() throws DriverException { |
|
408 |
return null; |
|
409 |
} |
|
410 |
|
|
404 | 411 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/gvs/GVSDriver.java | ||
---|---|---|
254 | 254 |
// TODO Auto-generated method stub |
255 | 255 |
return 0; |
256 | 256 |
} |
257 |
|
|
258 |
/** |
|
259 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
|
260 |
*/ |
|
261 |
public int[] getPrimaryKeys() throws DriverException { |
|
262 |
// TODO Auto-generated method stub |
|
263 |
return null; |
|
264 |
} |
|
257 | 265 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/jdbc/hsqldb/HSQLDBDriver.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 04-mar-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.fmap.drivers.jdbc.hsqldb; |
|
45 |
|
|
46 |
import java.awt.geom.Rectangle2D; |
|
47 |
import java.sql.Connection; |
|
48 |
import java.sql.ResultSet; |
|
49 |
import java.sql.SQLException; |
|
50 |
import java.sql.Statement; |
|
51 |
|
|
52 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
53 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
54 |
import com.iver.cit.gvsig.fmap.drivers.DefaultDBDriver; |
|
55 |
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes; |
|
56 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.WKBParser; |
|
58 |
import com.vividsolutions.jts.io.ParseException; |
|
59 |
|
|
60 |
/** |
|
61 |
* @author FJP |
|
62 |
* |
|
63 |
* TODO To change the template for this generated type comment go to |
|
64 |
* Window - Preferences - Java - Code Generation - Code and Comments |
|
65 |
*/ |
|
66 |
public class HSQLDBDriver extends DefaultDBDriver { |
|
67 |
private WKBParser parser = new WKBParser(); |
|
68 |
/* private int fetch_min=-1; |
|
69 |
private int fetch_max=-1; */ |
|
70 |
private Statement st; |
|
71 |
private Rectangle2D fullExtent = null; |
|
72 |
private String strAux; |
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* |
|
77 |
*/ |
|
78 |
public HSQLDBDriver() { |
|
79 |
} |
|
80 |
/* (non-Javadoc) |
|
81 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDriver#getDriverAttributes() |
|
82 |
*/ |
|
83 |
public DriverAttributes getDriverAttributes() { |
|
84 |
return null; |
|
85 |
} |
|
86 |
|
|
87 |
/* (non-Javadoc) |
|
88 |
* @see com.hardcode.driverManager.Driver#getName() |
|
89 |
*/ |
|
90 |
public String getName() { |
|
91 |
return "HSQLDB Driver"; |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int) |
|
96 |
*/ |
|
97 |
public IGeometry getShape(int index) { |
|
98 |
IGeometry geom = null; |
|
99 |
boolean resul; |
|
100 |
try { |
|
101 |
// EL ABSOLUTE NO HACE QUE SE VUELVAN A LEER LAS |
|
102 |
// FILAS, ASI QUE MONTAMOS ESTA HISTORIA PARA QUE |
|
103 |
// LO HAGA |
|
104 |
// System.out.println("getShape " + index); |
|
105 |
/* if (index < fetch_min) |
|
106 |
{ |
|
107 |
rs.close(); |
|
108 |
|
|
109 |
rs = st.executeQuery(sqlOrig); |
|
110 |
fetch_min = 0; |
|
111 |
fetch_max = rs.getFetchSize(); |
|
112 |
} |
|
113 |
while (index >= fetch_max) |
|
114 |
{ |
|
115 |
rs.last(); |
|
116 |
// forzamos una carga |
|
117 |
rs.next(); |
|
118 |
fetch_min = fetch_max; |
|
119 |
fetch_max = fetch_max + rs.getFetchSize(); |
|
120 |
// System.out.println("fetchSize = " + rs.getFetchSize() + " " + fetch_min + "-" + fetch_max); |
|
121 |
} |
|
122 |
rs.absolute(index+1 - fetch_min); */ |
|
123 |
rs.absolute(index+1); |
|
124 |
// strAux = rs.getString(1); |
|
125 |
// geom = parser.read(strAux); |
|
126 |
byte[] data = rs.getBytes(1); |
|
127 |
geom = parser.parse(data); |
|
128 |
|
|
129 |
|
|
130 |
} catch (SQLException e) { |
|
131 |
e.printStackTrace(); |
|
132 |
} |
|
133 |
|
|
134 |
return geom; |
|
135 |
} |
|
136 |
/** |
|
137 |
* @param conn |
|
138 |
* @param tableName |
|
139 |
* @param fields OJO: EL PRIMER CAMPO HA DE SER EL DE GEOMETRIA |
|
140 |
* @param whereClause |
|
141 |
*/ |
|
142 |
public void setData(Connection conn, String tableName, String fields, String whereClause, int id_FID_field) |
|
143 |
{ |
|
144 |
this.conn = conn; |
|
145 |
this.tableName = tableName; |
|
146 |
this.fields = fields; |
|
147 |
this.whereClause = whereClause; |
|
148 |
this.sqlOrig = "SELECT " + fields + " FROM " + tableName + " " + whereClause; |
|
149 |
this.idFID_FieldName = id_FID_field; |
|
150 |
try { |
|
151 |
st = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); |
|
152 |
rs = st.executeQuery(sqlOrig); |
|
153 |
metaData = rs.getMetaData(); |
|
154 |
// Le pegamos un primera pasada para poder relacionar |
|
155 |
// un campo de identificador ?nico (parecido al OID en |
|
156 |
// postgresql) con el ?ndice dentro del recordset. |
|
157 |
// Esto cuando haya ediciones, no es v?lido, y hay |
|
158 |
// que refrescarlo. |
|
159 |
doRelateID_FID(); |
|
160 |
|
|
161 |
} catch (SQLException e) { |
|
162 |
// TODO Auto-generated catch block |
|
163 |
e.printStackTrace(); |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getFullExtent() |
|
169 |
*/ |
|
170 |
public Rectangle2D getFullExtent(){ |
|
171 |
if (fullExtent == null) |
|
172 |
{ |
|
173 |
try |
|
174 |
{ |
|
175 |
IFeatureIterator itGeom = getFeatureIterator("SELECT the_geom AS the_geom FROM " + tableName); |
|
176 |
IGeometry geom; |
|
177 |
int cont = 0; |
|
178 |
while (itGeom.hasNext()) |
|
179 |
{ |
|
180 |
geom = itGeom.next().getGeometry(); |
|
181 |
if (cont==0) |
|
182 |
fullExtent = geom.getBounds2D(); |
|
183 |
else |
|
184 |
fullExtent.add(geom.getBounds2D()); |
|
185 |
cont++; |
|
186 |
} |
|
187 |
} |
|
188 |
catch (SQLException e) |
|
189 |
{ |
|
190 |
System.err.println(e.getMessage()); |
|
191 |
} catch (DriverException e) { |
|
192 |
// TODO Auto-generated catch block |
|
193 |
e.printStackTrace(); |
|
194 |
} |
|
195 |
|
|
196 |
} |
|
197 |
return fullExtent; |
|
198 |
} |
|
199 |
/* (non-Javadoc) |
|
200 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver#getGeometryIterator(java.lang.String) |
|
201 |
*/ |
|
202 |
public IFeatureIterator getFeatureIterator(String sql) throws com.iver.cit.gvsig.fmap.DriverException { |
|
203 |
Statement st; |
|
204 |
HSQLDBFeatureIterator geomIterator = null; |
|
205 |
try { |
|
206 |
st = conn.createStatement(); |
|
207 |
// st.setFetchSize(2000); |
|
208 |
ResultSet rs = st.executeQuery(sql); |
|
209 |
geomIterator = new HSQLDBFeatureIterator(rs); |
|
210 |
} catch (SQLException e) { |
|
211 |
e.printStackTrace(); |
|
212 |
throw new com.iver.cit.gvsig.fmap.DriverException(e); |
|
213 |
} |
|
214 |
|
|
215 |
return geomIterator; |
|
216 |
} |
|
217 |
/* (non-Javadoc) |
|
218 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver#getGeometryIterator(java.awt.geom.Rectangle2D) |
|
219 |
*/ |
|
220 |
public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException { |
|
221 |
double xMin = r.getMinX(); |
|
222 |
double yMin = r.getMinY(); |
|
223 |
double xMax = r.getMaxX(); |
|
224 |
double yMax = r.getMaxY(); |
|
225 |
|
|
226 |
String wktBox = "GeomFromText('LINESTRING(" + xMin + " " + yMin + ", " |
|
227 |
+ xMax + " " + yMin + ", " |
|
228 |
+ xMax + " " + yMax + ", " |
|
229 |
+ xMin + " " + yMax + ")', " |
|
230 |
+ strEPSG + ")"; |
|
231 |
String sqlAux = sqlOrig; |
|
232 |
if (getWhereClause().startsWith("WHERE")) |
|
233 |
sqlAux += " 1=1" ; |
|
234 |
|
|
235 |
return getFeatureIterator(sqlAux); |
|
236 |
} |
|
237 |
public void open() { |
|
238 |
// TODO Auto-generated method stub |
|
239 |
|
|
240 |
} |
|
241 |
/** |
|
242 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver#getConnectionStringBeginning() |
|
243 |
*/ |
|
244 |
public String getConnectionStringBeginning() { |
|
245 |
return "jdbc:mysql:"; |
|
246 |
} |
|
247 |
|
|
248 |
static{ |
|
249 |
try { |
|
250 |
Class.forName("com.mysql.jdbc.Driver"); |
|
251 |
} catch (ClassNotFoundException e) { |
|
252 |
throw new RuntimeException(e); |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 |
/** |
|
257 |
* @see com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver#getGeometryField(java.lang.String) |
|
258 |
*/ |
|
259 |
public String getGeometryField(String fieldName) { |
|
260 |
return fieldName; |
|
261 |
} |
|
262 |
/** |
|
263 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
|
264 |
*/ |
|
265 |
public int[] getPrimaryKeys() throws com.hardcode.gdbms.engine.data.driver.DriverException { |
|
266 |
return null; |
|
267 |
} |
|
268 |
|
|
269 |
|
|
270 |
|
|
271 |
} |
|
0 | 272 |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/jdbc/hsqldb/HSQLDBFeatureIterator.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 11-mar-2005 |
|
3 |
* |
|
4 |
* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
5 |
* |
|
6 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
7 |
* |
|
8 |
* This program is free software; you can redistribute it and/or |
|
9 |
* modify it under the terms of the GNU General Public License |
|
10 |
* as published by the Free Software Foundation; either version 2 |
|
11 |
* of the License, or (at your option) any later version. |
|
12 |
* |
|
13 |
* This program is distributed in the hope that it will be useful, |
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 |
* GNU General Public License for more details. |
|
17 |
* |
|
18 |
* You should have received a copy of the GNU General Public License |
|
19 |
* along with this program; if not, write to the Free Software |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
21 |
* |
|
22 |
* For more information, contact: |
|
23 |
* |
|
24 |
* Generalitat Valenciana |
|
25 |
* Conselleria d'Infraestructures i Transport |
|
26 |
* Av. Blasco Ib??ez, 50 |
|
27 |
* 46010 VALENCIA |
|
28 |
* SPAIN |
|
29 |
* |
|
30 |
* +34 963862235 |
|
31 |
* gvsig@gva.es |
|
32 |
* www.gvsig.gva.es |
|
33 |
* |
|
34 |
* or |
|
35 |
* |
|
36 |
* IVER T.I. S.A |
|
37 |
* Salamanca 50 |
|
38 |
* 46005 Valencia |
|
39 |
* Spain |
|
40 |
* |
|
41 |
* +34 963163400 |
|
42 |
* dac@iver.es |
|
43 |
*/ |
|
44 |
package com.iver.cit.gvsig.fmap.drivers.jdbc.hsqldb; |
|
45 |
|
|
46 |
import java.sql.ResultSet; |
|
47 |
import java.sql.ResultSetMetaData; |
|
48 |
import java.sql.SQLException; |
|
49 |
import java.sql.Types; |
|
50 |
|
|
51 |
import com.hardcode.gdbms.engine.values.Value; |
|
52 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
53 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
|
54 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
55 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
56 |
import com.iver.cit.gvsig.fmap.drivers.IFeatureIterator; |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.WKBParser; |
|
58 |
|
|
59 |
/** |
|
60 |
* @author FJP |
|
61 |
* |
|
62 |
* TODO To change the template for this generated type comment go to |
|
63 |
* Window - Preferences - Java - Code Generation - Code and Comments |
|
64 |
*/ |
|
65 |
public class HSQLDBFeatureIterator implements IFeatureIterator { |
|
66 |
private WKBParser parser = new WKBParser(); |
|
67 |
ResultSet rs; |
|
68 |
String strAux; |
|
69 |
IGeometry geom; |
|
70 |
int numColumns; |
|
71 |
private ResultSetMetaData metaData = null; |
|
72 |
Value[] regAtt; |
|
73 |
/** |
|
74 |
* @throws SQLException |
|
75 |
* |
|
76 |
*/ |
|
77 |
public HSQLDBFeatureIterator(ResultSet rs) { |
|
78 |
// Debe ser forward only |
|
79 |
this.rs = rs; |
|
80 |
try { |
|
81 |
numColumns = rs.getMetaData().getColumnCount(); |
|
82 |
regAtt = new Value[numColumns-1]; |
|
83 |
metaData = rs.getMetaData(); |
|
84 |
} catch (SQLException e) { |
|
85 |
// TODO Auto-generated catch block |
|
86 |
e.printStackTrace(); |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
/* (non-Javadoc) |
|
91 |
* @see com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator#hasNext() |
|
92 |
*/ |
|
93 |
public boolean hasNext() throws SQLException { |
|
94 |
if (rs.isLast()) |
|
95 |
{ |
|
96 |
rs.close(); |
|
97 |
return false; |
|
98 |
} |
|
99 |
else |
|
100 |
return true; |
|
101 |
} |
|
102 |
|
|
103 |
/* (non-Javadoc) |
|
104 |
* @see com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator#next() |
|
105 |
*/ |
|
106 |
public IFeature next() throws SQLException { |
|
107 |
rs.next(); |
|
108 |
byte[] data = rs.getBytes(1); |
|
109 |
geom = parser.parse(data); |
|
110 |
for (int fieldId=2; fieldId <= numColumns; fieldId++ ) |
|
111 |
{ |
|
112 |
if (metaData.getColumnType(fieldId) == Types.VARCHAR) |
|
113 |
{ |
|
114 |
String strAux = rs.getString(fieldId); |
|
115 |
if (strAux == null) strAux = ""; |
|
116 |
regAtt[fieldId-2] = ValueFactory.createValue(strAux); |
|
117 |
} |
|
118 |
if (metaData.getColumnType(fieldId) == Types.FLOAT) |
|
119 |
regAtt[fieldId-2] = ValueFactory.createValue(rs.getFloat(fieldId)); |
|
120 |
if (metaData.getColumnType(fieldId) == Types.DOUBLE) |
|
121 |
regAtt[fieldId-2] = ValueFactory.createValue(rs.getDouble(fieldId)); |
|
122 |
if (metaData.getColumnType(fieldId) == Types.INTEGER) |
|
123 |
regAtt[fieldId-2] = ValueFactory.createValue(rs.getInt(fieldId)); |
|
124 |
if (metaData.getColumnType(fieldId) == Types.BIGINT) |
|
125 |
regAtt[fieldId-2] = ValueFactory.createValue(rs.getLong(fieldId)); |
|
126 |
if (metaData.getColumnType(fieldId) == Types.BIT) |
|
127 |
regAtt[fieldId-2] = ValueFactory.createValue(rs.getBoolean(fieldId)); |
|
128 |
if (metaData.getColumnType(fieldId) == Types.DATE) |
|
129 |
regAtt[fieldId-2] = ValueFactory.createValue(rs.getDate(fieldId)); |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
// TODO: Aqu? habr?a que usar una Factor?a. |
|
134 |
|
|
135 |
IFeature feat = new DefaultFeature(geom, regAtt); |
|
136 |
|
|
137 |
return feat; |
|
138 |
} |
|
139 |
|
|
140 |
} |
|
0 | 141 |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/jdbc/mysql/MySQLDriver.java | ||
---|---|---|
262 | 262 |
public String getGeometryField(String fieldName) { |
263 | 263 |
return "ASBINARY(" + fieldName +")"; |
264 | 264 |
} |
265 |
/** |
|
266 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
|
267 |
*/ |
|
268 |
public int[] getPrimaryKeys() throws com.hardcode.gdbms.engine.data.driver.DriverException { |
|
269 |
return new int[]{idFID_FieldName - 1}; |
|
270 |
} |
|
265 | 271 |
|
266 | 272 |
|
267 | 273 |
|
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/PostGisDriver.java | ||
---|---|---|
339 | 339 |
public String getGeometryField(String fieldName) { |
340 | 340 |
return "ASBINARY(" + fieldName + ", XDR)"; |
341 | 341 |
} |
342 |
/** |
|
343 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
|
344 |
*/ |
|
345 |
public int[] getPrimaryKeys() throws com.hardcode.gdbms.engine.data.driver.DriverException { |
|
346 |
// TODO Auto-generated method stub |
|
347 |
return null; |
|
348 |
} |
|
342 | 349 |
|
343 | 350 |
|
344 | 351 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dgn/DgnMemoryDriver.java | ||
---|---|---|
596 | 596 |
public DriverAttributes getDriverAttributes() { |
597 | 597 |
return attr; |
598 | 598 |
} |
599 |
|
|
600 |
/** |
|
601 |
* @see com.hardcode.gdbms.engine.data.driver.ObjectDriver#getPrimaryKeys() |
|
602 |
*/ |
|
603 |
public int[] getPrimaryKeys() throws DriverException { |
|
604 |
return null; |
|
605 |
} |
|
599 | 606 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FPoint2D.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import org.cresques.cts.ICoordTrans; |
44 | 44 |
|
45 |
import com.iver.utiles.XMLEntity; |
|
46 |
|
|
45 | 47 |
import java.awt.Rectangle; |
46 | 48 |
import java.awt.geom.AffineTransform; |
47 | 49 |
import java.awt.geom.PathIterator; |
48 | 50 |
import java.awt.geom.Point2D; |
49 | 51 |
import java.awt.geom.Rectangle2D; |
50 |
import java.io.Serializable;
|
|
52 |
import java.util.ArrayList;
|
|
51 | 53 |
|
52 | 54 |
|
53 | 55 |
/** |
... | ... | |
56 | 58 |
* @author Vicente Caballero Navarro |
57 | 59 |
*/ |
58 | 60 |
public class FPoint2D implements FShape { |
59 |
protected double x; |
|
60 |
protected double y; |
|
61 |
protected Point2D p; |
|
61 | 62 |
|
62 | 63 |
/** |
63 | 64 |
* Crea un nuevo Point2D. |
... | ... | |
66 | 67 |
* @param y Coordenada y del punto. |
67 | 68 |
*/ |
68 | 69 |
public FPoint2D(double x, double y) { |
69 |
this.x = x; |
|
70 |
this.y = y; |
|
70 |
p = new Point2D.Double(x, y); |
|
71 | 71 |
} |
72 |
|
|
72 |
public FPoint2D(){ |
|
73 |
|
|
74 |
} |
|
75 |
private void setPoint(double x, double y){ |
|
76 |
p = new Point2D.Double(x, y); |
|
77 |
} |
|
73 | 78 |
/** |
74 | 79 |
* Aplica la transformaci?n de la matriz de transformaci?n que se pasa como |
75 | 80 |
* par?metro. |
... | ... | |
77 | 82 |
* @param at Matriz de transformaci?n. |
78 | 83 |
*/ |
79 | 84 |
public void transform(AffineTransform at) { |
80 |
double[] p = new double[]{x, y}; |
|
81 |
at.transform(p, 0, p, 0, 1); |
|
85 |
at.transform(p, p); |
|
82 | 86 |
} |
83 | 87 |
|
84 | 88 |
/* (non-Javadoc) |
85 | 89 |
* @see java.awt.Shape#contains(double, double) |
86 | 90 |
*/ |
87 | 91 |
public boolean contains(double x, double y) { |
88 |
if ((x == this.x) || (y == this.y)) {
|
|
92 |
if ((x == p.getX()) || (y == p.getY())) {
|
|
89 | 93 |
return true; |
90 | 94 |
} else { |
91 | 95 |
return false; |
... | ... | |
105 | 109 |
public boolean intersects(double x, double y, double w, double h) { |
106 | 110 |
Rectangle2D.Double rAux = new Rectangle2D.Double(x, y, w, h); |
107 | 111 |
|
108 |
return rAux.contains(this.x, this.y);
|
|
112 |
return rAux.contains(p.getX(), p.getY());
|
|
109 | 113 |
} |
110 | 114 |
|
111 | 115 |
/* (non-Javadoc) |
112 | 116 |
* @see java.awt.Shape#getBounds() |
113 | 117 |
*/ |
114 | 118 |
public Rectangle getBounds() { |
115 |
return new Rectangle((int) this.x, (int) this.y, 0, 0);
|
|
119 |
return new Rectangle((int) p.getX(), (int) p.getY(), 0, 0);
|
|
116 | 120 |
} |
117 | 121 |
|
118 | 122 |
/** |
... | ... | |
121 | 125 |
* @return Coordenada x. |
122 | 126 |
*/ |
123 | 127 |
public double getX() { |
124 |
return this.x;
|
|
128 |
return p.getX();
|
|
125 | 129 |
} |
126 | 130 |
|
127 | 131 |
/** |
... | ... | |
130 | 134 |
* @return Coordenada y. |
131 | 135 |
*/ |
132 | 136 |
public double getY() { |
133 |
return this.y;
|
|
137 |
return p.getY();
|
|
134 | 138 |
} |
135 | 139 |
|
136 | 140 |
/* (non-Javadoc) |
... | ... | |
144 | 148 |
* @see java.awt.Shape#getBounds2D() |
145 | 149 |
*/ |
146 | 150 |
public Rectangle2D getBounds2D() { |
147 |
return new Rectangle2D.Double(x, y, 0, 0);
|
|
151 |
return new Rectangle2D.Double(p.getX()- 0.01, p.getY() - 0.01, 0.02, 0.02);
|
|
148 | 152 |
} |
149 | 153 |
|
150 | 154 |
/* (non-Javadoc) |
... | ... | |
158 | 162 |
* @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D) |
159 | 163 |
*/ |
160 | 164 |
public boolean intersects(Rectangle2D r) { |
161 |
return r.contains(new Point2D.Double(x, y));
|
|
165 |
return r.contains(this.p);
|
|
162 | 166 |
} |
163 | 167 |
|
164 | 168 |
/* (non-Javadoc) |
165 | 169 |
* @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform) |
166 | 170 |
*/ |
167 | 171 |
public PathIterator getPathIterator(AffineTransform at) { |
168 |
return new FPointIterator(new Point2D.Double(x, y), at);
|
|
172 |
return new FPointIterator(p, at);
|
|
169 | 173 |
} |
170 | 174 |
|
171 | 175 |
/* (non-Javadoc) |
172 | 176 |
* @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform, double) |
173 | 177 |
*/ |
174 | 178 |
public PathIterator getPathIterator(AffineTransform at, double flatness) { |
175 |
return new FPointIterator(new Point2D.Double(x, y), at);
|
|
179 |
return new FPointIterator(p, at);
|
|
176 | 180 |
} |
177 | 181 |
|
178 | 182 |
/** |
... | ... | |
186 | 190 |
* @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape() |
187 | 191 |
*/ |
188 | 192 |
public FShape cloneFShape() { |
189 |
return new FPoint2D(x, y);
|
|
193 |
return new FPoint2D(p.getX(), p.getY());
|
|
190 | 194 |
} |
191 | 195 |
|
192 | 196 |
/* (non-Javadoc) |
193 | 197 |
* @see com.iver.cit.gvsig.fmap.core.FShape#reProject(org.cresques.cts.ICoordTrans) |
194 | 198 |
*/ |
195 | 199 |
public void reProject(ICoordTrans ct) { |
196 |
Point2D p = new Point2D.Double(x, y); |
|
197 | 200 |
p = ct.convert(p, p); |
198 |
x = p.getX(); |
|
199 |
y = p.getY(); |
|
200 | 201 |
} |
202 |
|
|
203 |
/** |
|
204 |
* @see com.iver.cit.gvsig.fmap.core.FShape#getXMLEntity() |
|
205 |
*/ |
|
206 |
public XMLEntity getXMLEntity() { |
|
207 |
XMLEntity xml=new XMLEntity(); |
|
208 |
xml.putProperty("x",p.getX()); |
|
209 |
xml.putProperty("y",p.getY()); |
|
210 |
return xml; |
|
211 |
} |
|
212 |
public void setXMLEntity(XMLEntity xml){ |
|
213 |
this.setPoint(xml.getDoubleProperty("x"),xml.getDoubleProperty("y"));//p=new FPoint2D(xml.getDoubleProperty("x"),xml.getDoubleProperty("y")); |
|
214 |
} |
|
201 | 215 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FNullGeometry.java | ||
---|---|---|
51 | 51 |
|
52 | 52 |
import java.awt.Graphics2D; |
53 | 53 |
import java.awt.geom.Rectangle2D; |
54 |
import java.io.IOException; |
|
54 | 55 |
|
55 | 56 |
|
56 | 57 |
/** |
... | ... | |
135 | 136 |
public boolean fastIntersects(double x, double y, double w, double h) { |
136 | 137 |
return false; |
137 | 138 |
} |
139 |
|
|
140 |
/** |
|
141 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB() |
|
142 |
*/ |
|
143 |
public byte[] toWKB() throws IOException { |
|
144 |
// TODO Auto-generated method stub |
|
145 |
return null; |
|
146 |
} |
|
138 | 147 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FMultiPoint2D.java | ||
---|---|---|
52 | 52 |
import java.awt.Color; |
53 | 53 |
import java.awt.Graphics2D; |
54 | 54 |
import java.awt.geom.Rectangle2D; |
55 |
import java.io.IOException; |
|
55 | 56 |
|
56 | 57 |
|
57 | 58 |
/** |
... | ... | |
189 | 190 |
// TODO Auto-generated method stub |
190 | 191 |
return false; |
191 | 192 |
} |
193 |
/** |
|
194 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB() |
|
195 |
*/ |
|
196 |
public byte[] toWKB() throws IOException { |
|
197 |
// TODO Auto-generated method stub |
|
198 |
return null; |
|
199 |
} |
|
192 | 200 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometry.java | ||
---|---|---|
56 | 56 |
import com.vividsolutions.jts.geom.Geometry; |
57 | 57 |
|
58 | 58 |
import org.cresques.cts.ICoordTrans; |
59 |
import org.geotools.data.postgis.attributeio.WKBEncoder; |
|
59 | 60 |
|
60 | 61 |
import java.awt.Graphics2D; |
61 | 62 |
import java.awt.geom.AffineTransform; |
62 | 63 |
import java.awt.geom.Rectangle2D; |
64 |
import java.io.IOException; |
|
63 | 65 |
import java.io.Serializable; |
64 | 66 |
|
65 | 67 |
|
... | ... | |
209 | 211 |
public boolean fastIntersects(double x, double y, double w, double h) { |
210 | 212 |
return shp.intersects(x,y,w,h); |
211 | 213 |
} |
214 |
|
|
215 |
public byte[] toWKB() throws IOException{ |
|
216 |
return WKBEncoder.encodeGeometry(toJTSGeometry()); |
|
217 |
} |
|
212 | 218 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/IGeometry.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.awt.Graphics2D; |
44 | 44 |
import java.awt.geom.Rectangle2D; |
45 |
import java.io.IOException; |
|
45 | 46 |
import java.io.Serializable; |
46 | 47 |
|
47 | 48 |
import org.cresques.cts.ICoordTrans; |
... | ... | |
169 | 170 |
* @return GeneralPathXIterator. |
170 | 171 |
*/ |
171 | 172 |
GeneralPathXIterator getGeneralPathXIterator(); |
173 |
|
|
174 |
public byte[] toWKB() throws IOException; |
|
172 | 175 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometryCollection.java | ||
---|---|---|
48 | 48 |
import com.vividsolutions.jts.geom.Geometry; |
49 | 49 |
|
50 | 50 |
import org.cresques.cts.ICoordTrans; |
51 |
import org.geotools.data.postgis.attributeio.WKBEncoder; |
|
51 | 52 |
|
52 | 53 |
import java.awt.Graphics2D; |
53 | 54 |
import java.awt.geom.Rectangle2D; |
55 |
import java.io.IOException; |
|
54 | 56 |
|
55 | 57 |
|
56 | 58 |
/** |
... | ... | |
181 | 183 |
} |
182 | 184 |
return resul; |
183 | 185 |
} |
186 |
|
|
187 |
/** |
|
188 |
* @see com.iver.cit.gvsig.fmap.core.IGeometry#toWKB() |
|
189 |
*/ |
|
190 |
public byte[] toWKB() throws IOException { |
|
191 |
return WKBEncoder.encodeGeometry(toJTSGeometry()); |
|
192 |
} |
|
184 | 193 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java | ||
---|---|---|
45 | 45 |
import com.hardcode.driverManager.DriverManager; |
46 | 46 |
|
47 | 47 |
import com.hardcode.gdbms.engine.customQuery.QueryManager; |
48 |
import com.hardcode.gdbms.engine.data.DataSource; |
|
48 | 49 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
50 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
|
51 |
import com.hardcode.gdbms.engine.data.edition.DataWare; |
|
49 | 52 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
53 |
import com.hardcode.gdbms.engine.instruction.TableNotFoundException; |
|
54 |
import com.hardcode.gdbms.engine.values.Value; |
|
55 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
50 | 56 |
|
51 | 57 |
import com.iver.cit.gvsig.fmap.DriverException; |
58 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
52 | 59 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
53 | 60 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
54 | 61 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
... | ... | |
61 | 68 |
import com.iver.cit.gvsig.fmap.operations.arcview.ArcJoin; |
62 | 69 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
63 | 70 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
71 |
import com.iver.utiles.StringUtilities; |
|
64 | 72 |
|
65 | 73 |
import org.apache.log4j.Logger; |
66 | 74 |
|
67 | 75 |
import org.cresques.cts.IProjection; |
76 |
import org.hsqldb.lib.StringUtil; |
|
68 | 77 |
|
69 | 78 |
import java.awt.geom.Rectangle2D; |
70 | 79 |
|
71 | 80 |
import java.io.File; |
81 |
import java.io.IOException; |
|
72 | 82 |
|
73 | 83 |
import java.net.URL; |
74 | 84 |
|
75 | 85 |
import java.sql.ResultSet; |
76 | 86 |
import java.sql.SQLException; |
77 | 87 |
import java.sql.Statement; |
88 |
import java.sql.Types; |
|
78 | 89 |
import java.util.Enumeration; |
79 | 90 |
import java.util.TreeMap; |
80 | 91 |
|
... | ... | |
389 | 400 |
* @param layerName |
390 | 401 |
* @param object |
391 | 402 |
* @return |
403 |
* @throws SQLException |
|
404 |
* @throws DriverIOException |
|
405 |
* @throws IOException |
|
406 |
* @throws DriverLoadException |
|
407 |
* @throws com.hardcode.gdbms.engine.data.driver.DriverException |
|
408 |
* @throws NoSuchTableException |
|
409 |
* @throws ClassNotFoundException |
|
410 |
* @throws |
|
392 | 411 |
*/ |
393 |
public static FLayer createDisconnectedDBLayer(VectorialDatabaseDriver driver, String layerName, IProjection proj) { |
|
412 |
public static FLayer createDisconnectedDBLayer(VectorialDatabaseDriver driver, String layerName, IProjection proj) throws SQLException, IOException, DriverIOException, DriverLoadException, NoSuchTableException, com.hardcode.gdbms.engine.data.driver.DriverException, ClassNotFoundException { |
|
413 |
VectorialDisconnectedDBAdapter dbAdapter = new VectorialDisconnectedDBAdapter(); |
|
414 |
dbAdapter.setDriver(driver); |
|
415 |
DataSource ds = dbAdapter.getRecordset(); |
|
416 |
ds.start(); |
|
417 |
String database = dataSourceFactory.getTempFile(); |
|
418 |
String[] fieldNames = new String[ds.getFieldCount() + 1]; |
|
419 |
System.arraycopy(ds.getFieldNames(), 0, fieldNames, 1, ds.getFieldCount()); |
|
420 |
fieldNames[0] = "the_geom"; |
|
421 |
int[] types = new int[fieldNames.length]; |
|
422 |
types[0] = Types.BINARY; |
|
423 |
for (int i = 1; i < types.length; i++) { |
|
424 |
types[i] = ds.getFieldType(i-1); |
|
425 |
} |
|
426 |
String dsName = dataSourceFactory.createTable(database, ds.getPKNames(), fieldNames, types); |
|
394 | 427 |
|
395 |
|
|
396 |
FLyrVect capa = new FLyrVect(); |
|
397 |
|
|
398 |
capa.setName(layerName); |
|
399 |
VectorialDisconnectedDBAdapter dbAdapter = new VectorialDisconnectedDBAdapter(); |
|
400 |
dbAdapter.setDriver(driver); |
|
428 |
dataSourceFactory.addDBDataSourceByTable(dsName, null, 0, "sa", "", database, dsName, "GDBMS HSQLDB driver", null); |
|
429 |
DataSource local = dataSourceFactory.createRandomDataSource(dsName, DataSourceFactory.MANUAL_MODE); |
|
430 |
local.start(); |
|
431 |
DataWare dw = local.getDataWare(); |
|
432 |
dw.beginTrans(); |
|
433 |
|
|
434 |
for (int i = 0; i < dbAdapter.getShapeCount(); i++) { |
|
435 |
dw.insertRow(ds.getPKValue(i)); |
|
436 |
byte[] bytes = dbAdapter.getShape(i).toWKB(); |
|
437 |
Value v = ValueFactory.createValue(bytes); |
|
438 |
dw.setFieldValue(i, 0, v); |
|
439 |
for (int j = 0; j < ds.getFieldCount(); j++) { |
|
440 |
dw.setFieldValue(i, j+1, ds.getFieldValue(i, j)); |
|
441 |
} |
|
442 |
} |
|
443 |
|
|
444 |
dw.commitTrans(); |
|
445 |
local.stop(); |
|
446 |
ds.stop(); |
|
447 |
VectorialDatabaseDriver cacheDriver = (VectorialDatabaseDriver) LayerFactory.getDM().getDriver("HSQLDB Driver"); |
|
448 |
Class.forName("org.hsqldb.jdbcDriver"); |
|
401 | 449 |
|
402 |
capa.setSource(dbAdapter); |
|
403 |
capa.setProjection(proj); |
|
404 |
try { |
|
405 |
if (driver instanceof WithDefaultLegend) { |
|
406 |
WithDefaultLegend aux = (WithDefaultLegend) driver; |
|
407 |
dbAdapter.start(); |
|
408 |
capa.setLegend((VectorialLegend) aux.getDefaultLegend()); |
|
409 |
dbAdapter.stop(); |
|
410 |
} else { |
|
411 |
capa.setLegend(LegendFactory.createSingleSymbolLegend( |
|
412 |
capa.getShapeType())); |
|
413 |
} |
|
414 |
} catch (FieldNotFoundException e) { |
|
415 |
throw new UnsupportedOperationException(e.getMessage()); |
|
416 |
} catch (DriverException e) { |
|
417 |
throw new UnsupportedOperationException(e.getMessage()); |
|
418 |
} |
|
419 |
|
|
420 |
return capa; |
|
421 |
|
|
422 |
|
|
423 |
|
|
450 |
cacheDriver.setData(java.sql.DriverManager.getConnection("jdbc:hsqldb:file:" + database, "sa", ""), dsName, StringUtilities.getComaSeparated(local.getFieldNames()), "", local.getPrimaryKeys()[0]); |
|
451 |
return createDBLayer(cacheDriver, layerName, proj); |
|
424 | 452 |
} |
425 | 453 |
|
426 | 454 |
|
... | ... | |
481 | 509 |
Throwable[] failures = driverManager.getLoadFailures(); |
482 | 510 |
|
483 | 511 |
for (int i = 0; i < failures.length; i++) { |
484 |
logger.error(failures[i]); |
|
512 |
logger.error("", failures[i]);
|
|
485 | 513 |
} |
486 | 514 |
|
487 | 515 |
getDataSourceFactory().setDriverManager(driverManager); |
516 |
getDataSourceFactory().initialize(); |
|
488 | 517 |
QueryManager.registerQuery(new ArcJoin()); |
489 | 518 |
} |
490 | 519 |
} |
branches/Fmap_GisPlanet/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/SelectableDataSource.java | ||
---|---|---|
51 | 51 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
52 | 52 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
53 | 53 |
import com.hardcode.gdbms.engine.data.driver.DriverInfo; |
54 |
import com.hardcode.gdbms.engine.data.persistence.Handler;
|
|
54 |
import com.hardcode.gdbms.engine.data.edition.DataWare;
|
|
55 | 55 |
import com.hardcode.gdbms.engine.data.persistence.Memento; |
56 | 56 |
import com.hardcode.gdbms.engine.data.persistence.MementoContentHandler; |
57 | 57 |
import com.hardcode.gdbms.engine.data.persistence.MementoException; |
... | ... | |
373 | 373 |
} |
374 | 374 |
|
375 | 375 |
/** |
376 |
* @throws DriverException |
|
376 | 377 |
* @see com.hardcode.gdbms.engine.data.DataSource#remove() |
377 | 378 |
*/ |
378 |
public void remove() { |
|
379 |
public void remove() throws DriverException {
|
|
379 | 380 |
dataSource.remove(); |
380 | 381 |
} |
381 | 382 |
|
... | ... | |
393 | 394 |
return dataSource.getSourceInfo(); |
394 | 395 |
} |
395 | 396 |
|
397 |
/** |
|
398 |
* @see com.hardcode.gdbms.engine.data.DataSource#getPrimaryKeys() |
|
399 |
*/ |
|
400 |
public int[] getPrimaryKeys() throws DriverException { |
|
401 |
return dataSource.getPrimaryKeys(); |
|
402 |
} |
|
403 |
|
|
404 |
/** |
|
405 |
* @see com.hardcode.gdbms.engine.data.DataSource#getDataWare() |
|
406 |
*/ |
|
407 |
public DataWare getDataWare() { |
|
408 |
return dataSource.getDataWare(); |
|
409 |
} |
|
410 |
|
|
411 |
/** |
|
412 |
* @see com.hardcode.gdbms.engine.data.DataSource#getPKValue(long) |
|
413 |
*/ |
|
414 |
public Value getPKValue(long rowIndex) throws DriverException { |
|
415 |
return dataSource.getPKValue(rowIndex); |
|
416 |
} |
|
417 |
|
|
418 |
/** |
|
419 |
* @see com.hardcode.gdbms.engine.data.DataSource#getPKName(int) |
|
420 |
*/ |
|
421 |
public String getPKName(int fieldId) throws DriverException { |
|
422 |
return dataSource.getPKName(fieldId); |
|
423 |
} |
|
424 |
|
|
425 |
/** |
|
426 |
* @see com.hardcode.gdbms.engine.data.DataSource#getPKType(int) |
|
427 |
*/ |
|
428 |
public int getPKType(int i) throws DriverException { |
|
429 |
return dataSource.getPKType(i); |
|
430 |
} |
|
431 |
|
|
432 |
/** |
|
433 |
* @throws DriverException |
|
434 |
* @see com.hardcode.gdbms.engine.data.DataSource#getPKCardinality() |
|
435 |
*/ |
|
436 |
public int getPKCardinality() throws DriverException { |
|
437 |
return dataSource.getPKCardinality(); |
|
438 |
} |
|
439 |
|
|
440 |
/** |
|
441 |
* @see com.hardcode.gdbms.engine.data.DataSource#getRow(long) |
|
442 |
*/ |
|
443 |
public Value[] getRow(long rowIndex) throws DriverException { |
|
444 |
return dataSource.getRow(rowIndex); |
|
445 |
} |
|
446 |
|
|
447 |
/** |
|
448 |
* @see com.hardcode.gdbms.engine.data.DataSource#getFieldNames() |
|
449 |
*/ |
|
450 |
public String[] getFieldNames() throws DriverException { |
|
451 |
return dataSource.getFieldNames(); |
|
452 |
} |
|
453 |
|
|
454 |
/** |
|
455 |
* @see com.hardcode.gdbms.engine.data.DataSource#getPKNames() |
|
456 |
*/ |
|
457 |
public String[] getPKNames() throws DriverException { |
|
458 |
return dataSource.getPKNames(); |
|
459 |
} |
|
460 |
|
|
396 | 461 |
public void removeLinksSelectionListener() { |
397 | 462 |
selectionSupport.removeLinkSelectionListener(); |
398 | 463 |
} |
Also available in: Unified diff