国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

Geometry 對象淺析

2024-07-21 02:30:21
字體:
來源:轉載
供稿:網友

  arcengine geometry庫定義了基本幾何圖形的矢量表達形式,頂級的幾何圖形有points、multipoints、polylines、polygons、 multipatches,geodatabase和繪圖系統使用這些幾何圖形來定義其他各種形狀的特征和圖形,提供了編輯圖形的操作方法和地圖符號系統符號化特征數據的途徑。


  geometry庫中幾個核心類和接口構成了geometry對象的基本框架。


  geometryenvironment


  geometryenvironment提供了從不同的輸入、設置或獲取全局變量來創建幾何圖形的方法,以便控制geometry方法的行為。geometryenvironment對象是一個單例對象。

以下為引用的內容:
public ipolyline testgeometryenvironment()
{
    ispatialreferencefactory spatialreferencefactory 
= new spatialreferenceenvironmentclass();

    
//create a projected coordinate system and define its domain, resolution, and x,y tolerance.
    ispatialreferenceresolution spatialreferenceresolution = spatialreferencefactory.createprojectedcoordinatesystem((int)esrisrprojcstype.esrisrprojcs_nad1983utm_11n) as ispatialreferenceresolution;
    spatialreferenceresolution.constructfromhorizon();
    ispatialreferencetolerance spatialreferencetolerance 
= spatialreferenceresolution as ispatialreferencetolerance;
    spatialreferencetolerance.setdefaultxytolerance();
    ispatialreference spatialreference 
= spatialreferenceresolution as ispatialreference;

    
//create an array of wkspoint structures starting in the middle of the x,y domain of the 
    
//projected coordinate system.

    
double xmin;
    
double xmax;
    
double ymin;
    
double ymax;
    spatialreference.getdomain(
out xmin, out xmax, out ymin, out ymax);

    
double xfactor = (xmin + xmax) * 0.5;
    
double yfactor = (ymin + ymax) * 0.5;

    wkspoint[] wkspoints 
= new wkspoint[10];
    
for (int i = 0; i < wkspoints.length; i++)
    
{
        wkspoints[i].x 
= xfactor + i;
        wkspoints[i].y 
= yfactor + i;
    }


    ipointcollection4 pointcollection 
= new polylineclass();

    igeometrybridge2 geometrybridge 
= new geometryenvironmentclass();
    geometrybridge.addwkspoints(pointcollection, 
ref wkspoints);

    ipolyline polyline 
= pointcollection as ipolyline;
    polyline.spatialreference 
= spatialreference;

    
return polyline;
}

  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對象一樣的空間參考。

以下為引用的內容:
private ipolygon geometrybag_example(ifeatureclass featureclass)
{

    
//check input objects.
    if (featureclass == null)
    
{
        
return null;
    }


    igeodataset geodataset 
= featureclass as igeodataset;
    ispatialfilter queryfilter 
= new spatialfilterclass();

    
//set the properties of the spatial filter here.
    igeometry geometrybag = new geometrybagclass();

    
//define the spatial reference of the bag before adding geometries to it.
    geometrybag.spatialreference = geodataset.spatialreference;

    
//use a nonrecycling cursor so each returned geometry is a separate object. 
    ifeaturecursor featurecursor = featureclass.search(queryfilter, false);

    igeometrycollection geometrycollection 
= geometrybag as igeometrycollection;
    ifeature currentfeature 
= featurecursor.nextfeature();

    
while (currentfeature != null)
    
{
        
//add a reference to this feature's geometry into the bag.
        
//you don't specify the before or after geometry (missing),
        
//so the currentfeature.shape igeometry is added to the end of the geometrycollection.
        object missing = type.missing;
        geometrycollection.addgeometry(currentfeature.shape, 
ref missing, ref missing);

        currentfeature 
= featurecursor.nextfeature();
    }


    
// create the polygon that will be the union of the features returned from the search cursor.
    
// the spatial reference of this feature does not need to be set ahead of time. the 
    
// constructunion method defines the constructed polygon's spatial reference to be the same as 
    
// the input geometry bag.
    itopologicaloperator unionedpolygon = new polygonclass();
    unionedpolygon.constructunion(geometrybag 
as ienumgeometry);

    
return unionedpolygon as ipolygon;
}

  points


  一個點包括x、y坐標,同時可以增加m、z值及id屬性來擴展點的功能。


  multipoints


  點的集合,多點組成multipoint幾何類型,使用multipoint對象實現了的ipointcollection接口可以訪問所有的點元素,這些點同樣可以擁有m、z值及id屬性來獲得更多的地理空間內涵。


  下面列舉一個例子,通過一個已知的polyline來定義一個新的multipart polyline。

 

