Hello,
I am currently trying to create a shapefile from a MemoryDataStore.
I followed this link :
http://docs.codehaus.org/display/GEOTDOC/05+How+to+Write+a+Shapefile
But actually I got a problem. GT says that when I write the spafile :
"1 avr. 2008 16:26:56 org.geotools.data.shapefile.ShapefileDataStore
createSchema
ATTENTION: PRJ file not generated for null CoordinateReferenceSystem"
My code is this :
FeatureCollection<SimpleFeatureType,SimpleFeature> fc = null;
MemoryDataStore sites = null;
String siteName = null;
try{
/* Creating the new Shapefile */
FileDataStoreFactorySpi factory = new
IndexedShapefileDataStoreFactory();
File file = new
File(MSS_ControlProject.getSitesPath()+File.separator+"sites.shp");
Map<String, URL> map = Collections.singletonMap("url",
file.toURI().toURL());
ShapefileDataStore myData = (ShapefileDataStore)
factory.createNewDataStore(map);
myData.forceSchemaCRS(CRS.decode("EPSG:4326"));
myData.createSchema(SensorSiteStation.getSensorSiteType());
/* Get sites and sites type */
siteName = SensorSiteStation.getSensorSiteType().getTypeName();
sites = MSS_ControlProject.getSensorSites();
/* Create the collection to write */
fc =
sites.getFeatureSource(SensorSiteStation.getTypeIdentifier()).getFeatures();
}catch(MalformedURLException murle){
}catch(IOException ioe){
}catch(NoSuchAuthorityCodeException nsace){
}catch(FactoryException fe){}
DefaultTransaction trans = null;
FeatureStore<SimpleFeatureType,SimpleFeature> store = null;
try{
trans = new DefaultTransaction();
store = (FeatureStore<SimpleFeatureType,
SimpleFeature>)sites.getFeatureSource(siteName);
store.setTransaction(trans);
}catch(IOException ioe){}
try{
store.addFeatures(fc);
trans.commit();
trans.close();
}catch (Exception eek) {
try {
trans.rollback();
} catch (IOException e) {
e.printStackTrace();
}
}
Somebody gets an idea to fix this problem ?
Thanks,
Thomas
_________________________________________________________________
Votre contact a choisi Hotmail, l'e-mail ultra sécurisé. Créez un compte
gratuitement !
http://www.windowslive.fr/hotmail/default.asp-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users