本文整理汇总了C#中PolylineClass.AddPoint方法的典型用法代码示例。如果您正苦于以下问题:C# PolylineClass.AddPoint方法的具体用法?C# PolylineClass.AddPoint怎么用?C# PolylineClass.AddPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolylineClass
的用法示例。
在下文中一共展示了PolylineClass.AddPoint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExample2
public static IGeometry GetExample2()
{
const double FromZ = -0.1;
const double ToZ = -8;
//Extrusion: Multiple Point 2D Polyline Extruded To Generate 3D Wall Via ConstructExtrudeFromTo()
IPointCollection polylinePointCollection = new PolylineClass();
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-10, -10), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-8, -7), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-5, -5), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-3, -2), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(0, 0), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(3, 2), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(5, 5), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(8, 7), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(10, 10), ref _missing, ref _missing);
IGeometry polylineGeometry = polylinePointCollection as IGeometry;
ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;
topologicalOperator.Simplify();
IConstructMultiPatch constructMultiPatch = new MultiPatchClass();
constructMultiPatch.ConstructExtrudeFromTo(FromZ, ToZ, polylineGeometry);
return constructMultiPatch as IGeometry;
}
示例2: DrawAxis
private static void DrawAxis(IGraphicsContainer3D axesGraphicsContainer3D, IPoint axisFromPoint, IPoint axisToPoint, IColor axisColor, esriSimple3DLineStyle axisStyle, double axisWidth)
{
IPointCollection axisPointCollection = new PolylineClass();
axisPointCollection.AddPoint(axisFromPoint, ref _missing, ref _missing);
axisPointCollection.AddPoint(axisToPoint, ref _missing, ref _missing);
GeometryUtilities.MakeZAware(axisPointCollection as IGeometry);
GraphicsLayer3DUtilities.AddAxisToGraphicsLayer3D(axesGraphicsContainer3D, axisPointCollection as IGeometry, axisColor, axisStyle, axisWidth);
}
示例3: OnClick
protected override void OnClick()
{
//
// TODO: Sample code showing how to access button host
//
var referenceFactory2 = (ISpatialReferenceFactory2)new SpatialReferenceEnvironment();
ISpatialReference WGS84 = referenceFactory2.CreateSpatialReference((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
IPointCollection pointCollection = new PolylineClass();
// ------------- Ensure that both points have negative longitude values -------------------
IPoint point = new PointClass();
point.PutCoords(-170, 10); // Equivalent to 170 degrees WEST
point.SpatialReference = WGS84;
pointCollection.AddPoint(point);
point = new PointClass();
point.PutCoords(-200, 10); // Equivalent to 160 degrees EAST
point.SpatialReference = WGS84;
pointCollection.AddPoint(point);
// -----------------------------------------------------------------------
IPolyline polyline = (IPolyline)pointCollection;
polyline.SpatialReference = WGS84;
var geometryDefEdit = (IGeometryDefEdit)new GeometryDef();
geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
geometryDefEdit.SpatialReference_2 = WGS84;
var field = (IFieldEdit)new Field();
field.Name_2 = "Shape";
field.Type_2 = esriFieldType.esriFieldTypeGeometry;
field.GeometryDef_2 = geometryDefEdit;
var fields = (IFieldsEdit)new Fields();
fields.AddField(field);
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
var featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile("C:\\Temp\\", 0);
IFeatureClass featureClass = featureWorkspace.CreateFeatureClass
("test3.shp", fields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
var feature = featureClass.CreateFeature();
feature.Shape = polyline;
feature.Store();
ArcMap.Application.CurrentTool = null;
}
示例4: GetPointCollection
/// <summary>
/// ����vct�߶λ�ȡ�㼯��
/// </summary>
/// <param name="pLineNodeEx"></param>
/// <returns></returns>
private IPointCollection GetPointCollection(LineNodeEx pLineNodeEx, IPoint pPrePoint)
{
//��ӭ־�ģ�ע���ߵķ���
try
{
IPointCollection pPtCollection = new PolylineClass();
if (pLineNodeEx.IsReverse == false)
{
for (int i = 0; i < pLineNodeEx.SegmentNodes.Count; i++)
{
BrokenLineNode pBLineNode = pLineNodeEx.SegmentNodes[i] as BrokenLineNode;
if (pBLineNode != null)
{
for (int j = 0; j < pBLineNode.PointInfoNodes.Count; j++)
{
if (i == 0 && j == 0 && pPrePoint != null)
continue;
PointInfoNode itemInfoNode = pBLineNode.PointInfoNodes[j];
IPoint pPoint = new PointClass();
pPoint.PutCoords(itemInfoNode.X, itemInfoNode.Y);
object objTypemissing = Type.Missing;
pPtCollection.AddPoint(pPoint, ref objTypemissing, ref objTypemissing);
}
}
}
}
else
{
for (int i = pLineNodeEx.SegmentNodes.Count - 1; i >= 0; i--)
{
BrokenLineNode pBLineNode = pLineNodeEx.SegmentNodes[i] as BrokenLineNode;
if (pBLineNode != null)
{
for (int j = pBLineNode.PointInfoNodes.Count - 1; j >= 0; j--)
{
if (i == pLineNodeEx.SegmentNodes.Count - 1 && j == pBLineNode.PointInfoNodes.Count - 1 && pPrePoint != null)
continue;
PointInfoNode itemInfoNode = pBLineNode.PointInfoNodes[j];
IPoint pPoint = new PointClass();
pPoint.PutCoords(itemInfoNode.X, itemInfoNode.Y);
object objTypemissing = Type.Missing;
pPtCollection.AddPoint(pPoint, ref objTypemissing, ref objTypemissing);
}
}
}
}
/* ///�����߶�
for (int j = 0; j < pLineNodeEx.SegmentNodes.Count; j++)
{
BrokenLineNode pBLineNode = pLineNodeEx.SegmentNodes[j] as BrokenLineNode;
bool bNewBeginPoint = true;///��ʾ���ڴ������ߵ����
foreach (PointInfoNode itemInfoNode in pBLineNode.PointInfoNodes)
{
if (bNewBeginPoint&&pPrePoint != null && itemInfoNode.X == pPrePoint.X
&&itemInfoNode.Y==pPrePoint.Y)
{
///�����ǰһ���߶��յ�ͺ�һ���߶������ͬ����ӵ�����㼯����
continue;
}
///������ӵ���������
IPoint pPoint = new PointClass();
pPoint.PutCoords(itemInfoNode.X, itemInfoNode.Y);
object objTypemissing = Type.Missing;
pPtCollection.AddPoint(pPoint, ref objTypemissing, ref objTypemissing);
}
bNewBeginPoint = false;///��ǰ����㴦�����
}
if (pLineNodeEx.IsReverse)
{
///������պϻ�
object objTypeMissing = Type.Missing;
IPointCollection pPtReserveCollection = new RingClass();
///������ӵ㼯������
for (int k = pPtCollection.PointCount; k >= 0; k--)
{
pPtReserveCollection.AddPoint(pPtCollection.get_Point(k), ref objTypeMissing, ref objTypeMissing);
}
return pPtReserveCollection;
}
*/
return pPtCollection;
}
catch(Exception ex)
{
LogAPI.WriteErrorLog(ex);
return null;
}
}
示例5: button1_Click
//.........这里部分代码省略.........
IField pFld = pFlds.get_Field(Convert.ToInt32(lIndex));
IPoint pPoint = new PointClass();
IPointCollection pPointCollection = (IPointCollection)pFeat.get_Value(Convert.ToInt32(lIndex));
IEnumVertex pEnum = pPointCollection.EnumVertices;
pEnum.Reset();
IPointCollection pNewPointCol = new PolygonClass();
pEnum.Next(out pPoint, out lPart, out lVertex);
int first = 0;
while (pPoint != null)
{
p.Longttd = pPoint.X;
p.Lattd = pPoint.Y;
double X, Y, z;
double X1, Y1, z1;
CCEuler.sphere2kart(out X, out Y, out z, p);
X1 = m[0, 0] * X + m[0, 1] * Y + m[0, 2] * z;
Y1 = m[1, 0] * X + m[1, 1] * Y + m[1, 2] * z;
z1 = m[2, 0] * X + m[2, 1] * Y + m[2, 2] * z;
CCEuler.kart2sphere(out p, X1, Y1, z1);
pPointNew.PutCoords(p.Longttd, p.Lattd);
if (first == 0)
{
firstx = p.Longttd;
firsty = p.Lattd;
}
pNewPointCol.AddPoint(pPointNew, ref Missing, ref Missing);
pEnum.Next(out pPoint, out lPart, out lVertex);
first = 1;
}
pPointNew.PutCoords(firstx, firsty);
pNewPointCol.AddPoint(pPointNew, ref Missing, ref Missing);
IFeature pNewfeature = pFeatClass.CreateFeature();
pNewfeature.Shape = (IGeometry)pNewPointCol;
pNewfeature.Store();
pFeat = pEnumFeat.Next();
}
IFeatureLayer pFLayer = new FeatureLayerClass();
pFLayer.FeatureClass = pFeatClass;
pFLayer.Name = pFeatClass.AliasName;
pMap.AddLayer(pFLayer);
activeMdiChild.axMapControl1.ActiveView.Refresh();
System.Threading.Thread.Sleep(800);
break;
}
if (pFeat.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
{
CCCreatePolygonFile CreatePolygonFile = new CCCreatePolygonFile();
pFeatClass = CreatePolygonFile.CreatePolylineFile(folder, strName, pEnv, pSR);
while (pFeat != null)
示例6: OnMouseMove
public override void OnMouseMove(int Button, int Shift, int X, int Y)
{
if (Button == 1)
{
if (!m_moving) return;
IPoint centerPoint = new PointClass
{
X = (m_element.Geometry.Envelope.LowerLeft.X + m_element.Geometry.Envelope.LowerRight.X) / 2,
Y = (m_element.Geometry.Envelope.LowerLeft.Y + m_element.Geometry.Envelope.UpperRight.Y) / 2
};
if (m_element is AnnotationElement)
{
// 如果旧点为空,则赋OnMouseDown事件所获取的点值
if (m_oldPoint == null)
m_oldPoint = m_point;
// 新点为当前的鼠标点坐标
IPoint newPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
// 获取旧点角度
IPointCollection pPointCollection = new PolylineClass();
object missing = Type.Missing;
pPointCollection.AddPoint(centerPoint, ref missing, ref missing);
pPointCollection.AddPoint(m_oldPoint, ref missing, ref missing);
double oldAngle = GetAngle(pPointCollection as IPolyline);
// 获取新点角度
IPointCollection pointCollection = new PolylineClass();
pointCollection.AddPoint(centerPoint, ref missing, ref missing);
pointCollection.AddPoint(newPoint, ref missing, ref missing);
double newAngle = GetAngle(pointCollection as IPolyline);
// 旋转Element,角度为新旧点之差
ITransform2D pTransform2D = m_viewElement as ITransform2D;
pTransform2D.Rotate(centerPoint, (newAngle - oldAngle));
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_viewElement, m_hookHelper.ActiveView.Extent);
// 更新旧点变量
m_oldPoint = newPoint;
}
else
{
object missing = Type.Missing;
IPoint newPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
IPointCollection pPointCollection = new PolylineClass();
pPointCollection.AddPoint(centerPoint, ref missing, ref missing);
pPointCollection.AddPoint(m_point, ref missing, ref missing);
double oldAngle = GetAngle(pPointCollection as IPolyline);
IPointCollection pointCollection = new PolylineClass();
pointCollection.AddPoint(centerPoint, ref missing, ref missing);
pointCollection.AddPoint(newPoint, ref missing, ref missing);
double newAngle = GetAngle(pointCollection as IPolyline);
ITransform2D pTransform2D = m_element as ITransform2D;
pTransform2D.Rotate(centerPoint, (newAngle - oldAngle));
m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, m_element, m_hookHelper.ActiveView.Extent);
m_point = newPoint;
}
}
}
示例7: LineBuffer
/// <summary>
/// ��ȡ�ߵĻ��������ζ���
/// </summary>
/// <param name="ipPolyline">��</param>
/// <param name="tolerance">����ֵ</param>
/// <returns>��ȷ�������ζ�����null</returns>
private IPolyline LineBuffer(IPolyline ipPolyline, double tolerance)
{
if (ipPolyline == null)
{
return null;
}
ISegmentCollection ipSegCollRes = (ISegmentCollection) ipPolyline;
long nSegmentCount = ipSegCollRes.SegmentCount;
ISegment ipSegment = null;
IPointCollection ipPtColl = new PolylineClass();
for (int i = 0; i < nSegmentCount; i++)
{
ipSegment = ipSegCollRes.get_Segment(i);
ILine ipline1 = new LineClass();
ILine ipline2 = new LineClass();
ipSegment.QueryNormal(esriSegmentExtension.esriExtendTangentAtFrom, 0, false, -tolerance, ipline1);
double dLength = ipSegment.Length;
ipSegment.QueryNormal(esriSegmentExtension.esriExtendTangentAtFrom, dLength, false, -tolerance, ipline2);
object obj = Type.Missing;
IPoint ipFromPoint = ipline2.FromPoint;
ipPtColl.AddPoint(ipFromPoint, ref obj, ref obj);
IPoint ipPoint = ipline1.ToPoint;
ipPtColl.AddPoint(ipPoint, ref obj, ref obj);
double dFromX = ipFromPoint.X;
double dFromY = ipFromPoint.Y;
double dToX = ipPoint.X;
double dToY = ipPoint.Y;
}
IPolyline ipResultPolyline = (IPolyline) ipPtColl;
return ipResultPolyline;
}
示例8: CreateFeature
/// <summary>
/// ������ʵ��
/// </summary>
/// <param name="pITable">���ݱ����</param>
/// <param name="entinyNode">VCT�ռ�ʵ��ڵ�</param>
public override void CreateFeature(ITable pITable, EntityNode entinyNode)
{
try
{
IFeatureClass pFeatureCls = pITable as IFeatureClass;
this.Feature = pFeatureCls.CreateFeature();
LineNode pLineNode = entinyNode as LineNode;
if (pLineNode != null)
{
///��ʶ�븳ֵ
int dBSMIndex = -1;
dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
if (dBSMIndex != -1)
this.Feature.set_Value(dBSMIndex, pLineNode.EntityID);
///Ҫ�ش��븳ֵ
int dSYDMIndex = -1;
dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
if (dSYDMIndex != -1)
this.Feature.set_Value(dSYDMIndex, pLineNode.FeatureCode);
///�����ռ�����
int dLineNodeCount = pLineNode.SegmentNodes.Count;
IPointCollection pointCollection = new PolylineClass();
for (int i = 0; i < dLineNodeCount; i++)
{
//11��ʾ��������
if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("LINETYPE", pLineNode.SegmentNodes[i].SegmentType.ToString()) == "BrokenLine")
{
BrokenLineNode pBLine = pLineNode.SegmentNodes[i] as BrokenLineNode;
foreach (PointInfoNode pPointInfoNode in pBLine.PointInfoNodes)
{
IPoint pPoint = new PointClass();
pPoint.PutCoords(pPointInfoNode.X, pPointInfoNode.Y);
object objType = Type.Missing;
pointCollection.AddPoint(pPoint, ref objType, ref objType);
}
}
else
{
//�������ʹ�������չ
}
}
(this.Feature as IFeature).Shape = pointCollection as IGeometry;
//feature.set_Value();
this.Feature.Store();
}
}
catch(Exception ex)
{
Logger.WriteErrorLog(ex);
}
}
示例9: AddHangdaoToLayer
/// <summary>
/// 添加对象到指定的图层
/// </summary>
/// <params name="pnts">对象的点串</params>
/// <params name="dics">属性字段</params>
/// <params name="hdlayer">添加对象图层</params>
public void AddHangdaoToLayer(List<IPoint> pnts, Dictionary<string, string> dics, IFeatureLayer layer, List<WirePoint> pntinfos = null)
{
//try
//{
IFeatureClass Featureclass = layer.FeatureClass;
IWorkspaceEdit workspace = (IWorkspaceEdit)(Featureclass as IDataset).Workspace;
workspace.StartEditing(false);
workspace.StartEditOperation();
esriGeometryType type = layer.FeatureClass.ShapeType;
int index = -1;
IGeometryDef geometryDef = null;
switch (type)
{
case esriGeometryType.esriGeometryPolygon://添加面到相应的图层
IPolygon polygon = new PolygonClass();
//添加
polygon.SpatialReference = Global.spatialref;
IPointCollection regpntcols = (IPointCollection)polygon;
for (int i = 0; i < pnts.Count; i++)
{
regpntcols.AddPoint(pnts[i]);
}
polygon.Close();
//拓扑检查一下
ITopologicalOperator4 tops = polygon as ITopologicalOperator4;
if (!tops.IsSimple)
tops.Simplify();
IFeature fea = Featureclass.CreateFeature();
index = fea.Fields.FindField(GIS_Const.FIELD_SHAPE);
geometryDef = fea.Fields.get_Field(index).GeometryDef as IGeometryDef;
if (geometryDef.HasZ)
{
IZAware pZAware = (IZAware)polygon;
pZAware.ZAware = true;
}
fea.Shape = polygon;
foreach (string key in dics.Keys)
{
int fIndex = fea.Fields.FindField(key);
if (fIndex != -1)
{
fea.set_Value(fIndex, dics[key]);
}
}
fea.Store();
//地图定位跳转
Global.commonclss.JumpToGeometry(polygon);
break;
case esriGeometryType.esriGeometryPolyline://中心线
IPolyline polyline = new PolylineClass();
IPointCollection plinecols = (IPointCollection)polyline;
for (int i = 0; i < pnts.Count; i++)
{
plinecols.AddPoint(pnts[i]);
}
polyline.SpatialReference = Global.spatialref;
//拓扑检查一下
ITopologicalOperator4 tops1 = polyline as ITopologicalOperator4;
if (!tops1.IsSimple)
tops1.Simplify();
//添加
IFeature fealin = Featureclass.CreateFeature();
IPointCollection polylinenew = new PolylineClass();
for (int i = 0; i < plinecols.PointCount; i++)
{
IPoint pnt = plinecols.get_Point(i);
IPoint pntnew = new PointClass();
pntnew.X = pnt.X;
pntnew.Y = pnt.Y;
pntnew.Z = 0.0;
polylinenew.AddPoint(pntnew);
}
polyline = polylinenew as IPolyline;
index = fealin.Fields.FindField(GIS_Const.FIELD_SHAPE);
geometryDef = fealin.Fields.get_Field(index).GeometryDef as IGeometryDef;
if (geometryDef.HasZ)
{
IZAware pZAware = (IZAware)polyline;
pZAware.ZAware = true;
}
fealin.Shape = polyline;
foreach (string key in dics.Keys)
{
int findex = fealin.Fields.FindField(key);
if (findex != -1)
{
fealin.set_Value(findex, dics[key]);
//.........这里部分代码省略.........
示例10: PDFX
/// <summary>
/// �ж��ߵķ����������ʱ�룬ת����˳ʱ��
/// </summary>
/// <params name="pPolyline"></params>
/// <params name="type">"Bezier,Line"</params>
/// <returns></returns>
public static IPolyline PDFX(IPolyline pPolyline, string type)
{
IPolyline rPolyline = pPolyline;
IGeometry geo = null;
IPointCollection pPointCollection = (IPointCollection)pPolyline;
double s = 0;
for (int i = 0; i < pPointCollection.PointCount - 1; i++)
{
s += (pPointCollection.get_Point(i + 1).X - pPointCollection.get_Point(i).X) * (pPointCollection.get_Point(i + 1).Y - pPointCollection.get_Point(i).Y) * 0.5;
}
if (s < 0)
{
if (type == "Bezier")
{
INewBezierCurveFeedback pBezier = new NewBezierCurveFeedbackClass();
for (int i = pPointCollection.PointCount - 1; i > -1; i--)
{
if (i == pPointCollection.PointCount - 1)
{
pBezier.Start(pPointCollection.get_Point(i));
}
else if (i == 0)
{
pBezier.AddPoint(pPointCollection.get_Point(i));
geo = pBezier.Stop();
}
else
pBezier.AddPoint(pPointCollection.get_Point(i));
}
rPolyline = (IPolyline)geo;
}
else
{
IPointCollection rPointCollection = new PolylineClass();
for (int i = pPointCollection.PointCount - 1; i > -1; i--)
{
rPointCollection.AddPoint(pPointCollection.get_Point(i));
}
rPolyline = (IPolyline)rPointCollection;
}
rPolyline.SpatialReference = pPolyline.SpatialReference;
ISegmentCollection pSegmentCollection = rPolyline as ISegmentCollection;
for (int i = 0; i < pSegmentCollection.SegmentCount; i++)
{
IPoint pt = new PointClass();
IZAware mZAware = (IZAware)pt;
mZAware.ZAware = true;
pt.X = pPointCollection.get_Point(pSegmentCollection.SegmentCount - i).X;
pt.Y = pPointCollection.get_Point(pSegmentCollection.SegmentCount - i).Y;
pt.Z = pPointCollection.get_Point(pSegmentCollection.SegmentCount - i).Z;
IPoint pt1 = new PointClass();
mZAware = (IZAware)pt1;
mZAware.ZAware = true;
if (i == pSegmentCollection.SegmentCount - 1)
{
pt1.X = pPointCollection.get_Point(0).X;
pt1.Y = pPointCollection.get_Point(0).Y;
pt1.Z = pPointCollection.get_Point(0).Z;
pSegmentCollection.get_Segment(i).FromPoint = pt;
pSegmentCollection.get_Segment(i).ToPoint = pt1;
}
else
{
pt1.X = pPointCollection.get_Point(pSegmentCollection.SegmentCount - 1 - i).X;
pt1.Y = pPointCollection.get_Point(pSegmentCollection.SegmentCount - 1 - i).Y;
pt1.Z = pPointCollection.get_Point(pSegmentCollection.SegmentCount - 1 - i).Z;
pSegmentCollection.get_Segment(i).FromPoint = pt;
pSegmentCollection.get_Segment(i).ToPoint = pt1;
}
}
rPolyline = pSegmentCollection as IPolyline;
}
return rPolyline;
}
示例11: GetExample9
public static IGeometry GetExample9()
{
const int DensificationDivisions = 20;
const double MaxDeviation = 0.1;
const double BaseZ = 0;
const double OffsetZ = -7;
//Extrusion: 3D Polyline Having Vertices With Varying Z Values, Extruded Relative To Existing
// Vertex Z Values Via ConstructExtrude()
IPointCollection polylinePointCollection = new PolylineClass();
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(-10, -10), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(0, -5), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(0, 5), ref _missing, ref _missing);
polylinePointCollection.AddPoint(GeometryUtilities.ConstructPoint2D(10, 10), ref _missing, ref _missing);
IPolyline polyline = polylinePointCollection as IPolyline;
polyline.Densify(polyline.Length / DensificationDivisions, MaxDeviation);
IGeometry polylineGeometry = polyline as IGeometry;
GeometryUtilities.MakeZAware(polylineGeometry);
Random random = new Random();
for (int i = 0; i < polylinePointCollection.PointCount; i++)
{
IPoint polylinePoint = polylinePointCollection.get_Point(i);
polylinePointCollection.UpdatePoint(i, GeometryUtilities.ConstructPoint3D(polylinePoint.X, polylinePoint.Y, BaseZ - 2 * Math.Sin(random.NextDouble())));
}
ITopologicalOperator topologicalOperator = polylineGeometry as ITopologicalOperator;
topologicalOperator.Simplify();
IConstructMultiPatch constructMultiPatch = new MultiPatchClass();
constructMultiPatch.ConstructExtrude(OffsetZ, polylineGeometry);
return constructMultiPatch as IGeometry;
}
示例12: MakeLineFeatureLayer
private IFeatureLayer MakeLineFeatureLayer(FusionTable ft, List<RowLine> lstGeomsLine)
{
IFeatureLayer pLineLayer = new FeatureLayerClass();
pLineLayer.FeatureClass = MakeInMemoryFeatureClass(ft, esriGeometryType.esriGeometryPolyline);
//Set up the Outpoints cursor
IFeatureCursor pFCurOutLine = pLineLayer.Search(null, false);
pFCurOutLine = pLineLayer.FeatureClass.Insert(true);
IFeatureBuffer pFBuffer = pLineLayer.FeatureClass.CreateFeatureBuffer();
IPointCollection pNewLinePointColl = null;
IPoint ppoint;
foreach (RowLine line in lstGeomsLine)
{
pNewLinePointColl = new PolylineClass();
foreach (List<double> pt in line.geometry.coordinates)
{
ppoint = new PointClass();
ppoint.X = pt[0];
ppoint.Y = pt[1];
pNewLinePointColl.AddPoint(ppoint);
}
pFBuffer.Shape = pNewLinePointColl as PolylineClass;
pFCurOutLine.InsertFeature(pFBuffer);
}
pLineLayer.Name = "FusionTableLine";
return pLineLayer;
}
示例13: TextToPolyline
/// <summary>
/// �����ļ�չ����ͼ��
/// </summary>
public void TextToPolyline()
{
if (m_FeatureLayer.FeatureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
{
MessageBox.Show("��ȷ��չ��ĵ�һ��ͼ��Ϊ��ͼ��", "��ʾ��Ϣ", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
return;
}
OpenFileDialog openfileDialog = new OpenFileDialog();
openfileDialog.Title = "��ѡ��չ����ͼ��������ļ�";
openfileDialog.Filter = " txt files(*.txt)|*.txt|All files(*.*)|*.*";
openfileDialog.RestoreDirectory = true;
if (openfileDialog.ShowDialog() == DialogResult.OK)
{
frmW.WaitingLabel = "�����������...";
frmW.Show();
Application.DoEvents();
LocalFilePath = openfileDialog.FileName;
StreamReader strReadToEnd = new StreamReader(LocalFilePath);
string sAllLine = strReadToEnd.ReadToEnd();
int LineCount = sAllLine.Split('\n').Length + 1;
string[] pline = new string[LineCount];
double[] x = new double[LineCount];
double[] y = new double[LineCount];
string[] pSeparate = new string[] { };
m_statusBar.Panels[0].ProgressBarMinValue = 0;
m_statusBar.Panels[0].ProgressBarMaxValue = LineCount - 1;
StreamReader strRead = new StreamReader(LocalFilePath);
int i = 0;
int j = 0;
int count = 0;
try
{
if (strRead != null)
{
pline[i] = strRead.ReadLine();
IFeatureClass pFeaCls = m_FeatureLayer.FeatureClass;
IFeature pFeature = pFeaCls.CreateFeature();
IPointCollection pPointCol = new PolylineClass();
IPolyline pPolyline = pPointCol as IPolyline;
while (pline[i] != null)
{
pSeparate = pline[i].Split(',', ' ', ';');
if (pSeparate.Length >= 3)
{
x[j] = double.Parse(pSeparate[1]);
y[j] = double.Parse(pSeparate[2]);
IPoint pPoint = new PointClass();
pPoint.X = x[j];
pPoint.Y = y[j];
object miss = Type.Missing;
pPointCol.AddPoint(pPoint, ref miss, ref miss);
j++;
i++;
pline[i] = strRead.ReadLine();
}
else
{
if (count != 0)
{
pFeature.Shape = pPointCol as IGeometry;
pFeature.Store();
m_mapControl.ActiveView.Refresh();
pPointCol = new PolylineClass();
pFeature = pFeaCls.CreateFeature();
pPolyline = pPointCol as IPolyline;
}
count++;
i++;
pline[i] = strRead.ReadLine();
}
m_statusBar.Panels[0].ProgressBarValue = i;
frmW.WaitingLabel = "���ڻ��Ƶ� " + i.ToString() + " ����";
Application.DoEvents();
}
}
frmW.Close();
MessageBox.Show("������ɣ�");
}
catch
{
MessageBox.Show("�����ı��ļ��ĵ�" + i + "��", "������Ϣ", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
}
}
ICommand pCommand = new ControlsMapFullExtentCommandClass();
pCommand.OnCreate(m_mapControl.Object);
pCommand.OnClick();
m_statusBar.Panels[0].ProgressBarValue = 0;
}
示例14: ConstructTrianglesOutline
public static IGeometryCollection ConstructTrianglesOutline(IGeometry trianglesGeometry)
{
IGeometryCollection outlineGeometryCollection = new GeometryBagClass();
IPointCollection trianglesPointCollection = trianglesGeometry as IPointCollection;
// Triangles: an unlinked set of triangles, where every three vertices completes a new triangle.
if ((trianglesPointCollection.PointCount % 3) != 0)
{
throw new Exception("Triangles Geometry Point Count Must Be Divisible By 3. " + trianglesPointCollection.PointCount);
}
else
{
for (int i = 0; i < trianglesPointCollection.PointCount; i+=3)
{
IPointCollection outlinePointCollection = new PolylineClass();
outlinePointCollection.AddPoint(trianglesPointCollection.get_Point(i), ref _missing, ref _missing);
outlinePointCollection.AddPoint(trianglesPointCollection.get_Point(i + 1), ref _missing, ref _missing);
outlinePointCollection.AddPoint(trianglesPointCollection.get_Point(i + 2), ref _missing, ref _missing);
outlinePointCollection.AddPoint(trianglesPointCollection.get_Point(i), ref _missing, ref _missing); //Simulate: Polygon.Close
IGeometry outlineGeometry = outlinePointCollection as IGeometry;
MakeZAware(outlineGeometry);
outlineGeometryCollection.AddGeometry(outlineGeometry, ref _missing, ref _missing);
}
}
return outlineGeometryCollection;
}
示例15: ConstructTriangleFanOutline
public static IGeometryCollection ConstructTriangleFanOutline(IGeometry triangleFanGeometry)
{
IGeometryCollection outlineGeometryCollection = new GeometryBagClass();
IPointCollection triangleFanPointCollection = triangleFanGeometry as IPointCollection;
// TriangleFan: a linked fan of triangles, where every vertex (after the first two) completes a new triangle.
// A new triangle is always formed by connecting the new vertex with its immediate predecessor
// and the first vertex of the part.
for (int i = 2; i < triangleFanPointCollection.PointCount; i++)
{
IPointCollection outlinePointCollection = new PolylineClass();
outlinePointCollection.AddPoint(triangleFanPointCollection.get_Point(0), ref _missing, ref _missing);
outlinePointCollection.AddPoint(triangleFanPointCollection.get_Point(i - 1), ref _missing, ref _missing);
outlinePointCollection.AddPoint(triangleFanPointCollection.get_Point(i), ref _missing, ref _missing);
outlinePointCollection.AddPoint(triangleFanPointCollection.get_Point(0), ref _missing, ref _missing); //Simulate: Polygon.Close
IGeometry outlineGeometry = outlinePointCollection as IGeometry;
MakeZAware(outlineGeometry);
outlineGeometryCollection.AddGeometry(outlineGeometry, ref _missing, ref _missing);
}
return outlineGeometryCollection;
}