FeatureLayer geometry type?

525
1
Jump to solution
06-02-2020 02:39 PM
MikeQuetel1
Occasional Contributor

Hi,

I'm programmatically adding a bunch of feature layers to a map from a local, runtime geodatabase.  Prior to adding to the map, I would like to get the geometry type of the feature table (or feature layer).  Can someone assist me with the most efficient way to get that info?  I'm pretty new to QML.

Thanks in advance!

Mike

0 Kudos
1 Solution

Accepted Solutions
LucasDanzinger
Esri Frequent Contributor

You could do something like this:

// create the geodatabase
Geodatabase {
    id: gdb
    path: dataPath + "geodatabase/LA_Trails.geodatabase"

    Component.onCompleted: load();

    onLoadStatusChanged: {
        if (loadStatus === Enums.LoadStatusLoaded) {
            console.log("Geodatabase loaded");
            for (var i = 0; i < geodatabaseFeatureTables.length; i++) {
                const ft = geodatabaseFeatureTables[i];

                ft.loadStatusChanged.connect(()=>{
                                                 if (ft.loadStatus === Enums.LoadStatusLoaded) {
                                                     if (ft.geometryType === Enums.GeometryTypePoint) {
                                                         console.log("this is a point")
                                                     } else if (ft.geometryType === Enums.GeometryTypePolygon) {
                                                         console.log("this is a polygon")
                                                     } else if (ft.geometryType === Enums.GeometryTypePolyline) {
                                                         console.log("this is a polyline")
                                                     }
                                                 }
                                             });
                ft.load();
            }
        }
    }
}

View solution in original post

1 Reply
LucasDanzinger
Esri Frequent Contributor

You could do something like this:

// create the geodatabase
Geodatabase {
    id: gdb
    path: dataPath + "geodatabase/LA_Trails.geodatabase"

    Component.onCompleted: load();

    onLoadStatusChanged: {
        if (loadStatus === Enums.LoadStatusLoaded) {
            console.log("Geodatabase loaded");
            for (var i = 0; i < geodatabaseFeatureTables.length; i++) {
                const ft = geodatabaseFeatureTables[i];

                ft.loadStatusChanged.connect(()=>{
                                                 if (ft.loadStatus === Enums.LoadStatusLoaded) {
                                                     if (ft.geometryType === Enums.GeometryTypePoint) {
                                                         console.log("this is a point")
                                                     } else if (ft.geometryType === Enums.GeometryTypePolygon) {
                                                         console.log("this is a polygon")
                                                     } else if (ft.geometryType === Enums.GeometryTypePolyline) {
                                                         console.log("this is a polyline")
                                                     }
                                                 }
                                             });
                ft.load();
            }
        }
    }
}