Hello there, I want to add local gml to map. I am able to add file locally
but when i close udig it will ask to save file how to avoid it.... I think
it is due to createTemporaryResource. How to load gml permanently so that
it will no ask file to save and automatically load while application start
next time

Here is my sample code

String workDirPath = "/home/amit/Music/sample.gml";
                org.geotools.xml.Configuration configuration = new
org.geotools.gml2.GMLConfiguration();
                org.geotools.xml.Parser parser = new
org.geotools.xml.Parser( configuration );
                InputStream xml = null;
                        try {
                            GML gml = new GML(Version.WFS1_0);
                            xml = new FileInputStream(workDirPath);
                            //FeatureCollection<SimpleFeatureType,
SimpleFeature> featureCollection = gml.decodeFeatureCollection(xml);
                            SimpleFeatureCollection featureCollection =
gml.decodeFeatureCollection(xml);
                            IGeoResource resource =
CatalogPlugin.getDefault().getLocalCatalog()

.createTemporaryResource(featureCollection.getSchema());
                            FeatureStore<SimpleFeatureType, SimpleFeature>
store = resource.resolve(FeatureStore.class, new NullProgressMonitor());
                            store.addFeatures(featureCollection);

ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(),
Collections.singletonList(resource), -1);
                        } catch (FileNotFoundException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        } catch (IOException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        } catch (SAXException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        } catch (ParserConfigurationException e1) {
                            // TODO Auto-generated catch block
                            e1.printStackTrace();
                        }
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to