ArcObjects.docx

上传人:b****0 文档编号:10109996 上传时间:2023-05-23 格式:DOCX 页数:21 大小:599.83KB
下载 相关 举报
ArcObjects.docx_第1页
第1页 / 共21页
ArcObjects.docx_第2页
第2页 / 共21页
ArcObjects.docx_第3页
第3页 / 共21页
ArcObjects.docx_第4页
第4页 / 共21页
ArcObjects.docx_第5页
第5页 / 共21页
ArcObjects.docx_第6页
第6页 / 共21页
ArcObjects.docx_第7页
第7页 / 共21页
ArcObjects.docx_第8页
第8页 / 共21页
ArcObjects.docx_第9页
第9页 / 共21页
ArcObjects.docx_第10页
第10页 / 共21页
ArcObjects.docx_第11页
第11页 / 共21页
ArcObjects.docx_第12页
第12页 / 共21页
ArcObjects.docx_第13页
第13页 / 共21页
ArcObjects.docx_第14页
第14页 / 共21页
ArcObjects.docx_第15页
第15页 / 共21页
ArcObjects.docx_第16页
第16页 / 共21页
ArcObjects.docx_第17页
第17页 / 共21页
ArcObjects.docx_第18页
第18页 / 共21页
ArcObjects.docx_第19页
第19页 / 共21页
ArcObjects.docx_第20页
第20页 / 共21页
亲,该文档总共21页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

ArcObjects.docx

《ArcObjects.docx》由会员分享,可在线阅读,更多相关《ArcObjects.docx(21页珍藏版)》请在冰点文库上搜索。

ArcObjects.docx

ArcObjects

2012/11/23Fri

1"esriControls.ControlsSelectFeaturesTool"、esriControls.ControlsAddDataCommand"esriControls.ControlsMapNavigationToolbar"、"esriControls.ControlsOpenDocCommand"

2内建的命令LearningArcObjects/GeneralAOreferences/NamesandIDs/各种内建命令的列表

http:

//127.0.0.1:

47873/help/1-6012/ms.help?

method=page&id=ARCOBJECTS_NET-36DA4D45-0002D3&product=VS&productversion=100&locale=en-US&topiclocale=EN-US&topicversion=0&SQM=2

3加载内建命令时,字符串内部不能有空格,不然直接报thesuppliedcommandisinvalid

4更新要素:

IFeature.Value()=……IFeature.Store();

5IRowSubtypesrowSubtypes

rowSubtypes.SubtypeCode=IEditLayers.CurrentSubtype;

rowSubtypes.InitDefaultValues();

feature.Store();

6更新一组要素,用CURSOR

Acursorisadataaccessobjectthatcanbeusedtoiterateover asetofrowsinatableortoinsertnewrowsintoatable.

7如果是用于更新要素的话,可用SEARCHCURSOR或者UPDATE CURSOR。

在Desktop中,用SEARCH CURSOR(NextFeature获得要素,再用IFeature.set_Value设置值,再IFeature.Store())好,因为它会使用MAP CACHE,效率更高。

如果在AE中处理复杂要素,则UPDATE CURSOR一次直接从DB读一行可能更适合。

8Search Cursor用 Store()来提交,Update Cursor用UpdateFeature()

9IFeatureCursorupdateCursor=featureClass.Update(queryFilter,false);

feature=updateCursor.NextFeature()

feature.set_Value(typeFieldIndex,"TollHighway");

updateCursor.UpdateFeature(feature);

10IEditor.EditSelection:

IEnumFeature。

如果选中的要素来自不同的图层的话,需要另外进行处理

11IEnumFeature.Next().Reset()%EditSelection%MapSelection

12 editsession 有时影响性能。

13在 editsession 外面,用ITransactions显式地开始一个事务。

不支持嵌套事务,不能在事务中对复杂要素进行更新。

14ITransaction.AbortTransaction()CommitTransaction()InTransaction:

