ThinkGeo.com    |     Blog    |     Wiki    |     Support

FileGeoDatabase - GetFirstFeaturesWellKnowType for Polyline - Returns Invalid

MapSuite Team,

The following code returns Invalid for those FileGeoDatabaseFeatureLayer that are actually Polyline.

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

TheFileGeoDatabaseFeatureLayer.Open();

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

Replace TheTableName in the above with “ATS_LINES” or “ROAD_LINES”. Use the data that I had previously uploaded to my ThinkGeo drive space at: home/Chicago_Data/GeoFileDatabase/Airport.

There are two anomalies with this as well.

First, with “ATS_LINES” or “ROAD_LINES” the below code returns a WellKnownType of Line.

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

Second, with “ATS_LINES” or “ROAD_LINES” the below code returns a WellKnownType of Polyline.

cAllFeatures = TheFileGeoDatabaseFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
foreach (Feature TheFeature in cAllFeatures)
{
    var TheWellKnownType = TheFeature.ColumnValues["Shape"];
}

Should not all three of the above return a value of Polyline?

Thanks,
Dennis

Hi Dennis,

Our Map don’t have a type named Polyline, all the polyline type will be included in our type line.

That’s why the TheFeature.GetWellKnownType() return line because the return value here is WellKnowType but the TheFeature.ColumnValues[“Shape”] is polyline because it’s string and this value is directly get from data.

About you mentioned the first item, it looks you hadn’t use correct table name here? I think the data type is related with table but not with entire FileGeoDatabase because it looks like a database, so if you don’t use correct table name it return invalid should be correct.

If I missed any point please let me know.

Regards,

Ethan

Ethan,

I’m not understanding your explanation.

Below is the Visual Studio Locals Window that shows the differing values of WellKnownType for ATS_LINES .

I would have thought that all three WellKnownType values would be Polyline.

The ShapeFileType has Polyline.

Thanks,
Dennis

    string TheLogMessage;

    string ThePath;
    string TheTable;
    string TheStartupDirectory;
    string TheProjectionString;

    Collection<string> TheGeoDatabaseTableNames;
    Collection<Feature> cAllFeatures;


    System.Type TheSystemType;
    ThinkGeo.MapSuite.Shapes.Projection    TheProjection;
    ThinkGeo.MapSuite.Shapes.WellKnownType TheWellKnownTypeFromFirstFeature;
    ThinkGeo.MapSuite.Shapes.WellKnownType TheWellKnownTypeFromFeatureItSelf;
    object                                 TheWellKnownTypeFromFeatureColumnValue;
    FileGeoDatabaseFeatureLayer            fileGeoDatabaseFeatureLayer;

    // save Current Drive & Directory
    TheStartupDirectory = Directory.GetCurrentDirectory();

    ThePath  = string.Format("{0}", "../../AppData/Airport");
    TheTable = string.Format("{0}", "ATS_LINES");

    TheGeoDatabaseTableNames = new Collection<string>();

    try
    {
        TheGeoDatabaseTableNames = FileGeoDatabaseFeatureLayer.GetTableNames(ThePath);
    }
    catch (Exception ex)
    {
        TheLogMessage = string.Format("FileGeoDatabaseFeatureLayer.GetTableNames({0}{1}Message={1})", ThePath, Environment.NewLine, ex.Message);
        return;
    }

    fileGeoDatabaseFeatureLayer = new FileGeoDatabaseFeatureLayer(ThePath, TheTable, "OBJECTID");

    fileGeoDatabaseFeatureLayer.Open();

    TheSystemType                    = fileGeoDatabaseFeatureLayer.FeatureSource.GetType();
    TheWellKnownTypeFromFirstFeature = fileGeoDatabaseFeatureLayer.FeatureSource.GetFirstFeaturesWellKnownType();

    cAllFeatures = fileGeoDatabaseFeatureLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

    if (cAllFeatures.Count > 0)
    {
        TheWellKnownTypeFromFeatureItSelf      = cAllFeatures[0].GetWellKnownType();

        TheWellKnownTypeFromFeatureColumnValue = cAllFeatures[0].ColumnValues["Shape"];
    }

    TheProjection       = fileGeoDatabaseFeatureLayer.FeatureSource.Projection;

    TheProjectionString = fileGeoDatabaseFeatureLayer.GetInternalProj4ProjectionParametersString();

    fileGeoDatabaseFeatureLayer.Close();

Hi Dennis,

I think only the “Invalid” have problem, the value here should be “Line” also.

In our map, we don’t have a type which is named PolyLine. The PolyLine is type for shape file format. When the shape feature is loaded into map, the type will be thought as Line, that’s why the TheWellKnownTypeFromFeatureItSelf equal Line.

The TheWellKnownTypeFromFeatureColumnValue equal “Polyline” is because it read the type directly from data and saved as a string but not an enumerator.

If you still be confused about it please let me know.

Edit:

Our developer check the logic here, the function GetFirstFeaturesWellKnownType works via GetDatasetDefinition API from the dll of ESRI, it looks the return value here is “invalid”. And when we checked the other tables, most of them can return valid value, so we think maybe the two tables which you mentioned return “Invalid” have problem in the table dataset definition. For make it works, please choose the other two items follow your requirement, you can break loop when you get the first valid type I think.

Regards,

Ethan