ThinkGeo.com    |     Documentation    |     Premium Support

FileGeoDatabase - GetFirstFeaturesWellKnownType - Returns Invalid

MapSuite Team,

FileGeoDatabaseFeatureLayer.FeatureSource.GetFirstFeaturesWellKnownType – always return Invalid.

TheFileGeoDatabaseFeatureLayer = new FileGeoDatabaseFeatureLayer(TheFilePath, TheTableName, "OBJECTID");

TheFileGeoDatabaseFeatureLayer.Open();

TheWellKnownType = TheFileGeoDatabaseFeatureLayer.QueryTools.GetFirstFeaturesWellKnownType();
TheWellKnownType = TheFileGeoDatabaseFeatureLayer.FeatureSource.GetFirstFeaturesWellKnownType();

The above lines always returns WellKnownType.Invalid.

However, these lines always return a valid value:

cAllFeatures = TheFileGeoDatabaseFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
foreach (Feature TheFeature in cAllFeatures)
{
    TheWellKnownType = TheFeature.GetWellKnownType();
}

The equivalent method for an SQLiteFeatureLayer is successful:

TheWellKnownType = TheSqliteFeatureLayer.GetFirstGeometryType();

Thanks,
Dennis

Hi Dennis,

I tested your code in our sample here: https://github.com/ThinkGeo/DisplayFileGeoDatabaseSample-ForWpf

It looks the QueryTools.GetFirstFeaturesWellKnownType() and FeatureSource.GetFirstFeaturesWellKnownType() return ThinkGeo.MapSuite.Shapes.WellKnownType.Polygon but not invalid.

So I think that’s should related with your data.

Regards,

Ethan

Hi Dennis,

I tested your Airport data and it looks also works well:

            FileGeoDatabaseFeatureLayer fileGeoDatabaseFeatureLayer = new FileGeoDatabaseFeatureLayer("../../AppData/Airport", "WATER");
        fileGeoDatabaseFeatureLayer.Open();


        var TheWellKnownType1 = fileGeoDatabaseFeatureLayer.QueryTools.GetFirstFeaturesWellKnownType();
        var TheWellKnownType2 = fileGeoDatabaseFeatureLayer.FeatureSource.GetFirstFeaturesWellKnownType();

Could you please double check that?

Regards,

Ethan

hi Ethan,

The below line of code returns a collection of table names. However, each name is preceded by a back-slash character as shown below in my application datagrid. My application programmatically uses the names in the collection as-is. The problem is the back-slash. If the back-slash is present, methods such as GetFirstFeaturesWellKnownType and GetInternalProj4ProjectionParametersString do not work. Remove the back-slash, as I’m now doing programmatically, and everything works.

Collection<string> TheGeoDatabaseTableNames = FileGeoDatabaseFeatureLayer.GetTableNames(ThePath);

To prevent future confusion it would be advisable to modify MapSuite GetTableNames such that leading back-slash is not included.

Thanks,
Dennis

Hi Dennis,

Thanks for your suggestion, I am not sure why the first slash is keep here, but I will let our development team knows your suggestion about it.

For now I think you can use this line to make it works in your scenario:

var tables = FileGeoDatabaseFeatureLayer.GetTableNames("../../AppData/Airport").Select(x => x.TrimStart('\\')).ToList();

Wish it’s helpful.

Regards,

Ethan