boolStartTransaction()%Sde3WorkspaceSde4WorkspaceVersionedWorkspaceWorkspace

15已经有事务在进行的话,重新发起会话等于没干活。

16ITransactions不能用于SchemaEdits,不用于DDL

17如果直接对GDB中的数据使用SQL语句的话,原来由GDB维护的表之间的关系之类的,不会被维护。

但是如果要的表中的数据不涉及geodatabasebehavioralconstraintsordatavalidationrules用SQL语句效率比较高。

18除非用于ArcSDEMultiversionedview,不要对Versioned数据使用SQL语句。

19用完SQL语句之后,加个COMMIT或者ROLLBACK,因为DBMS可能会等待未提交的会话提交,比如COMPRESS操作就是如此。

20用SQL语句的话,不要修改那些会经由GDB的相关规则而影响其它数据的数据。

21如果要素类的Geometry参与到拓扑、网络、关系中去了,不要用SQL语句改它。

可以读,但是,它们无法正确地进行相关修改。

22Row_ID(ObjectID)不能改。

2012/11/24Sat

1IFeatureBuffer.Fields{get;}:

IFields.Shape.get_Value.set_Value%Feature类似于IRowBuffer,主要用于InsertFeatureCursor

2rasOut=(IRaster)mapAlgebraOp.Execute(expression);

IRasterBandCollectionrasterBandCollection=(IRasterBandCollection)rasOut;

IRasterBandrasterBand=rasterBandCollection.Item(0);

IRasterDatasetrasterDataset=rasterBand.RasterDataset;

//QuerythedatasetforITemporaryDataset.

ITemporaryDatasettemporaryDataset=(ITemporaryDataset)rasterDataset;

if(temporaryDataset.IsTemporary())//我试过那么久,这个判断竟然为假

{

temporaryDataset.MakePermanent();

}

3ITemporaryDatasetisnotsupportedbya RasterDataset instancefroman ArcSDEgeodatabaseoraFilegeodatabase.TemporaryrasterdatasetsarecreatedbymostoperationsperformedbytheSpatialAnalystExtensionandalsocanbecreatedusing IRasterWorkspace2:

:

CreateRasterDataset method.

MakePermanentmethodchangethestatusofadatasetfromtemporarytopermanent.Ifthedatasetispermanent, MakePermanentdoesnothing.

MakePermanentAsmethodmakesthecurrentdatasetpermanentbycreatinganewrasterdatasetthatcontainsthesamedata. Thecurrentrasterdatasetwillbedeletedwhenallreferencestoitarereleased.ThesupportedoutputformatsaresameasISaveAs.

4publicIDatasetITemporaryDataset.MakePermanentAs(

    stringnew_name,

    IWorkspaceWorkspace,

    stringFormat);

5ITemporaryDataset.IsTemporary().MakePermanent().MakePermanentAs()%FunctionRasterDataset%RasterDataset

6ISaveAs.CanSaveAs(stringfromat):

bool,

7publicIDatasetISaveAs.SaveAs(stringName, IWorkspaceWorkspace, stringFormat);

FormatName

StringUsed

Imagine

"IMAGINEImage"

TIFF

"TIFF"

GRID

"GRID"

JPEG

"JPG"

JP2000

"JP2"

BMP

"BMP"

PNG

"PNG"

GIF

"GIF"

PCIRaster

"PIX"

X11Pixmap

"XPM"

PCRaster

"MAP"

MemoryRaster

"MEM"

HDF4

"HDF4"

BIL

"BIL"

BIP

"BIP"

BSQ

"BSQ"

IdrisiRasterFormat

"RST"

ENVIRasterFormat

"ENVI"

GeodatabaseRaster

"GDB"

7ISaveAs%MosaicRaster%Raster%RasterDataset

8ISaveAs2多一个publicIRasterDatasetSaveAsRasterDataset(stringName,IWorkspaceWorkspace,stringFormat,IRasterStorageDefStorageDef);

