ThinkGeo.com    |     Documentation    |     Premium Support

FeatureSource.GetColumns() returns empty list

Hi,

I’ve just upgraded to version 9 recently and one of the changes is related to feature source columns being eventually deprecated for feature layer. I don’t see any notes on what this will actually mean when it happens…

When I pass a feature layer to another procedure to process it, I can see the feature source columns in it by mouse over the object; however, when I try to return the columns using

fl.FeatureSource.GetColumns()

the return is an empty list. What is more if I mouse over the object after calling this method, I find the columns that were listed before are now gone!

My main issue with this is that feature class doesn’t support anything other than string for column values and I need to be able to write out shapefiles with specific types like integer, double, datetime. If I can’t get feature source column from the feature source anymore, how do I do it?

Regards,
Damian

Hi Damian,

Please show us more code about your issue and your detail dll version, I did a quickly test for that, but it looks the GetColumns works well, I tested the ShapeFileFeatureLayer class.

If you want to know what’s the type of the string in column, I think you can create the other item saved it’s type in it.

Regards,

Don

Hi Don,

Here are two screen shots. I am using 9.0.0.484.

If you have a look at the code, I am also executing the GetFirstFeaturesWellKnownType() procedure. I didn’t check it, but it may be that this is where the columns disappear.

Finally, I didn’t get your comment on how to get the type to the shape with no featuresourcecolumns. Can you provide an example?

As an aside, this is a new user I had to create because of licensing agreement transfer. Is there a way to get my posts from my old account migrated?

Before

And after

Hi Damian,

  1. Could you please test with development dll again, and if that still works I need some sample code and a simple sample data for reproduce that.

  2. I means, if you want to save the data type into feature, you can create a new ColumnName in feature, for example: DataType, then you can set it value like “String”, “Int”, “DateTime”. So when you want to save the feature into file, you can read the “DataType” column and know what’s the data format.

  3. I don’t understand about the “licensing agreement transfer”, but if you means you forget old account, I think that’s not a problem, because you can find your original forum name and view your posts like this:
    http://community.thinkgeo.com/users/“Your Old ID”/activity/topics

Wish that’s helpful.

Regards,

Don

Hi Don,

I don’t think point 2 works well. If you have N columns, then you must have N data type fields to express them all. Plus, you should also be supplying N field lengths just as in FeatureSourceColumn so you have efficient file sizes. This also means there must be some standard naming scheme to pair them properly as well. I’m really interested to know the fate of FeatureSourceColumn now…

I’ll get you a test project hopefully by tomorrow. I did find out that it was at GetFirstFeatureWellKnownType() that the columns disappeared.

I was able to find my old user which is now renamed to Damian1 for some reason since the new blog came out. Thanks.

Best Regards,
Damian

Hi Damian,

Yes you’re right, so that’s just a workaround. You can also add pre-type in the data, and remove it before saved back.

I think maybe saved as string won’t be modified near future.

When we moved to the new forum, the same name had been renamed follow register time by system.

Regards,

Don

Hi Don,

Sorry for the delay on this test project. It’s really simple and shows the issue.

GetColumnsTest.zip (21.0 KB)

Regards,
Damian

Hi Damian,

Thanks for your sample, that’s a bug introduced when our developer fix another issue.

We will try to fix that quickly, for a workaround, please pass the columns when initialization like this:

Collection<FeatureSourceColumn> theColumns = new Collection<FeatureSourceColumn>();
        theColumns.Add(new FeatureSourceColumn("Test1", "INT", 5));
        theColumns.Add(new FeatureSourceColumn("Test2", "TEXT", 5));
        theColumns.Add(new FeatureSourceColumn("Test3", "INT", 5));

        InMemoryFeatureLayer imfl = new InMemoryFeatureLayer(theColumns);

        imfl.Open();
        Collection<FeatureSourceColumn> aacolumns = imfl.GetColumns();

Which can works well.

Regards,

Don

Hi Damian,

We have fixed columns bug. Please download version 9.0.720.0.

If you have any questions, please feel free to contact us.

Thanks,