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.