阅读:5749回复:10
人气太差,传代码!
<P>随便写写,实现文本生成Tin(边界控制),生成等值线,切取断面功能,继续写遇到了问题,想做个剔除狭长三角形优化等值线的功能,思路有了,就是得不到FeatureClass的个数,是我的问题还是软件问题?已发有帖子。其实用ArcEngine编程是个享受,接口转来转去,好玩!!!(这是Delphi版本程序)</P>
|
|
1楼#
发布于:2007-04-16 14:19
<P>没有注释也没有调试步骤哦,</P>
<P>另外你要获取地图上的featureclass个数,很简单,只要获取到IMAP,然后就可以得到map.layercount</P> |
|
|
2楼#
发布于:2007-04-14 11:35
<img src="images/post/smile/dvbbs/em03.gif" /><img src="images/post/smile/dvbbs/em03.gif" />
|
|
3楼#
发布于:2007-01-25 20:06
<img src="images/post/smile/dvbbs/em07.gif" />
|
|
4楼#
发布于:2007-01-21 23:55
FeatureClass的个数要用检索
|
|
5楼#
发布于:2007-01-13 21:01
<img src="images/post/smile/dvbbs/em01.gif" /><img src="images/post/smile/dvbbs/em01.gif" />
|
|
6楼#
发布于:2006-12-04 11:15
<P>这么长啊,看了都累啊,</P>
|
|
|
7楼#
发布于:2006-12-01 17:09
<img src="images/post/smile/dvbbs/em05.gif" /><img src="images/post/smile/dvbbs/em06.gif" />
|
|
|
8楼#
发布于:2006-12-01 13:07
<P>unit Unit4;</P>
<P>interface</P> <P>uses<BR> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<BR> Dialogs, esriMapControl_TLB, StdCtrls, RzLstBox, RzCmboBx, esriCarto_TLB,<BR> esriSystem_TLB, RzButton, esriGeoDatabase_TLB, esriDataSourcesFile_TLB,<BR> esriGeometry_TLB;</P> <P>type<BR> TForm4 = class(TForm)<BR> RzComboBox1: TRzComboBox;<BR> RzRankListBox1: TRzRankListBox;<BR> RzButton1: TRzButton;<BR> RzButton2: TRzButton;<BR> RzColorComboBox1: TRzColorComboBox;<BR> RzBitBtn1: TRzBitBtn;<BR> RzBitBtn2: TRzBitBtn;<BR> procedure RzBitBtn1Click(Sender: TObject);<BR> private<BR> { Private declarations }<BR> MapCtrl: TMapControl;<BR> public<BR> { Public declarations }<BR> procedure SetMapControl(AMapCtrl: TMapControl);<BR> function CreateFeatureClass(outPath: string; lyrName: string): IFeatureClass;<BR> procedure OptimizeContour(ipFeatureClass: IFeatureClass);<BR> end;</P> <P>var<BR> Form4: TForm4;</P> <P>implementation</P> <P><BR>{$R *.dfm}</P> <P>{ TForm4 }</P> <P>procedure TForm4.SetMapControl(AMapCtrl: TMapControl);<BR>var<BR> ipMap: IMap;<BR> ipEnumLayer: IEnumLayer;<BR> ipUID: IUID;<BR> ipLayer: ILayer;<BR> Str: WideString;<BR>begin<BR> MapCtrl:= AMapCtrl;<BR> ipMap:= MapCtrl.Map;<BR> ipUID:= CoUID.Create;<BR> ipUID.Value:= '{FE308F36-BDCA-11D1-A523-0000F8774F0F}';<BR> ipMap.Get_Layers(ipUID, False, ipEnumLayer);<BR> if ipEnumLayer <> nil then<BR> begin<BR> ipEnumLayer.Reset;<BR> ipEnumLayer.Next(ipLayer);<BR> ipLayer.Get_Name(Str);<BR> RzComboBox1.Items.Add(Str);<BR> end;<BR> Self.RzRankListBox1.Add('0 m');<BR> Self.RzRankListBox1.Add('1 m');<BR>end;</P> <P>procedure TForm4.RzBitBtn1Click(Sender: TObject);<BR>var<BR> I: Integer;<BR> ipLayer: ILayer;<BR> ipTinLayer: ITinLayer;<BR> Str: WideString;<BR> ipTin: ITin;<BR> ipTinSurface: ITinSurface;<BR> ipDoubleArray: IDoubleArray;<BR> ipFeatureLayer: IFeatureLayer;<BR> ipFeatureClass: IFeatureClass;<BR> Count: Integer;<BR>begin<BR> for I:= 0 to MapCtrl.LayerCount-1 do<BR> begin<BR> ipLayer:= MapCtrl.Layer;<BR> ipLayer.Get_Name(Str);<BR> if Str = RzComboBox1.Text then<BR> begin<BR> ipTinLayer:= ipLayer as ITinLayer;<BR> ipTinLayer.Get_Dataset(ipTin);<BR> ipTinSurface:= ipTin as ITinSurface;<BR> ipDoubleArray:= CoDoubleArray.Create as IDoubleArray;<BR> ipDoubleArray.Add(-8.5);<BR> ipFeatureClass:= CreateFeatureClass('H:\', '8.5');<BR> ipTinSurface.ContourList(ipDoubleArray, ipFeatureClass,'Elevation' ,1);<BR> //OptimizeContour(ipFeatureClass);<BR> ipFeatureLayer:= CoFeatureLayer.Create as IFeatureLayer;<BR> ipFeatureLayer.Set_Name('8.5');<BR> ipFeatureLayer._Set_FeatureClass(ipFeatureClass);<BR> MapCtrl.AddLayer(ipFeatureLayer,1);<BR> Break;<BR> end;<BR> end;<BR>end;</P> <P>function TForm4.CreateFeatureClass(outPath,<BR> lyrName: string): IFeatureClass;<BR>var<BR> ipWorkspaceFactory: IWorkspaceFactory;<BR> ipWorkspace: IWorkspace ;<BR> ipFeatureWorkSapce: IFeatureWorkspace;<BR> ipFields: IFields;<BR> ipFieldsEdit: IFieldsEdit;<BR> ipField: IField;<BR> ipFieldEdit: IFieldEdit;<BR> ipGeometryDef: IGeometryDef;<BR> ipGeometryDefEdit: IGeometryDefEdit;<BR> ipSpatialReference: ISpatialReference;<BR> ipMap: IMap;<BR>begin<BR> ipWorkspaceFactory:= CoShapefileWorkspaceFactory.Create as IWorkspaceFactory;<BR> ipWorkspaceFactory.OpenFromFile(outPath,0,ipWorkspace);<BR> ipFeatureWorkSapce:= ipWorkspace as IFeatureWorkspace;<BR> ipFields:= CoFields.Create as IFields;<BR> ipFieldsEdit:= ipFields as IFieldsEdit;<BR> ipField:= CoField.Create as IField;<BR> ipFieldEdit:= ipField as IFieldEdit;<BR> ipFieldEdit.Set_Name('Shape');<BR> ipFieldEdit.Set_type_(esriFieldTypeGeometry);<BR> ipGeometryDef:= CoGeometryDef.Create as IGeometryDef;<BR> ipGeometryDefEdit:= ipGeometryDef as IGeometryDefEdit;<BR> ipMap:= MapCtrl.Map;<BR> ipMap.Get_SpatialReference(ipSpatialReference);<BR> ipGeometryDefEdit.Set_GeometryType(esriGeometryPolyline);<BR> ipGeometryDefEdit._Set_SpatialReference(ipSpatialReference);<BR> ipFieldEdit._Set_GeometryDef(ipGeometryDef);<BR> ipFieldsEdit.AddField(ipField);<BR> ipFeatureWorkSapce.CreateFeatureClass(lyrName, ipFields, nil,nil,esriFTSimple,'Shape','',Result);<BR>end;</P> <P>procedure TForm4.OptimizeContour(ipFeatureClass: IFeatureClass);<BR>var<BR> ipTable: ITable;<BR> ipFeatureCursor: IFeatureCursor;<BR> ipFeature: IFeature;<BR> ipGeometry: IGeometry;<BR> ipPolycurve: IPolyCurve;<BR> ipPolyline4: IPolyline4;<BR> ipPointCollection: IPointCollection;<BR> I, Count: Integer;<BR> Point1, Point2, Point3: IPoint;<BR> fids: array of LongInt;<BR> ipClass: IClass;<BR> ipIIndexes: IIndexes;<BR>begin</P> <P><BR> //ipTable:= ipFeatureClass as ITable;<BR> ipFeatureClass.FeatureCount(nil, Count);<BR> SetLength(fids, Count);<BR> for I:= 0 to Count-1 do<BR> fids:= I;<BR> ipFeatureClass.GetFeatures(fids, True, ipFeatureCursor);<BR> ipFeatureCursor.NextFeature(ipFeature);<BR> ipFeature.Get_Shape(ipGeometry);<BR> ipPolyline4:= ipGeometry as IPolyline4;<BR> //ipPointCollection:= ipGeometry as IPointCollection;<BR> //ipPointCollection.Get_PointCount(Count);<BR> //for I:= 0 to Count-1 do<BR> //begin<BR> //Point1<BR> //end;<BR> ipPolyline4.SimplifyEx(True);<BR> ipFeatureCursor.Flush;<BR>end;</P> <P>end.</P> |
|
9楼#
发布于:2006-12-01 13:07
<P>unit Unit3;</P>
<P>interface</P> <P>uses<BR> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<BR> Dialogs, OleCtrls, CELL50Lib_TLB, RzButton, RzRadChk, StdCtrls, RzLstBox,<BR> RzChkLst, RzPanel, ExtCtrls, RzSplit, esriCarto_TLB, esriGeometry_TLB, esriGeoDatabase_TLB,<BR> Mask, RzEdit;</P> <P>type<BR> TForm3 = class(TForm)<BR> RzSizePanel1: TRzSizePanel;<BR> RzPanel1: TRzPanel;<BR> RzCheckList1: TRzCheckList;<BR> RzCheckBox1: TRzCheckBox;<BR> Cell1: TCell;<BR> RzBitBtn1: TRzBitBtn;<BR> RzGroupBox1: TRzGroupBox;<BR> RzEdit1: TRzEdit;<BR> procedure RzBitBtn1Click(Sender: TObject);<BR> private<BR> { Private declarations }<BR> public<BR> { Public declarations }<BR> ipGeometry: IGeometry;<BR> end;</P> <P>var<BR> Form3: TForm3;</P> <P>implementation</P> <P>uses Unit1;</P> <P>{$R *.dfm}</P> <P>procedure TForm3.RzBitBtn1Click(Sender: TObject);<BR>var<BR> I, J: Integer;<BR> LayerName: WideString;<BR> ipTinLayer: ITinLayer;<BR> ipLayer: ILayer;<BR> ipTin: ITin;<BR> ipTinEdit: ITinEdit;<BR> ipTinFeatureEdit: ITinFeatureEdit;<BR> ipTinAdvanced: ITinAdvanced;<BR> ipPolygon: IPolygon;<BR> ipInterSection: IGeometry;<BR> ipTopologicalOperator: ITopologicalOperator;<BR> IsSuccessful: WordBool;<BR> ipTinSurface: ITinSurface;<BR> Volume, Area, Depth: Double;<BR> Level: Double;<BR> IsEmpty: WordBool;<BR>begin<BR> for I:= 0 to Self.RzCheckList1.Count -1 do<BR> begin<BR> <BR> for J:= 0 to Form1.MapControl1.LayerCount-1 do<BR> begin<BR> ipLayer:= Form1.MapControl1.Layer[J];<BR> ipLayer.Get_Name(LayerName);<BR> if LayerName = RzCheckList1.Items.Strings then<BR> begin<BR> ipTinLayer:= ipLayer as ITinLayer;<BR> ipTinLayer.Get_Dataset(ipTin);<BR> ipTinAdvanced:= ipTin as ITinAdvanced;<BR> ipTinAdvanced.GetDataArea(ipPolygon);<BR> ipTopologicalOperator:= ipPolygon as ITopologicalOperator;<BR> ipTopologicalOperator.Intersect(ipGeometry, esriGeometry2Dimension, ipInterSection);<BR> ipInterSection.Get_IsEmpty(IsEmpty);<BR> if IsEmpty then<BR> begin<BR> Cell1.SetCellString(1, I+1, 0, LayerName);<BR> Cell1.SetCellString(2,I+1, 0, '');<BR> Cell1.SetCellString(3,I+1, 0, '');<BR> Continue;<BR> end;</P> <P> ipTinEdit:= ipTin as ITinEdit;<BR> ipTinFeatureEdit:= ipTin as ITinFeatureEdit;<BR> ipTinFeatureEdit.StartInMemoryEditing(IsSuccessful);<BR> ipTinEdit.AddShape(ipGeometry,esriTinSoftClip, 0, EmptyParam);<BR> Level:= StrToFloat(RzEdit1.Text);<BR> ipTinSurface:= ipTin as ITinSurface;<BR> ipTinSurface.GetVolume(Level, 1, Volume);<BR> ipTinSurface.GetProjectedArea(Level, 1, Area);<BR> Depth:= Volume/Area-Level;<BR> Volume:= Round(Volume/100000)/100;<BR> Depth:= Round(Depth*100)/100;<BR> Cell1.SetCellString(1, I+1, 0, Copy(LayerName,1, 4)+'-'+Copy(LayerName,5, 2));<BR> Cell1.SetCellDouble(2,I+1, 0, Volume);<BR> Cell1.SetCellDouble(3,I+1, 0, Depth);<BR> end;<BR> end;<BR> end;<BR>end;</P> <P>end.</P> |
|
上一页
下一页