




已阅读5页,还剩6页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ArcEngine Geometry库定义了基本几何图形的矢量表达形式,顶级的几何图形有Points、Multipoints、Polylines、Polygons、 Multipatches,Geodatabase和绘图系统使用这些几何图形来定义其他各种形状的特征和图形,提供了编辑图形的操作方法和地图符号系统符号化特征数据的途径。 Geometry库中几个核心类和接口构成了Geometry对象的基本框架。 GeometryEnvironment GeometryEnvironment提供了从不同的输入、设置或获取全局变量来创建几何图形的方法,以便控制geometry方法的行为。GeometryEnvironment对象是一个单例对象。publicIPolylineTestGeometryEnvironment()ISpatialReferenceFactoryspatialReferenceFactory=newSpatialReferenceEnvironmentClass();/Createaprojectedcoordinatesystemanddefineitsdomain,resolution,andx,ytolerance.ISpatialReferenceResolutionspatialReferenceResolution=spatialReferenceFactory.CreateProjectedCoordinateSystem(int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_11N)asISpatialReferenceResolution;spatialReferenceResolution.ConstructFromHorizon();ISpatialReferenceTolerancespatialReferenceTolerance=spatialReferenceResolutionasISpatialReferenceTolerance;spatialReferenceTolerance.SetDefaultXYTolerance();ISpatialReferencespatialReference=spatialReferenceResolutionasISpatialReference;/CreateanarrayofWKSPointstructuresstartinginthemiddleofthex,ydomainofthe/projectedcoordinatesystem.doublexMin;doublexMax;doubleyMin;doubleyMax;spatialReference.GetDomain(outxMin,outxMax,outyMin,outyMax);doublexFactor=(xMin+xMax)*0.5;doubleyFactor=(yMin+yMax)*0.5;WKSPointwksPoints=newWKSPoint10;for(inti=0;iwksPoints.Length;i+)wksPointsi.X=xFactor+i;wksPointsi.Y=yFactor+i;IPointCollection4pointCollection=newPolylineClass();IGeometryBridge2geometryBridge=newGeometryEnvironmentClass();geometryBridge.AddWKSPoints(pointCollection,refwksPoints);IPolylinepolyline=pointCollectionasIPolyline;polyline.SpatialReference=spatialReference;returnpolyline; new GeometryEnvironmentClass仅仅是创建了一个指向已存在的GeometryEnvironmentClass的引用。注意 IGeometryBridge2接口的使用,addWKSPoints方法将WKSPoint二维点添加到PointCollection中,用于构建 path、ring、polyline、polygon,或增加新点到Multipoint、TriangleFan、TriangleStrip。在 Geometry库中,除了IGeometryBridge2还有IGeometryBridge接口,后者继承了前者,增加了一些编辑功能(添加点、插入点、重置点、分段等)。 GeometryBag GeometryBag是支持IGeometry接口的几何对象引用的集合,任何几何对象都可以通过IGeometryCollection接口添加到 GeometryBag中,但是在使用拓扑操作的时候,需要注意不同类型的几何类型可能会有相互不兼容的情况。在向GeometryBag中添加几何对象的时候,GeometryBag对象需要指定空间参考,添加到其中的几何对象均拥有和GeometryBag对象一样的空间参考。privateIPolygonGeometryBag_Example(IFeatureClassfeatureClass)/Checkinputobjects.if(featureClass=null)returnnull;IGeoDatasetgeoDataset=featureClassasIGeoDataset;ISpatialFilterqueryFilter=newSpatialFilterClass();/Setthepropertiesofthespatialfilterhere.IGeometrygeometryBag=newGeometryBagClass();/Definethespatialreferenceofthebagbeforeaddinggeometriestoit.geometryBag.SpatialReference=geoDataset.SpatialReference;/Useanonrecyclingcursorsoeachreturnedgeometryisaseparateobject.IFeatureCursorfeatureCursor=featureClass.Search(queryFilter,false);IGeometryCollectiongeometryCollection=geometryBagasIGeometryCollection;IFeaturecurrentFeature=featureCursor.NextFeature();while(currentFeature!=null)/Addareferencetothisfeaturesgeometryintothebag./Youdontspecifythebeforeoraftergeometry(missing),/sothecurrentFeature.ShapeIGeometryisaddedtotheendofthegeometryCollection.objectmissing=Type.Missing;geometryCollection.AddGeometry(currentFeature.Shape,refmissing,refmissing);currentFeature=featureCursor.NextFeature();/Createthepolygonthatwillbetheunionofthefeaturesreturnedfromthesearchcursor./Thespatialreferenceofthisfeaturedoesnotneedtobesetaheadoftime.The/ConstructUnionmethoddefinestheconstructedpolygonsspatialreferencetobethesameas/theinputgeometrybag.ITopologicalOperatorunionedPolygon=newPolygonClass();unionedPolygon.ConstructUnion(geometryBagasIEnumGeometry);returnunionedPolygonasIPolygon; Points 一个点包括X、Y坐标,同时可以增加M、Z值及ID属性来扩展点的功能。 Multipoints 点的集合,多点组成Multipoint几何类型,使用multipoint对象实现了的IPointCollection接口可以访问所有的点元素,这些点同样可以拥有M、Z值及ID属性来获得更多的地理空间内涵。 下面列举一个例子,通过一个已知的polyline来定义一个新的multipart polyline。publicIPolylineConstructMultiPartPolyline(IPolylineinputPolyline)IGeometryoutGeometry=newPolylineClass();/Alwaysassociatenew,top-levelgeometrieswithanappropriatespatialreference.outGeometry.SpatialReference=inputPolyline.SpatialReference;IGeometryCollectiongeometryCollection=outGeometryasIGeometryCollection;ISegmentCollectionsegmentCollection=inputPolylineasISegmentCollection;/Iterateoverexistingpolylinesegmentsusingasegmentenumerator.IEnumSegmentsegments=segmentCollection.EnumSegments;ISegmentcurrentSegment;intpartIndex=0;intsegmentIndex=0;segments.Next(outcurrentSegment,refpartIndex,refsegmentIndex);while(currentSegment!=null)ILinenormal=newLineClass();/Geometrymethodswith_Query_intheirnameexpecttomodifyexistinggeometries./Inthiscase,theQueryNormalmethodmodifiesanexistingline/segment(normal)tobethenormalvectorto/currentSegmentatthespecifiedlocationalongcurrentSegment.currentSegment.QueryNormal(esriSegmentExtension.esriNoExtension,0.5,true,currentSegment.Length/3,normal);/Sinceeachnormalvectorisnotconnectedtoothers,createanewpathforeachone.ISegmentCollectionnewPath=newPathClass();objectmissing=Type.Missing;newPath.AddSegment(normalasISegment,refmissing,refmissing);/ThespatialreferenceassociatedwithgeometryCollectionwillbeassignedtoallincomingpathsandsegments.geometryCollection.AddGeometry(newPathasIGeometry,refmissing,refmissing);segments.Next(outcurrentSegment,refpartIndex,refsegmentIndex);/ThegeometryCollectionnowcontainsthenew,multipartpolyline.returngeometryCollectionasIPolyline; ISegment接口的QueryNormal方法用来在弧段上的某一点生成该弧段的法线,指定其长度,这样就生成了新的segment,并且多个path添加到geometryCollection中,以IPolyline的形式返回。 Polylines Polylines是有序path组成的集合,可以拥有M、Z和ID属性值。Polyline对象的IPointCollection接口包含了所有节点的复制,IGeometryCollection接口可以获取polyline的paths,ISegmentCollection接口可以获取 polyline的segments。 Polyline结构图 Polygons Polygon是一系列rings组成的集合,可以拥有M、Z和ID属性值。每一个ring由一个或多个segment组成,Polygon或ring对象的IPointCollection接口包含了所有节点的复制,IGeometryCollection接口可以获取polygon的rings, ISegmentCollection接口可以获取polygon的segments。 Polygon结构图 Multipatch Multipatch用于描述3D面状几何类型,由一系列的矢量三角形构成,如果其中的part是一个ring,那么它必须是封闭的,第一个节点和最后一个节点相同,另外每个part所包含节点的顺序非常重要,Inner Rings在Outer Rings之后,代表单个表面patch的一系列rings必须由第一个ring开始。在9.0以后的开发包中,使用IGeneralMultiPatchCreator创建新的Multipatch,IGeometryMaterial进行材质贴图。publicIMultiPatchCreateMultipatch()/Preparethegeometrymateriallist.IGeometryMaterialtexture=newGeometryMaterialClass();texture.TextureImage=C:TempMyImage.bmp;IGeometryMaterialListmaterialList=newGeometryMaterialListClass();materialList.AddMaterial(texture);/Createthemultipatch.IGeneralMultiPatchCreatormultiPatchCreator=newGeneralMultiPatchCreatorClass();multiPatchCreator.Init(4,1,false,false,false,4,materialList);/Setuppart./CouldalsouseaRingoraTriangleFan.multiPatchCreator.SetPatchType(0,esriPatchType.esriPatchTypeTriangleStrip);multiPatchCreator.SetMaterialIndex(0,0);multiPatchCreator.SetPatchPointIndex(0,0);multiPatchCreator.SetPatchTexturePointIndex(0,0);/Setreal-worldpoints.WKSPointZupperLeft=newWKSPointZ();WKSPointZlowerLeft=newWKSPointZ();WKSPointZupperRight=newWKSPointZ();WKSPointZlowerRight=newWKSPointZ();upperLeft.X=0;upperLeft.Y=0;upperLeft.Z=0;upperRight.X=300;upperRight.Y=0;upperRight.Z=0;lowerLeft.X=0;lowerLeft.Y=0;lowerLeft.Z=-100;lowerRight.X=300;lowerRight.Y=1;lowerRight.Z=-100;multiPatchCreator.SetWKSPointZ(0,refupperRight);multiPatchCreator.SetWKSPointZ(1,reflowerRight);multiPatchCreator.SetWKSPointZ(2,re
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 108.教育经费执行动态监测报告撰写考核卷
- 2025年湖北中烟笔试试题
- 难点解析人教版八年级物理上册第5章透镜及其应用-透镜综合练习练习题
- 综合解析人教版八年级物理《压强》专项训练试题(含答案解析)
- 2025年结构力学试题及参考答案
- 2025年福建南平注册环保工程师考试模拟题库及答案:(大气污染防治专业案例)
- 城市道路高清视频监控系统方案
- 2025年金属冶炼单位主要负责人考试(金属冶炼(炼铁))仿真试题及答案
- 超市监控施工方案
- 2025金属非金属矿山主要负责人和安全生产管理人员考试考前冲刺试题及答案
- 山东初级注安师考试题库及答案
- 线粒体基因糖尿病讲解
- 会计行业巅峰备战:会计分录面试题解及例题集锦服务
- 鸿蒙应用开发案例实战(ArkTS版)(AI助学)(微课版) 课件全套 项目1-7 初探HarmonyOS开发 个性化设置应用 - 融会贯通 七彩天气App开发之旅
- 藏菜生长技术指导
- 2025至2030内窥镜市场前景分析及发展趋势分析与未来投资战略咨询研究报告
- 寝室卫生课件
- 政府EPC工程总承包管理课件
- TCITS 288-2025 饮用水处理装置高效净化全氟及多氟化合物试验方法及分级要求
- 上海市闵行区民办上宝中学2025届英语八年级第二学期期中达标检测模拟试题含答案
- 北京市国有及国有控股负责人经营业绩考核暂行办法
评论
0/150
提交评论