金色的骷髅 发表于 2015-1-16 22:28:50

ASP.NET编程:Geometry 工具浅析

实不相瞒,Java是我见过的执行效率最低的程序设计语言,前不久在CSDN论坛上有个评测,计算9999的阶乘,同样的循环算法,Java的耗时是.NET的5倍。  ArcEngineGeometry库界说了基础多少图形的矢量表达情势,顶级的多少图形有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;

WKSPoint[]wksPoints=newWKSPoint;
for(inti=0;i<wksPoints.Length;i++)
{
wksPoints.X=xFactor+i;
wksPoints.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;
}

如果英语好,口才好,加上女孩子的优势说不定有机会进去做做别的工具)

admin 发表于 2015-1-25 12:58:33

目前在微软的.net战略中新推出的ASP.net借鉴了Java技术的优点,使用CSharp(C#)语言作为ASP.net的推荐语言,同时改进了以前ASP的安全性差等缺点。但是,使用ASP/ASP.net仍有一定的局限性,因为从某种角度来说它们只能在微软的WindowsNT/2000/XP+IIS的服务器平台上良好运行(虽然像ChilliSoft提供了在UNIX/Linux上运行ASP的解决方案.

因胸联盟 发表于 2015-2-8 12:08:48

主流网站开发语言之ASP:ASP是微软(Microsoft)所开发的一种后台脚本语言,它的语法和VisualBASIC类似,可以像SSI(ServerSideInclude)那样把后台脚本代码内嵌到HTML页面中。虽然ASP简单易用,但是它自身存在着许多缺陷,最重要的就是安全性问题。

仓酷云 发表于 2015-2-25 12:08:49

代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。

小女巫 发表于 2015-3-7 21:37:46

虽然在形式上JSP和ASP或PHP看上去很相似——都可以被内嵌在HTML代码中。但是,它的执行方式和ASP或PHP完全不同。在JSP被执行的时候,JSP文件被JSP解释器(JSPParser)转换成Servlet代码,然后Servlet代码被Java编译器编译成.class字节文件,这样就由生成的Servlet来对客户端应答。所以,JSP可以看做是Servlet的脚本语言(ScriptLanguage)版。

若天明 发表于 2015-3-15 14:46:25

Asp.net:首先来说,Asp.net和Asp没什么关系,看着像是升级版本什么的,其实没什么联系。Asp是脚本编程,用的是ASP语言,而ASP.net用的是C#语言,完全不同的东西。

精灵巫婆 发表于 2015-3-22 02:10:22

JSP/Servlet虽然在国内目前的应用并不广泛,但是其前途不可限量。
页: [1]
查看完整版本: ASP.NET编程:Geometry 工具浅析