以下為引用的內容:
public ipolyline constructmultipartpolyline(ipolyline inputpolyline)
{
    igeometry outgeometry 
= new polylineclass();

    
//always associate new, top-level geometries with an appropriate spatial reference.
    outgeometry.spatialreference = inputpolyline.spatialreference; 
 
    igeometrycollection geometrycollection 
= outgeometry as igeometrycollection;

    isegmentcollection segmentcollection 
= inputpolyline as isegmentcollection;

    
//iterate over existing polyline segments using a segment enumerator.
    ienumsegment segments = segmentcollection.enumsegments;

    isegment currentsegment;
    
int partindex = 0;;
    
int segmentindex = 0;;  
    segments.next(
out currentsegment,ref partindex, ref segmentindex);
    
while(currentsegment != null)
    
{
        iline normal 
= new lineclass();

        
//geometry methods with _query_ in their name expect to modify existing geometries. 
        
//in this case, the querynormal method modifies an existing line
        
//segment (normal) to be the normal vector to 
        
//currentsegment at the specified location along currentsegment.
        currentsegment.querynormal(esrisegmentextension.esrinoextension, 0.5true, currentsegment.length / 3, normal); 
 
        
//since each normal vector is not connected to others, create a new path for each one.
        isegmentcollection newpath = new pathclass();
        
object missing = type.missing;
        newpath.addsegment(normal 
as isegment, ref missing, ref missing);
        
//the spatial reference associated with geometrycollection will be assigned to all incoming paths and segments.
        geometrycollection.addgeometry(newpath as igeometry, ref missing, ref missing);

        segments.next(
out currentsegment,ref partindex, ref segmentindex);
    }

    
//the geometrycollection now contains the new, multipart polyline.
    return geometrycollection as ipolyline;
}

  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進行材質貼圖。

以下為引用的內容:
public imultipatch createmultipatch()
{
    
//prepare the geometry material list.
    igeometrymaterial texture = new geometrymaterialclass();
    texture.textureimage 
= "c://temp//myimage.bmp";

    igeometrymateriallist materiallist 
= new geometrymateriallistclass();
    materiallist.addmaterial(texture);

    
//create the multipatch.
    igeneralmultipatchcreator multipatchcreator = new generalmultipatchcreatorclass();
    multipatchcreator.init(
41falsefalsefalse4, materiallist);

    
//set up part.

    
//could also use a ring or a trianglefan.
    multipatchcreator.setpatchtype(0, esripatchtype.esripatchtypetrianglestrip);
    multipatchcreator.setmaterialindex(
00);
    multipatchcreator.setpatchpointindex(
00);
    multipatchcreator.setpatchtexturepointindex(
00);

    
//set real-world points.
    wkspointz upperleft  = new wkspointz();
    wkspointz lowerleft  
= new wkspointz();
    wkspointz upperright 
= new wkspointz();
    wkspointz lowerright 
= new wkspointz();

    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(
0ref upperright);
    multipatchcreator.setwkspointz(
1ref lowerright);
    multipatchcreator.setwkspointz(
2ref upperleft);
    multipatchcreator.setwkspointz(
3ref lowerleft);

    
//set texture points.
    
//set the texture coordinates for a panel.
    wkspoint textureupperleft  = new wkspoint();
    wkspoint texturelowerleft  
= new wkspoint();
    wkspoint textureupperright 
= new wkspoint();
    wkspoint texturelowerright 
= new wkspoint();

    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(
0ref textureupperright);
    multipatchcreator.settexturewkspoint(
1ref texturelowerright);
    multipatchcreator.settexturewkspoint(
2ref textureupperleft);
    multipatchcreator.settexturewkspoint(
3ref texturelowerleft);
    imultipatch multipatch 
= multipatchcreator.createmultipatch() as imultipatch;

    
return multipatch;
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 上犹县| 民乐县| 榆树市| 温泉县| 嵊泗县| 仪陇县| 佳木斯市| 手游| 锡林浩特市| 玛沁县| 兴隆县| 长海县| 永仁县| 赣榆县| 阿拉善左旗| 贺州市| 沂源县| 平陆县| 陕西省| 肥城市| 中西区| 富阳市| 通江县| 峡江县| 电白县| 黎平县| 汉中市| 津南区| 宣武区| 都江堰市| 万山特区| 平潭县| 札达县| 郧西县| 大庆市| 周至县| 禄丰县| 翁源县| 金堂县| 周至县| 通许县|