Create an FdoFeatureClass?

19 messages Options
Embed this post
Permalink
VJ

Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
Hello,

I'd like to create an FdoFeatureDataClass...
FdoFeatureClass::Create can be used to create a new instance of a feature class
FdoFeatureClass::SetGeometryProperty can be used to set the GeometricPopertyDefinition
but how do I set the different DataPropertyDefinition?

How can I then add that FdoFeatureDataClass to an existing FdoFeatureSchema?

(I'd like to be able to create a new "table" in PostGIS)


Thanks!


Jörg
Greg Boone

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
If you look at the files in...

https://svn.osgeo.org/fdo/trunk/Fdo/UnitTest

... and search for FdoFeatureClass::Create, you will find some basic examples on how to create schema and apply it.

Greg,

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of VJ
Sent: Thursday, April 09, 2009 10:45 AM
To: [hidden email]
Subject: [fdo-users] Create an FdoFeatureClass?


Hello,

I'd like to create an FdoFeatureDataClass...
FdoFeatureClass::Create can be used to create a new instance of a feature class
FdoFeatureClass::SetGeometryProperty can be used to set the GeometricPopertyDefinition
but how do I set the different DataPropertyDefinition?

How can I then add that FdoFeatureDataClass to an existing FdoFeatureSchema?

(I'd like to be able to create a new "table" in PostGIS)


Thanks!


Jörg
--
View this message in context: http://n2.nabble.com/Create-an-FdoFeatureClass--tp2611536p2611536.html
Sent from the FDO Users mailing list archive at Nabble.com.

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
Great! Thanks!
:)

Jörg
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
Ok, I can create a new FeatureClass to an FdoFeatureSchema, but the changes are not passed on to my PostGIS database... The FdoFeatureSchema shows it has been modified, and I can verify the new FeatureClass is present.

I called the AcceptChange method (of FdoFeatureSchema), and called Flush (of FdoIConnection), yet no table has been added to the database...

Any suggestions?
Thanks!
Jackie Ng

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
Did you execute FdoIApplySchema passing in your modified  FdoFeatureSchema ?

- Jackie

VJ wrote:
Ok, I can create a new FeatureClass to an FdoFeatureSchema, but the changes are not passed on to my PostGIS database... The FdoFeatureSchema shows it has been modified, and I can verify the new FeatureClass is present.

I called the AcceptChange method (of FdoFeatureSchema), and called Flush (of FdoIConnection), yet no table has been added to the database...

Any suggestions?
Thanks!
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
I created the FdoIApplySchema command, called SetFeatureSchema on it with my new featureschema.
But does that schema also need to hold the current classes?
My steps were:
1. GetClasses on my featureSchema => FdoClassCollection
2. added an new class to this collection
3. Created the FdoIApplySchema command
4. called SetFeatureSchema (my new schema)
5. executed FdoIApplySchema

I think the problem lies with the FdoPhysicalSchemaMapping, I'm currently figuring out what I should add there. I think I may also need to call SetPhysicalMapping on the FdoIApplySchemaCommand.

 
Jackie Ng wrote:
Did you execute FdoIApplySchema passing in your modified  FdoFeatureSchema ?

- Jackie
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
The command FdoIDescribeSchemaMapping is not supported for this provider....

VJ wrote:
I created the FdoIApplySchema command, called SetFeatureSchema on it with my new featureschema.
But does that schema also need to hold the current classes?
My steps were:
1. GetClasses on my featureSchema => FdoClassCollection
2. added an new class to this collection
3. Created the FdoIApplySchema command
4. called SetFeatureSchema (my new schema)
5. executed FdoIApplySchema

I think the problem lies with the FdoPhysicalSchemaMapping, I'm currently figuring out what I should add there. I think I may also need to call SetPhysicalMapping on the FdoIApplySchemaCommand.

 
Jackie Ng wrote:
Did you execute FdoIApplySchema passing in your modified  FdoFeatureSchema ?

- Jackie
Jackie Ng

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
In reply to this post by VJ
Where does your feature schema originate from? Was it from a FdoIDescribeSchema command or did you create one?

- Jackie

VJ wrote:
I created the FdoIApplySchema command, called SetFeatureSchema on it with my new featureschema.
But does that schema also need to hold the current classes?
My steps were:
1. GetClasses on my featureSchema => FdoClassCollection
2. added an new class to this collection
3. Created the FdoIApplySchema command
4. called SetFeatureSchema (my new schema)
5. executed FdoIApplySchema

I think the problem lies with the FdoPhysicalSchemaMapping, I'm currently figuring out what I should add there. I think I may also need to call SetPhysicalMapping on the FdoIApplySchemaCommand.

 
Jackie Ng wrote:
Did you execute FdoIApplySchema passing in your modified  FdoFeatureSchema ?

- Jackie
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
It came from an FdoIDescribeSchema (on the same provider).

1. get schemas
FdoPtr<FdoIDescribeSchema> describeSchemaCommand = (FdoIDescribeSchema*) (FdoConnectionObject->CreateCommand(FdoCommandType_DescribeSchema));
FdoFeatureSchemaCollection* schemaCollection = describeSchemaCommand->Execute();

2. set schema
mFeatureSchema= schemaCollection->GetItem(name)

3. create class
FdoFeatureClass* newClass = FdoFeatureClass::Create(fdoname,fdoname);
FdoPropertyDefinitionCollection* dataProperties = newClass->GetProperties();
// a number of times:
FdoDataPropertyDefinition* fdpd = FdoDataPropertyDefinition::Create(key,key);
fdpd->SetDataType(type);
fdpd->SetReadOnly(false);
dataProperties->Add(fdpd);
//

4. add class
FdoClassCollection* collection = mFeatureSchema->GetClasses();
collection->Add(newClass);
FdoSchemaElementState state = mFeatureSchema->GetElementState(); // shows modified!
mFeatureSchema->AcceptChanges(); // should not be necessary according to documentation

// test
FdoClassCollection* collection = mFeatureSchema->GetClasses(); // shows one more class!


5. apply
FdoPtr<FdoIApplySchema> applySchema;
applySchema = (FdoIApplySchema*) (FdoConnectionObject->CreateCommand(FdoCommandType_ApplySchema));
applySchema->SetFeatureSchema(mFeatureSchema);
applySchema->Execute();

No execptions are thrown, but my database stays the same. I would have expected a new table to show up.
Jackie Ng

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
If you execute another FdoIDescribeSchema afterwards does your new class appear?

- Jackie

VJ wrote:
It came from an FdoIDescribeSchema (on the same provider).

1. get schemas
FdoPtr<FdoIDescribeSchema> describeSchemaCommand = (FdoIDescribeSchema*) (FdoConnectionObject->CreateCommand(FdoCommandType_DescribeSchema));
FdoFeatureSchemaCollection* schemaCollection = describeSchemaCommand->Execute();

2. set schema
mFeatureSchema= schemaCollection->GetItem(name)

3. create class
FdoFeatureClass* newClass = FdoFeatureClass::Create(fdoname,fdoname);
FdoPropertyDefinitionCollection* dataProperties = newClass->GetProperties();
// a number of times:
FdoDataPropertyDefinition* fdpd = FdoDataPropertyDefinition::Create(key,key);
fdpd->SetDataType(type);
fdpd->SetReadOnly(false);
dataProperties->Add(fdpd);
//

4. add class
FdoClassCollection* collection = mFeatureSchema->GetClasses();
collection->Add(newClass);
FdoSchemaElementState state = mFeatureSchema->GetElementState(); // shows modified!
mFeatureSchema->AcceptChanges(); // should not be necessary according to documentation

// test
FdoClassCollection* collection = mFeatureSchema->GetClasses(); // shows one more class!


5. apply
FdoPtr<FdoIApplySchema> applySchema;
applySchema = (FdoIApplySchema*) (FdoConnectionObject->CreateCommand(FdoCommandType_ApplySchema));
applySchema->SetFeatureSchema(mFeatureSchema);
applySchema->Execute();

No execptions are thrown, but my database stays the same. I would have expected a new table to show up.
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
I did not create a new Schema (did I?), but a new FeatureClass in the existing schema..

So I still have one FdoFeatureSchema at the end (tried the FdoIDescribeSchema afterwards), but it does hold one more class than it did before I tried (using GetClasses() on that schema). That one more class also has the correct signature (types, ...).


Jörg

Jackie Ng wrote:
If you execute another FdoIDescribeSchema afterwards does your new class appear?

- Jackie
Jackie Ng

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
If the subsequent FdoIDescribeSchema returns a FdoFeatureSchema containing your new class, then everything worked.

If you want to be doubly sure, take a look at the PostGIS database with pgAdmin and see if a new table (representing your new feature class) is there.

- Jackie

VJ wrote:
I did not create a new Schema (did I?), but a new FeatureClass in the existing schema..

So I still have one FdoFeatureSchema at the end (tried the FdoIDescribeSchema afterwards), but it does hold one more class than it did before I tried (using GetClasses() on that schema). That one more class also has the correct signature (types, ...).


Jörg

Jackie Ng wrote:
If you execute another FdoIDescribeSchema afterwards does your new class appear?

- Jackie
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
That is my issue: it doesn't appear in PostGIS (no trace of it), I'm looking with pgadmin. :-(

From in my program, everything seems in order (Schema contains class). But on the next execution, there also is no trace of it...

I tried flush (on the FdoIConnection), but to no avail.

Any thoughts?
Thanks!


Jackie Ng wrote:
If the subsequent FdoIDescribeSchema returns a FdoFeatureSchema containing your new class, then everything worked.

If you want to be doubly sure, take a look at the PostGIS database with pgAdmin and see if a new table (representing your new feature class) is there.

- Jackie
Traian Stanev

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink

Did you try cloning the schema object and using ApplySchema with this new object? The provider could be returning a cached pointer to its internal schema, which you end up modifying. Later when you ApplySchema it cannot detect any changes to the schema since it's the same object. Cloning would work around that.

Traian


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of VJ
Sent: Tuesday, April 14, 2009 3:27 PM
To: [hidden email]
Subject: RE: [fdo-users] Create an FdoFeatureClass?


That is my issue: it doesn't appear in PostGIS (no trace of it), I'm looking with pgadmin. :-(

>From in my program, everything seems in order (Schema contains class). But on the next execution, there also is no trace of it...

I tried flush (on the FdoIConnection), but to no avail.

Any thoughts?
Thanks!



If the subsequent FdoIDescribeSchema returns a FdoFeatureSchema containing your new class, then everything worked.

If you want to be doubly sure, take a look at the PostGIS database with pgAdmin and see if a new table (representing your new feature class) is there.

- Jackie


--
View this message in context: http://n2.nabble.com/Create-an-FdoFeatureClass--tp2611536p2634852.html
Sent from the FDO Users mailing list archive at Nabble.com.

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Greg Boone

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
In reply to this post by VJ
Could be a bug in the provider. I think it would have to be tested further.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of VJ
Sent: Tuesday, April 14, 2009 3:27 PM
To: [hidden email]
Subject: RE: [fdo-users] Create an FdoFeatureClass?


That is my issue: it doesn't appear in PostGIS (no trace of it), I'm looking with pgadmin. :-(

>From in my program, everything seems in order (Schema contains class). But on the next execution, there also is no trace of it...

I tried flush (on the FdoIConnection), but to no avail.

Any thoughts?
Thanks!



If the subsequent FdoIDescribeSchema returns a FdoFeatureSchema containing your new class, then everything worked.

If you want to be doubly sure, take a look at the PostGIS database with pgAdmin and see if a new table (representing your new feature class) is there.

- Jackie


--
View this message in context: http://n2.nabble.com/Create-an-FdoFeatureClass--tp2611536p2634852.html
Sent from the FDO Users mailing list archive at Nabble.com.

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
In reply to this post by Traian Stanev
Traian: I'll give cloning a go!

Greg: With the SHP provider, should it be possible to create a new shp file this way? I tried it, and on the describeSchemaCommand executed after the addition, the added class is not listed (and no new file is exists). This makes me wonder where the PostGIS describeSchema gets finds new class (seems like something of the creation has been cached...

Could the fact that my new class is still empty have something to do with it?
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
I couldn't figure out the cloning part... BUT in the documentation of IApplySchema I found "Implementors must call FdoFeatureSchema::AcceptChanges() when Execute() succeeds. It must be called after the schema has been successfully applied, in order to synchronize the states of the schema elements. "

So I decided to call AppectChanges after Execute, and... my table shows up! For the SHP provider, I get a .dbf file (as there are no geometries stored, it can make sense that there is no .shp file as of yet).

But am I misreading that documentation-quote, or should AcceptChanges have been called for me (who is ment by "Implementors": the ones using a provider, or the ones making a provider?)...?
Greg Boone

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
I believe the intent here is that providers that implement IApplySchema are required to call AcceptChanges on the Schema attached to the ApplySchema command, not the users.

Greg

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of VJ
Sent: Wednesday, April 15, 2009 9:29 AM
To: [hidden email]
Subject: RE: [fdo-users] Create an FdoFeatureClass?


I couldn't figure out the cloning part... BUT in the documentation of IApplySchema  I found "Implementors must call FdoFeatureSchema::AcceptChanges() when Execute() succeeds. It must be called after the schema has been successfully applied, in order to synchronize the states of the schema elements. "

So I decided to call AppectChanges after Execute, and... my table shows up! For the SHP provider, I get a .dbf file (as there are no geometries stored, it can make sense that there is no .shp file as of yet).

But am I misreading that documentation-quote, or should AcceptChanges have been called for me (who is ment by "Implementors": the ones using a provider, or the ones making a provider?)...?

--
View this message in context: http://n2.nabble.com/Create-an-FdoFeatureClass--tp2611536p2638742.html
Sent from the FDO Users mailing list archive at Nabble.com.

_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
VJ

RE: Create an FdoFeatureClass?

Reply Threaded More More options
Print post
Permalink
Greg Boone wrote:
I believe the intent here is that providers that implement IApplySchema are required to call AcceptChanges on the Schema attached to the ApplySchema command, not the users.
I guess calling it afterwards won't hurt either... :)

Just to let you guys know: database support in our software has been postponed to a later time, development will now shift to other specific issues and requested functionalities. As I result, I'll no longer continue working with FDO at this time (but no doubt it will return). :(

Thanks again for your help!