.Y=yFactor+i;
}
IPointCollection4pointCollection=newPolylineClass();
IGeometryBridge2geometryBridge=newGeometryEnvironmentClass();
geometryBridge.AddWKSPoints(pointCollection,refwksPoints);
IPolylinepolyline=pointCollectionasIPolyline;
polyline.SpatialReference=spatialReference;
returnpolyline;
}
newGeometryEnvironmentClass仅仅是创立了一个指向已存在的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来界说一个新的multipartpolyline。
以下为援用的内容:
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所包括节点的按次十分主要,InnerRings在OuterRings以后,代表单个外表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,refupperLeft);
multiPatchCreator.SetWKSPointZ(3,reflowerLeft);
//Settexturepoints.
//Setthetexturecoordinatesforapanel.
WKSPointtextureUpperLeft=newWKSPoint();
WKSPointtextureLowerLeft=newWKSPoint();
WKSPointtextureUpperRight=newWKSPoint();
WKSPointtextureLowerRight=newWKSPoint();
textureUpperLeft.X=0;
textureUpperLeft.Y=0;
textureUpperRight.X=1;
textureUpperRight.Y=0;
textureLowerLeft.X=0;
textureLowerLeft.Y=1;
textureLowerRight.X=1;
textureLowerRight.Y=1;
multiPatchCreator.SetTextureWKSPoint(0,reftextureUpperRight);
multiPatchCreator.SetTextureWKSPoint(1,reftextureLowerRight);
multiPatchCreator.SetTextureWKSPoint(2,reftextureUpperLeft);
multiPatchCreator.SetTextureWKSPoint(3,reftextureLowerLeft);
IMultiPatchmultiPatch=multiPatchCreator.CreateMultiPatch()asIMultiPatch;
returnmultiPatch;
}
如果英语好,口才好,加上女孩子的优势说不定有机会进去做做别的工具)