# Region "open various types of featureclass"
''' <Summary>
'''Open access and return featureclass
''' </Summary>
''' <Param name = "sdbname"> Access File Name (full path) </param>
''' <Param name = "sfcname"> featureclass name </param>
''' <Returns> element class featureclass </returns>
''' <Remarks> </remarks>
Public Function openaccessdatabase (byval sdbname as string, byval sfcname as string) as ifeatureclass
dim ppropset as ipropertyset
ppropset = new propertyset
dim pfact as iworkspacefactory
dim pworkspace as iworkspace
ppropset. setproperty ("Database", sdbname)
pfact = new accessworkspacefactory
pworkspace = pfact. open (ppropset, 0)
dim pfeatureworkspace as ifeatureworkspace
pfeatureworkspace = pworkspace
dim pfeatureclass as ifeatureclass
pfeatureclass = pfeatureworkspace. openfeatureclass (sfcname)
return pfeatureclass
end function
'''
''' open the shapefile, return featureclass
'''
''' shapefile path
''' featureclass name
''' element class featureclass
'''
Public Function openshapefile (byval sdbname as string, byval sfcname as string) as ifeatureclass
Dim ppropset as ipropertyset
Ppropset = new propertyset
Dim pfact as iworkspacefactory
Dim pworkspace as iworkspace
Ppropset. setproperty ("Database", sdbname)
Pfact = new shapefileworkspacefactory
Pworkspace = pfact. Open (ppropset, 0)
Dim pfeatureworkspace as ifeatureworkspace
Pfeatureworkspace = pworkspace
Dim pfeatureclass as ifeatureclass
Pfeatureclass = pfeatureworkspace. openfeatureclass (sfcname)
Return pfeatureclass
End Function
''' <Summary>
''' Open SDE and return featureclass
''' </Summary>
''' <Param name = "sservername"> SDE service name </param>
''' <Param name = "sfcname"> featureclass name </param>
''' <Returns> element class featureclass </returns>
''' <Remarks> </remarks>
Public Function opensde (byval sservername as string, byval sfcname as string) as ifeatureclass
Dim ppropset as ipropertyset
Ppropset = new propertyset
Dim pfact as iworkspacefactory
Dim pworkspace as iworkspace
With ppropset
. Setproperty ("server", sservername)
. Setproperty ("instance", "sdemss ")
. Setproperty ("Database", "SDE") 'ignored with ArcSDE for Oracle
. Setproperty ("user", "SDE ")
. Setproperty ("password", "go ")
. Setproperty ("version", "SDE. Default ")
End
Pfact = new sdeworkspacefactory
Pworkspace = pfact. Open (ppropset, 0)
Dim pfeatureworkspace as ifeatureworkspace
Pfeatureworkspace = pworkspace
Dim pfeatureclass as ifeatureclass
Pfeatureclass = pfeatureworkspace. openfeatureclass (sfcname)
Return pfeatureclass
End Function
''' <Summary>
''' Open raster and return Dataset
''' </Summary>
''' <Param name = "sdir"> path name </param>
''' <Param name = "sfile"> file name </param>
''' <Returns> return rasterdataset </returns>
''' <Remarks> </remarks>
Public Function openrasterdataset (byval sdir as string, byval sfile as string) as irasterdataset
'Open the raster dataset with the given name.
'sdir is the directory the file resides
'sfile is the filename
dim pwsfact as iworkspacefactory
dim PWS as irasterworkspace
dim prasterdataset as irasterdataset
'Open the workspace
pwsfact = new rasterworkspacefactory
PWS = pwsfact. openfromfile (sdir, 0)
'Open the raster dataset
prasterdataset = PWS. openrasterdataset (sfile)
'Return
pwsfact = nothing
PWS = nothing
prasterdataset = nothing
return prasterdataset
end function
# End Region