ThinkGeo.com    |     Documentation    |     Premium Support

Access ShapeType and check for duplicate columns in featureLayer

I am trying to determine on the fly what type of shape a feature layer includes. I also want to check for duplicate column names, because that has caused us issues in the past. 


Currently I do something relatively ugly and loop through the features, grab the first valid one, check it's shape type and do layer.FeatureSource.GetColumns() to determine if it has any duplicate columns.


This code is pretty old; I'm wondering if there is a simpler way to do this? Is there a way to access the shape type directly from the layer or featuresource? 



If you are using a shapefile as the layer format, you can use the GetShapeFileType() function to get the shape type directly from the layer. 
  
 layer.Open(); 
 ShapeFileType shapeFileType = layer.GetShapeFileType(); 
  
 If you are using another type, I would look for a similar function, if not then you can use the method you are currently using.

Val,


We do support mutliple map sources, but a majority are Shape File so I might be able to get away with using that for most. 


I ended up trying this: layer.FeatureSource.GetFirstFeaturesWellKnownType(); Which seems to have workd. Any reason why I shouldn't use this?


 


Thanks for the help Val. 



Kevin, 
  
 Thanks for your post and qustion. 
  
 I think for ShapeFileFeatureLayer, the GetShapeFileType will be much faster than the GetFirstFeturesWellKnownType,  because the latter API will get all the features first. 
  
 About the duplicate columns, I suggest you using the GetColumns API and check the returning columns. 
  
 Any more questions just feel free to let us know. 
  
 Thanks. 
  
 Yale