From: Justin D. <jde...@op...> - 2009-05-12 20:27:57
|
Hi Fernando, What I would try is first querying the shapefile datastore with a query that specifies only the attributes you want to import into the database. Example: String[] properties = new String[]{"prop1","prop2",...}; Query query = new DefaultQuery( "theTypeName", Filter.INCLUDE, properties); FeatureCollection features = source.getFeatures(query); ... -Justin Fernando Quadro wrote: > Hi All, > > I want to import shapefile to PostGIS, but the shapefile have many columns and I want to import only column geom. > The code below makes the importation of all columns of the Shapefile, how do you import only the geom column? > > Map params = new HashMap(); > params.put("dbtype", "postgis"); //must be postgis > params.put("host", ConstantesMd.BD_HOST); //the name or ip address of the machine running PostGIS > params.put("port", new Integer(5432)); //the port that PostGIS is running on (generally 5432) > params.put("database", ConstantesMd.BD_NOME); //the name of the database to connect to. > params.put("user", ConstantesMd.BD_USUARIO); //the user to connect with > params.put("passwd", ConstantesMd.BD_SENHA); > params.put("schema", lNomSchema); > > PostgisDataStore pgDatastore = (PostgisDataStore)DataStoreFinder.getDataStore(params); > PostgisFeatureStore fsBC = (PostgisFeatureStore)pgDatastore.getFeatureSource(lNomTabela); > > Feature[] ftc = new Feature[1]; > > for (FeatureIterator it=source.getFeatures().features(); it.hasNext(); ) { > try { > ftc[0] = (Feature)it.next(); > FeatureReader feature = DataUtilities.reader(ftc); > fsBC.addFeatures(feature); > lIntLinhasImportadas++; > System.out.println("Linha: " + lIntLinhasImportadas); > } catch (Exception e) { > e.printStackTrace(); > System.out.println( e.getMessage() ); > } > lIntTotalLinhas++; > } > > Best Regards, > > Fernando Quadro > GeoServer-BR > http://www.fernandoquadro.com.br > twitter.com/fernandoquadro > > ------------------------------------------------------------------------------ > The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your > production scanning environment may not be a perfect world - but thanks to > Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700 > Series Scanner you'll get full speed at 300 dpi even with all image > processing features enabled. http://p.sf.net/sfu/kodak-com > _______________________________________________ > Geoserver-users mailing list > Geo...@li... > https://lists.sourceforge.net/lists/listinfo/geoserver-users -- Justin Deoliveira OpenGeo - http://opengeo.org Enterprise support for open source geospatial. |