POST
|
I have a form called ChildForm and it includes a globeControl. When i try to add a layer when ChildForm is created(in its constructor) and give it to a form called ParentForm layer is not seen. ParentForm is an mdiContainer and ParentForm is the MDIParent of the ChildForm.However, when ChildForm includes a mapControl and when i try the same case layer is seen. As far as i understand 3D ESRI component does not support mdiParent. Am i wrong? Is there a way to make a 3D ESRI component as MDIParent? Any help will be appreciated. Here is my code: In the parent form when the button is pressed , childform is created. //Form4 is the childForm public partial class Form4 : Form { public Form4() { InitializeComponent(); addFeatureLayer(); } private void addFeatureLayer() { //create a feature layer IFeatureLayer featureLayer = new FeatureLayer(); IWorkspaceFactory wf = new ShapefileWorkspaceFactory(); IFeatureWorkspace workspace = (IFeatureWorkspace)wf.OpenFromFile("D:\\ROGIS_YENI\\trunk\\codes\\ornek veriler\\GSHHS", 0); IFeatureClass featureClass = workspace.OpenFeatureClass("GSHHS_l_L1.shp"); featureLayer.FeatureClass = featureClass; ((ILayer)featureLayer).Name = "Globe"; axGlobeControl1.GlobeDisplay.Scene.AddLayer((ILayer)featureLayer, true); axGlobeControl1.GlobeDisplay.RefreshViewers(); } } //Form2 is the parentForm public partial class Form2 : Form { //MainForm mainform; Form4 mrm; private IGlobeControl m_globeControl; public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.IsMdiContainer = true; mrm = new Form4(); mrm.MdiParent = this; mrm.Show(); } }
... View more
04-10-2013
11:25 PM
|
0
|
0
|
563
|
POST
|
Please help. I created a multipatch geometry and I want to see it on globe control an correct altitude.Although i gave the same coordinates to both feature and element, element is shown above the feature .Here is my code element part IPointCollection coll = new Polygon(); ((IZAware)coll).ZAware = true; IPointCollection coll2 = new Polygon(); ((IZAware)coll2).ZAware = true; IPoint[] points = new IPoint[8]; for (int i = 0; i < 8; i++) { points = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)points).ZAware = true; } points[0].PutCoords(27, 41); points[0].Z = 100000; points[1].PutCoords(27.5, 32.5); points[1].Z = 500000; points[2].PutCoords(40, 32); points[2].Z = 600000; points[3].PutCoords(35, 39); points[3].Z = 0; points[4].PutCoords(27, 41); points[4].Z = 500000; points[5].PutCoords(27.5, 32.5); points[5].Z = 500000; points[6].PutCoords(40, 32); points[6].Z = 500000; points[7].PutCoords(35, 39); points[7].Z = 500000; coll.AddPoint(points[0]); coll.AddPoint(points[1]); coll.AddPoint(points[2]); coll.AddPoint(points[3]); coll2.AddPoint(points[4]); coll2.AddPoint(points[5]); coll2.AddPoint(points[6]); coll2.AddPoint(points[7]); IExtrude2 ext = (IExtrude2)new GeometryEnvironment(); IGeometry geom = ext.Extrude(1, coll as IGeometry); IMultiPatch patch = geom as IMultiPatch; IExtrude2 ext2 = (IExtrude2)new GeometryEnvironment(); IGeometry geom2= ext.Extrude(1, coll2 as IGeometry); geom2.SpatialReference = geographic; IMultiPatch patch2 = geom2 as IMultiPatch; IRgbColor color = new RgbColor(); color.Red = 255; color.Green = 0; color.Blue = 0; //color.Transparency = 20; ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); simpleFillSymbol.Color = color; IElement element = new MultiPatchElement(); element.Geometry = patch as IGeometry; IElement element2= new MultiPatchElement(); element2.Geometry = patch2 as IGeometry; IFillShapeElement fillShapeElement = element as IFillShapeElement; fillShapeElement.Symbol = simpleFillSymbol; IFillShapeElement fillShapeElement2 = element2 as IFillShapeElement; fillShapeElement2.Symbol = simpleFillSymbol; //((IGraphicsContainer)m_globeGraphicsLayer).AddElement(fillShapeElement as IElement, 1); ((IGraphicsContainer)m_globeGraphicsLayer).AddElement(fillShapeElement2 as IElement, 0); feature part Console.WriteLine("dosyaya yazma i??lemi basladi"); string folder = @"D:\\"; string nameOfShapeFile = "ff.shp"; string shapeFieldName = "Shape"; try { IWorkspaceFactory workspaceFactory = null; workspaceFactory = new ShapefileWorkspaceFactory(); IWorkspace workspace = workspaceFactory.OpenFromFile(folder, 0); IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace; IFields fields = null; IFieldsEdit fieldsEdit = null; fields = new Fields(); fieldsEdit = (IFieldsEdit)fields; IField field = null; IFieldEdit fieldEdit = null; field = new Field();///########### fieldEdit = (IFieldEdit)field; fieldEdit.Name_2 = "Shape"; fieldEdit.Type_2 = (esriFieldType.esriFieldTypeGeometry); IGeometryDef geomDef = null; IGeometryDefEdit geomDefEdit = null; geomDef = new GeometryDef();///######### geomDefEdit = (IGeometryDefEdit)geomDef; ISpatialReferenceFactory3 spatialReferenceFactory = (ISpatialReferenceFactory3)new SpatialReferenceEnvironment(); geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryMultiPatch;//esriGeometryPolygon; IGeographicCoordinateSystem geographic = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_WGS1984); geographic.SetDomain(-180, 180, -90, 90); geographic.SetZDomain(-10000000000000, 100000000000000); geomDefEdit.SpatialReference_2 = geographic;//spatialReferenceFactory.CreateGeographicCoordinateSystem((int)ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_WGS1984); geomDefEdit.HasZ_2 = true; //geomDefEdit.HasM_2 = true; fieldEdit.GeometryDef_2 = geomDef; fieldsEdit.AddField(field); //Add another miscellaneous text field field = new Field(); fieldEdit = (IFieldEdit)field; fieldEdit.Length_2 = 30; fieldEdit.Name_2 = "Id"; fieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger; fieldsEdit.AddField(field); IFeatureClass featClass = null; featClass = featureWorkspace.CreateFeatureClass(nameOfShapeFile, fields, null, null, esriFeatureType.esriFTSimple, shapeFieldName, ""); IFeature feature = featClass.CreateFeature(); IPointCollection polygon = new Polygon(); ((IZAware)polygon).ZAware = true; IPointCollection polygon2 = new Polygon(); ((IZAware)polygon2).ZAware = true; IPoint[] points = new IPoint[8]; for (int i = 0; i < 8; i++) { points = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)points).ZAware = true; } points[0].PutCoords(27,41); points[0].Z = 100000; points[1].PutCoords(27.5,32.5); points[1].Z = 500000; points[2].PutCoords(40,32); points[2].Z = 500000; points[3].PutCoords(35,39); points[3].Z = 0; points[4].PutCoords(27, 41); points[4].Z = 500000; points[5].PutCoords(27.5, 32.5); points[5].Z = 500000; points[6].PutCoords(40, 32); points[6].Z = 500000; points[7].PutCoords(35, 39); points[7].Z = 500000; polygon.AddPoint(points[0]); polygon.AddPoint(points[1]); polygon.AddPoint(points[2]); polygon.AddPoint(points[3]); polygon2.AddPoint(points[4]); polygon2.AddPoint(points[5]); polygon2.AddPoint(points[6]); polygon2.AddPoint(points[7]); IExtrude2 ext = (IExtrude2)new GeometryEnvironment(); IGeometry geom = ext.Extrude(1, polygon as IGeometry); IMultiPatch patch = geom as IMultiPatch; IExtrude2 ext2 = (IExtrude2)new GeometryEnvironment(); IGeometry geom2 = ext.Extrude(1, polygon2 as IGeometry); IMultiPatch patch2 = geom2 as IMultiPatch; feature.Shape = patch; feature.Store(); IFeature feature2 = featClass.CreateFeature(); feature2.Shape = patch2; feature2.Store(); /*feature.Shape = (IGeometry)patch;//polygon; feature.Store();*/ } catch (Exception ex) { MessageBox.Show(ex.Message); } Console.WriteLine("dosyaya yazma i??lemi bitti"); why are elemnts drawn the wrong place? What is he way that i can show an element on wanted elevation. I tried almost everything to correct this situation? Can anyone help me? Thanks in advance.
... View more
05-15-2012
05:04 AM
|
0
|
0
|
620
|
POST
|
Hello everyone I want to write a shapefile that consists of more than one multipatch features in c#. How can i do this job? Can anyone help me ? A code snippet will be very nice. Thanks in advance. Here is my code that handles just one multipatch feature. string folder = "D:\\"; string nameOfShapeFile = "multipatch.shp"; string shapeFieldName = "Shape"; try { IWorkspaceFactory workspaceFactory = null; workspaceFactory = new ShapefileWorkspaceFactory(); IWorkspace workspace = workspaceFactory.OpenFromFile(folder, 0); IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace; IFields fields = null; IFieldsEdit fieldsEdit = null; fields = new Fields(); fieldsEdit = (IFieldsEdit)fields; IField field = null; IFieldEdit fieldEdit = null; field = new Field();///########### fieldEdit = (IFieldEdit)field; fieldEdit.Name_2 = "Shape"; fieldEdit.Type_2 = (esriFieldType.esriFieldTypeGeometry); IGeometryDef geomDef = null; IGeometryDefEdit geomDefEdit = null; geomDef = new GeometryDef();///######### geomDefEdit = (IGeometryDefEdit)geomDef; ISpatialReferenceFactory3 spatialReferenceFactory = (ISpatialReferenceFactory3)new SpatialReferenceEnvironment(); geomDefEdit.HasZ_2 = true; geomDefEdit.GeometryType_2 = esriGeometryType.esriGeometryMultiPatch; geomDefEdit.SpatialReference_2 = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)ESRI.ArcGIS.Geometry.esriSRGeoCSType.esriSRGeoCS_WGS1984); fieldEdit.GeometryDef_2 = geomDef; fieldsEdit.AddField(field); //Add another miscellaneous text field field = new Field(); fieldEdit = (IFieldEdit)field; fieldEdit.Length_2 = 30; fieldEdit.Name_2 = "Id"; fieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger; fieldsEdit.AddField(field); IFeatureClass featClass = null; featClass = featureWorkspace.CreateFeatureClass(nameOfShapeFile, fields, null, null, esriFeatureType.esriFTSimple, shapeFieldName, ""); IFeature feature = featClass.CreateFeature(); IGeometryCollection coll = (IGeometryCollection)new MultiPatch(); ((IZAware)coll).ZAware = true; IPoint uppercenter = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)uppercenter).ZAware = true; uppercenter.PutCoords(center.X, center.Y); uppercenter.Z = center.Z + height; IPointCollection pcoll = new Polygon(); ((IZAware)pcoll).ZAware = true; IPoint[] points = new IPoint[36]; IPoint[] points2 = new IPoint[36]; for (int i = 0; i < 36; i++) { points = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)points).ZAware = true; points2 = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)points2).ZAware = true; } double newlon, newlat; for (int i = 0; i < 360; i += 10) { shiftCoordinate(center.X, center.Y, i, width, out newlon, out newlat); points[i / 10].PutCoords(newlon, newlat); points[i / 10].Z = center.Z; } for (int i = 0; i <= 35; i++) { pcoll.AddPoint(points, ref _missing, ref _missing); } IExtrude2 ext = (IExtrude2)new GeometryEnvironment(); IGeometry geom = ext.Extrude(1000000, pcoll as IGeometry); IMultiPatch patch = geom as IMultiPatch; feature.Shape = (IGeometry)patch; feature.Store(); } catch (Exception ex) { MessageBox.Show(ex.Message); }
... View more
11-24-2011
10:15 PM
|
0
|
0
|
710
|
POST
|
Thank you very much Eric. It works. But now, i have another problem.My problem is i have a geodetic closed polyline and i want to convert it to a polygon so that i can fill inside of that closed polyline. Or is there another way to fill inside the closed polyline without converting it to a polygon. Thanks in advance.
... View more
10-17-2011
11:13 PM
|
0
|
0
|
183
|
POST
|
I am using ArcGIS 10 and I want to draw a realistic line on globe control by using c# and my code is below.But my problem is when i run my program it draws a straight line.But i want t� draw a geodesic line(a curved segment according to earth's geodic shape ) public void drawline(double lon1, double lat1, double alt1, double lon2, double lat2, double alt2) { const esriSimple3DLineStyle AxisStyle = esriSimple3DLineStyle.esriS3DLSTube; const double AxisWidth = 1; IPoint point = (IPoint)new ESRI.ArcGIS.Geometry.Point(); ((IZAware)point).ZAware = true; point.PutCoords(lon1, lat1); point.Z = alt1; IPoint point2 = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)point2).ZAware = true; point2.PutCoords(lon2, lat2); point2.Z = alt2; IPoint zero = new ESRI.ArcGIS.Geometry.Point(); ((IZAware)zero).ZAware = true; zero.PutCoords(0, 0); zero.Z = 0; IRgbColor color = new RgbColor(); color.Red = 255; color.Green = 0; color.Blue = 0; IPointCollection axisPointCollection = new Polyline(); // ((IGeometry)axisPointCollection).SpatialReference = //axGlobeControl1.GlobeDisplay.Scene.SpatialReference; axisPointCollection.AddPoint(point, ref _missing, ref _missing); axisPointCollection.AddPoint(point2, ref _missing, ref _missing); IZAware zAware = axisPointCollection as IZAware; zAware.ZAware = true; ISimpleLine3DSymbol simpleLine3DSymbol = new SimpleLine3DSymbol(); simpleLine3DSymbol.Style = AxisStyle; simpleLine3DSymbol.ResolutionQuality = 1; ILineSymbol lineSymbol = simpleLine3DSymbol as ILineSymbol; lineSymbol.Color = color; lineSymbol.Width = AxisWidth * 20; ILine3DPlacement line3DPlacement = lineSymbol as ILine3DPlacement; //line3DPlacement.Units = Units; ILineElement lineElement = (ILineElement)new LineElement(); lineElement.Symbol = lineSymbol; IElement element = lineElement as IElement; element.Geometry = axisPointCollection as IPolyline; ((IGraphicsContainer)m_globeGraphicsLayer).AddElement(element, 1); } Is there a way to do so. Thanks in advance.
... View more
10-17-2011
03:13 AM
|
0
|
3
|
357
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|