SDF using FeatureClassCollection

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SDF using FeatureClassCollection

raghulan
This post was updated on .
Hello PPL,

 I am not able to use featureclasscolelction to store feature class which i created to create a Schema and a SDF file from scratch..

here is my code (I am trying to create a SDF file with desired schema)
=============================================================
//create the feature class definitions store all feature class in a collection
            FeatureClassCollection fcoll = null;

           
            //create all feature class
            FeatureClass class_points = new FeatureClass("Points", "Point information");
            FeatureClass class_alignment = new FeatureClass("Alignments", "Alignment information");
            FeatureClass class_parcels = new FeatureClass("Parcels", "Parcels information");
            FeatureClass class_pipes = new FeatureClass("Pipes", "Pipes information");
            FeatureClass class_structures = new FeatureClass("Structures", "Structures information");

//add all the feature classes to the collection <<< this is where my application crashing..
                fcoll.Add(class_points);
                fcoll.Add(class_alignment);
                fcoll.Add(class_parcels);
                fcoll.Add(class_pipes);
                fcoll.Add(class_structures);

============================================
any help would be great...
-Raghulan Gowthaman
Senior civil BIM Consultant
Reply | Threaded
Open this post in threaded view
|

Re: SDF using FeatureClassCollection

Jackie Ng
You're adding feature class objects to a null reference.

If you're trying to add classes to a schema, you should be adding these classes to the schema's class collection (via the schema's Classes property)

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: SDF using FeatureClassCollection

raghulan
Thnx for the hint...How to declare a FeatureClassCollection?

here is the complete code snippet..
=============================================================
//create the feature class definitions store all feature class in a collection
            FeatureClassCollection fcoll = null;

           
            //create all feature class
            FeatureClass class_points = new FeatureClass("Points", "Point information");
            FeatureClass class_alignment = new FeatureClass("Alignments", "Alignment information");
            FeatureClass class_parcels = new FeatureClass("Parcels", "Parcels information");
            FeatureClass class_pipes = new FeatureClass("Pipes", "Pipes information");
            FeatureClass class_structures = new FeatureClass("Structures", "Structures information");

//add all the feature classes to the collection <<< this is where my application crashing..
                fcoll.Add(class_points);
                fcoll.Add(class_alignment);
                fcoll.Add(class_parcels);
                fcoll.Add(class_pipes);
                fcoll.Add(class_structures);

//create property definition for each feature class - here for each class i am adding property definition from a seperate class called metadata...
            for(int i = 0; i <15; i++)
            {
                if (i < 2)
                {
                    class_points.Properties.Add(Metadata.get_point_property(i));
                }
                if (i < 12)
                {
                    class_pipes.Properties.Add(Metadata.get_pipe_property(i));
                }
               
            }

//create the schema and add the class definition - getting names from UI for schema name and desc
            FeatureSchema schema1 = new FeatureSchema(tbox_q_schema_name.Text, tbox_q_schema_desc.Text);
            foreach (FeatureClass fc in fcoll)
            {
                schema1.Classes.Add(fc);
            }

//first get an instance of the connection manager
            IConnectionManager connman = FeatureAccessManager.GetConnectionManager();
            using (IConnection con = connman.CreateConnection("OSGeo.SDF"))
            {
                IConnectionPropertyDictionary props = con.ConnectionInfo.ConnectionProperties;
                props.SetProperty("File", file1);//file name from UI
                props.SetProperty("ReadOnly", false.ToString());

                //create datastore - sdf file
                ICreateDataStore create_sdf = con.CreateCommand(CommandType.CommandType_CreateDataStore) as ICreateDataStore;
                create_sdf.DataStoreProperties.SetProperty("File", file1);
                create_sdf.Execute();
            }
============================================
-Raghulan Gowthaman
Senior civil BIM Consultant
Reply | Threaded
Open this post in threaded view
|

Re: SDF using FeatureClassCollection

raghulan
In reply to this post by Jackie Ng
Thanks Jacki,

 its working now..I am able to do it..but not through collection but i added them individually.

-Raghulan Gowthaman
Senior civil BIM Consultant
Reply | Threaded
Open this post in threaded view
|

create a class that reads from one data source and creates a shapefile out of it.

Pankaj
This post has NOT been accepted by the mailing list yet.
In reply to this post by Jackie Ng
Using the Maguide .NET C# API (with FDO API) i  would like  to create a class that reads from one data source and creates a shapefile out of it.

So basically take any FDO input source and create a shapefile out of.