URL rutaBase = GeneradorShapeFile.class.getResource("/");
java.util.Date date = new java.util.Date();
String rutaLocal = rutaBase.toString()+"../../paginas/temp/"+date.getDay()+ "_"+date.getMonth()+ "_"+date.getYear()+ "_"+date.getMinutes()+ "_"+date.getSeconds()+ ".shp";
//File file = new File( new URL(rutaLocal).toURI() );
Map params = new HashMap();
try {
params.put("url", new URL(rutaLocal) );
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
ShapefileDataStore dataStoreS = (ShapefileDataStore) factory.createNewDataStore(params);
// UTM 30.
//SimpleFeatureType TYPE = (SimpleFeatureType) DataUtilities.createType("Location","location:Point,name:String");
dataStoreS.createSchema(simpleFeature);
dataStoreS.forceSchemaCRS(
CRS.decode("EPSG:23030")
);
Carlos Javier Martín Cano
Buscar este blog
jueves, 10 de junio de 2010
miércoles, 9 de junio de 2010
CONSULTA SQL POR BOUNDING BOX
private MemoryDataStore getCapaGeoDatabase(ReferencedEnvelope
bounds)throws Exception {
// Hay que hacer una consulta espacial a ORACLE de la siguiente
forma.
// SELECT SHAPE FROM CapaGeoDatabase A
// WHERE sdo_filter(A.shape, SDO_geometry(2003,NULL,NULL,
//
SDO_elem_info_array(1,1003,3),
//
SDO_ordinate_array(x_min,y_min, x_max,y_max))
// ) = 'TRUE';
//
// Y crearse la capa de resultados.
String nombreCapa =
indicadorSeleccionado.getSspCapasig2().getCapa();
String sqlQuery = "SELECT shape FROM "+nombreCapa+" A\n";
sqlQuery +=" WHERE SDO_FILTER(A.shape, SDO_GEOMETRY(2003,23030,NULL,\n"; // SRID = 23030 (U.T.M 30 metros)
sqlQuery +="
SDO_ELEM_INFO_ARRAY(1,1003,3),\n"; // TIPO Poligono
sqlQuery +="
SDO_ORDINATE_ARRAY("+bounds.getMinX()+","+bounds.getMinY()+","+bounds.getMaxX()+","+bounds.getMaxY()+"))\n";
sqlQuery +=") = 'TRUE'";
Connection conexion = (Connection) ManagerConsultasDAO.Instance().getOracleConnection();
Statement stm = conexion.createStatement();
stm.execute(sqlQuery);
ResultSet rs = stm.getResultSet();
MemoryDataStore ds = crearMemoryDataStore(rs);
conexion.close();
return ds;
} Carlos Javier Martín Cano
bounds)throws Exception {
// Hay que hacer una consulta espacial a ORACLE de la siguiente
forma.
// SELECT SHAPE FROM CapaGeoDatabase A
// WHERE sdo_filter(A.shape, SDO_geometry(2003,NULL,NULL,
//
SDO_elem_info_array(1,1003,3),
//
SDO_ordinate_array(x_min,y_min, x_max,y_max))
// ) = 'TRUE';
//
// Y crearse la capa de resultados.
String nombreCapa =
indicadorSeleccionado.getSspCapasig2().getCapa();
String sqlQuery = "SELECT shape FROM "+nombreCapa+" A\n";
sqlQuery +=" WHERE SDO_FILTER(A.shape, SDO_GEOMETRY(2003,23030,NULL,\n"; // SRID = 23030 (U.T.M 30 metros)
sqlQuery +="
SDO_ELEM_INFO_ARRAY(1,1003,3),\n"; // TIPO Poligono
sqlQuery +="
SDO_ORDINATE_ARRAY("+bounds.getMinX()+","+bounds.getMinY()+","+bounds.getMaxX()+","+bounds.getMaxY()+"))\n";
sqlQuery +=") = 'TRUE'";
Connection conexion = (Connection) ManagerConsultasDAO.Instance().getOracleConnection();
Statement stm = conexion.createStatement();
stm.execute(sqlQuery);
ResultSet rs = stm.getResultSet();
MemoryDataStore ds = crearMemoryDataStore(rs);
conexion.close();
return ds;
} Carlos Javier Martín Cano
lunes, 7 de junio de 2010
gotoWorkSpace oracle
public static boolean gotoWorkSpace(escenario escenario){
try {
IConnection C= escenario.getCwp().getConnection();
ConnectionJDBC jdbc = (ConnectionJDBC) C;
String call = "{ call DBMS_WM.GotoWorkspace(?) }";
Statement st = jdbc.getConnection().createStatement();
CallableStatement CL=jdbc.getConnection().prepareCall(call);
CL.setQueryTimeout(1800);
CL.registerOutParameter(1, Types.VARCHAR);
CL.setString(1, escenario.getNombreWorkSpace());
CL.executeUpdate();
CL.close();
conecta.commitConec();
System.out.println("GOTOWORKSPACE: " +escenario.getNombreWorkSpace());
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
} Carlos Javier Martín Cano
try {
IConnection C= escenario.getCwp().getConnection();
ConnectionJDBC jdbc = (ConnectionJDBC) C;
String call = "{ call DBMS_WM.GotoWorkspace(?) }";
Statement st = jdbc.getConnection().createStatement();
CallableStatement CL=jdbc.getConnection().prepareCall(call);
CL.setQueryTimeout(1800);
CL.registerOutParameter(1, Types.VARCHAR);
CL.setString(1, escenario.getNombreWorkSpace());
CL.executeUpdate();
CL.close();
conecta.commitConec();
System.out.println("GOTOWORKSPACE: " +escenario.getNombreWorkSpace());
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
return true;
} Carlos Javier Martín Cano
Suscribirse a:
Comentarios (Atom)