9saveAs.SaveAs(@"c:

\temp\image1.img",null,"IMAGINEImage");

2012/11/25Sun

1IWorkspace2 只有一个boolget_NameExists(esriDatasetTypeType,stringName);%Sde4Workspace%Workspace

2

3要查找一个DS中是不是有某个FC,用IFeatureClassContainer:

:

ClassByName,因为NameExists会在整个Workspace中找。

4publicclassCreateRandomPoints:

ESRI.ArcGIS.Geoprocessor.ESRI.ArcGIS.Geoprocessor.IGPProcess

2012/11/26Mon

1InArcGIS10,youneedtosettheproductthatwillexecutethecodebytheRuntimeManager.AddESRI.ArcGIS.Versiontoyourprojectasareference.However,youdon'tneedtoaddthenamespacetoyourcodewiththeusingkeyword.

2RuntimeManager.Bind(ProductCode.EngineOrDesktop)

3使用ArcView或ArcEditorlicense,必须使用 AoIntialize,andtheproductmustbesettoArcVieworArcEditor,否则会失败。

geoprocessor默认假定使用一个工具需要ArcInfolicense

4ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);

//Initializetheapplication.

esriLicenseStatuslicenseStatus=esriLicenseStatus.esriLicenseUnavailable;

IAoInitializem_AoInitialize=newAoInitializeClass();

licenseStatus=m_AoInitialize.Initialize

(esriLicenseProductCode.esriLicenseProductCodeArcInfo);

licenseStatus=m_AoInitialize.CheckOutExtension

(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);

//Initializethegeoprocessor.

Geoprocessorgp=newGeoprocessor();

SlopetSlope=newSlope();

tSlope.in_raster=@"E:

\Data\demlatgrd";

tSlope.out_raster=@"E:

\Data\aspect03";

gp.Execute(tSlope,null);

licenseStatus=m_AoInitialize.CheckInExtension

(esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst);

m_AoInitialize.Shutdown();

m_AoInitialize=null;

5DLL不需要用AoInitialize 配置License,因为它会加到某个程序中,由那个程序来配置

6一般有两种License要配置

a) esriLicenseProductCodes

esriLicenseExtensionCodes多达57种……

7License类型:

a)EngineSingleUse:

ArcGISEngine或EnginewithGeoDatabaseEditinglicenses.

b)DesktopConcurrentlicenses:

DesktopconcurrentArcView,ArcEditorandArcInfolicenses.

c)DesktopSingleUselicensesusethesametechnologyasDesktopConcurrentlicensesandprovideaccesstoSingleUseArcView,ArcEditorandArcInfolicenses. 应该与上一个视作相同的,因为没什么差别

8设置License的步骤

a)esriLicenseStatusIAoInitialize.IsProductCodeAvailable(esriLicenseProductCodeProductCode);

9调用Analysis中的Erase出错的原因:

AE的License初始化有两种方式:

1、采用LicenseControl控件初始化

我想这也是大部分的开发者所采用的。

但要注意的是,AE的License有着同ArcGISDesktop一样的级别控制。

可以在控件的属性中设置,如下图:

 

 

但更要注意的是,千万不要贪多而勾选我多个级别的License。

LicenseControl的License级别只有第一个勾选的生效!

因为高级别的License已经包含了较低级别的,所以多选了不但无益,反而坏事了!

2、采用代码初始化License

这种方法相信很少人用,但要注意的也是不要初始化多个License级别了,只要初始化你需要的最高级别的License就可以了,先初化的生效!

原因同上。

代码如下:

1.IAoInitializem_AoInitialize=newAoInitializeClass();

2.esriLicenseStatuslicenseStatus=esriLicenseStatus.esriLicenseUnavailable;

3.licenseStatus=m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcInfo);

4.//下面的初始化不会生效!

5.licenseStatus=m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);

复制代码

回到我原来的问题上来,因为Near工具是ArcInfo级别的,而Buffer工具好像是ArcView级别的,所以出现了在同一位置的工具,有的能执行,有的不能执行的怪事!

