Open various types of featureclass (VB. NET source code)

Source: Internet
Author: User

 

 

# 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.