我原来勾选了多个License级别,而ArcInfo恰恰在最后,所以它一直没生效,所以Near工具一直不执行,所以有了这篇帖子!

(呵呵,不好意思,我是菜鸟!

)在这里建议ESRI把级别高的License放到前面去,这样不是更省事了,呵呵。

9TheAppendtool'sFieldMapcontrol控制输入的DS的属性如何转入目标DS中.只有SchemaTypeNO_TESTisspecified.时才能用

10SCHEMATYPE为TEST时,输入的DS与目标DS的列必须是相同的,为NO_TEST时,不必相同,但除非在FieldMapcontrol中进行了映射,否则输入DS中与目标DS中不同的列都会被省略。

Marshal.ReleaseComObjectMethod(System.Runtime.InteropServices)在AO中则是ESRI.ArcGIS.ADF.Connection.Local库中ESRI.ArcGIS.ADF.ComReleaser.ReleaseComObject()

11In.NETcode,referencestoCOMobjectsareheldviaruntimecallablewrappers(RCWs),managedobjects thatactasproxyobjectsfortheunderlyingCOMobject.

12COMobjectsleftinmemoryforanextendedperiodafteruse cancauseproblemsanderrorsonshutdown.SingletonsareatypeofCOMobjectthathaveonlyoneinstanceperprocess.Youmightfindyourcoderesultsinerrorsifsingletonsarelefthanging(aprocessknownaspinning).Inthecaseofsingletons,itisnecessarytoalwaysunpin(orrelease)thereference,regardlessofthespecificapplicationprogramminginterface(API)youareusing.Fornon-.NETAPIs,setthemembervariableequaltonothing.Forthe.NETAPI,releasethesingletonCOMobjectusingtheComReleaserclass

2012/11/27Tuesday

1IRasterDatasetrstDs=rstWs.OpenRasterDataset("slide.tif");

IRaster2raster2=rstDs.CreateDefaultRaster()asIRaster2;跑第一句时slide.tif所在的文件夹还没出现锁slide.tif.vat.dbf.PETERS-PC.7500.5704.sr.lock,跑完第二句就出来了

2接下来又有这句。

IRasterCursorrasterCursor=raster2.CreateCursorEx(null);用完这个Cursor,并用

ComReleaser.ReleaseCOMObject(rasterCursor);释放掉之后,锁就不见了。

..刚重试的时候,翻译掉Cursor没用,释放掉上面的raster2才行。

3用Geoprocessor运行Sample这个工具之后,在Sample用到的其中的一个栅格slide.tif上也出现了一个锁slide.tif.vat.dbf.PETERS-PC.7500.5704.sr.lock。

光是设置Sample参数不会产生锁,调用GP的Execute才产生锁。

但是释放掉GP或者Sample都不能让锁消失。

关掉正在调试的程序,那个锁不见了,直接停止调试,过了一会锁才消失。

4停止vshost.exe进程之后,在2那里,释放掉Cursor锁就不见了。

2012/12/04

1IFeatureClass.FeatureClassID只读,返回FeatureClass的UniqueID。

GDB中的FeatureClass有唯一的ID.Coverage和Shapefile中的FC没有,因此会返回-1。

由于FeaturesClassic继承自IObjectClass,也可由IobjectClass.ObjectClassID得到该值。

2ObjectClassID:

registeredwiththegeodatabase的featureclassortable是objectclass.Objectclasses的ID唯一,以与GDB中其它ObjectClass区分。

TheobjectclassID在创建或者注册到GDB时由系统分配不能更改。

在DB中但没有注册到GDB中的featureclassesandtables的objectclassID为-1.

3IfeatureClass.IfeatureClassID:

只读,返回 the IFeatureDataset interfaceonthefeaturedatasetthatthisfeatureclassisamemeberof. 如果是StandAlone的FeaturesClassic,没有相应的Dataset的话,返回Null。

coveragefeatureclass则会返回自己,Shapef

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2