本文整理汇总了C#中IPolyline.ReverseOrientation方法的典型用法代码示例。如果您正苦于以下问题:C# IPolyline.ReverseOrientation方法的具体用法?C# IPolyline.ReverseOrientation怎么用?C# IPolyline.ReverseOrientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPolyline
的用法示例。
在下文中一共展示了IPolyline.ReverseOrientation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProfileCreateGraph
//���ݶ���ߺͷ������鴴���߳�����
public static void ProfileCreateGraph(AxMapControl ppAxMapControl, IPolyline pPolyline, IArray pSewerElevArray)
{
IZ pPolylineZ = pPolyline as IZ;
IRasterLayer pRasterLyr = FindRasterLayer("Elevation", ppAxMapControl);
//��ñ�����в�ֵ
ISurface pSurface = GetSurface(pRasterLyr);
//����Polyline z-ware;
IZAware pZAwareLineZ = pPolyline as IZAware;
pZAwareLineZ.ZAware = true;
//'* work around for InterpolateFromSurface sometimes flipping polyline
IPoint pPtOrigFrom = pPolyline.FromPoint;
IPoint pPtOrigTo = pPolyline.ToPoint;
//���Zֵ���������
pPolylineZ.InterpolateFromSurface(pSurface);
if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y)
pPolyline.ReverseOrientation();
//���Mֵ������
IMSegmentation pMSegmentation = pPolyline as IMSegmentation;
IMAware pMAware = pPolyline as IMAware;
pMAware.MAware = true;
pMSegmentation.SetMsAsDistance(false);
//�������
ITable pTable = ProfileCreateTable();
int i = 0;
if (pTable != null)
{
//��ͼ���б�ؼ���Ҫȷ���ñ�����ڣ����������ɾ����
IStandaloneTableCollection pStandAloneTabColl = ppAxMapControl.ActiveView.FocusMap as IStandaloneTableCollection;
for (i = 0; i <= pStandAloneTabColl.StandaloneTableCount - 1; i++)
{
if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable")
pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i));
}
//����һ���µĶ��������������ӵ���ͼ������
IStandaloneTable pStandAloneTab = new StandaloneTableClass();
pStandAloneTab.Table = pTable;
pStandAloneTabColl = ppAxMapControl.ActiveView.FocusMap as IStandaloneTableCollection;
pStandAloneTabColl.AddStandaloneTable(pStandAloneTab);
pTable = pStandAloneTab as ITable;
//Ϊ�����ֶ����ñ���
ITableFields pTableFields = pStandAloneTab as ITableFields;
IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z"));
pFieldInfo.Alias = "Ground Elevation";
pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev"));
pFieldInfo.Alias = "Sewer Line Elevation";
//Ϊ�����һ��������
ICursor pCursor = pTable.Insert(true);
IRowBuffer pRowBuff;
//
IPointCollection pPtCollection = pPolyline as IPointCollection;
IEnumVertex pEnumVertex = pPtCollection.EnumVertices;
pEnumVertex.Reset();
IPoint pPT;
int iPartIndex;
int iVertexIndex;
i = 0;
//��ӽڵ�XYZ���±����
pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
while (pPT != null)
{
pRowBuff = pTable.CreateRowBuffer();
pRowBuff.set_Value(pRowBuff.Fields.FindField("X"), pPT.X);
pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"), pPT.Y);
pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"), pPT.Z);
pRowBuff.set_Value(pRowBuff.Fields.FindField("M"), pPT.M);
pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i)));
pCursor.InsertRow(pRowBuff);
pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
i = i + 1;
}
pCursor.Flush();
pCursor = null;
pCursor = pTable.Search(null, false);
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = "SewerElev <> -99";
ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false);
pCursor = null;
pCursor = pTable.Update(null, false);
pRowBuff = pCursor.NextRow();
double m = 0;
double Mmin = 0;
double Mmax = 0;
double deltaM = 0;
double deltaSewerElev = 0;
double sewerelev = 0;
double newZ = 0;
int j = 0;
double minSewerElev = 0;
double maxSewerElev = 0;
IRow pRowSewerElev;
while (pRowBuff != null)
{
if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99)
{
m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M")));
newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev;
pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ);
pCursor.UpdateRow(pRowBuff as IRow);
//.........这里部分代码省略.........
示例2: MakeOneHatch
public static ISegment MakeOneHatch(IPolyline pSubPL, double dist, double m, double numhatch, double dTxtInterval, double dHatchLen, double dHatchOffset)
{
ILine pL = new LineClass();
int result;
ISegmentM pSegM;
Math.DivRem((int)numhatch, (int)dTxtInterval, out result);
if (!(result == 0))
{
if (dHatchOffset == 0)
pSubPL.QueryNormal(esriSegmentExtension.esriNoExtension, dist, false, (dHatchLen * 0.5), pL);
else if (dHatchOffset > 0)
pSubPL.QueryNormal(esriSegmentExtension.esriNoExtension, dist, false, (dHatchLen * 0.5) + dHatchOffset, pL);
else if (dHatchOffset < 0)
{
pSubPL.ReverseOrientation();
pSubPL.QueryNormal(esriSegmentExtension.esriNoExtension, pSubPL.Length - dist, false, dHatchLen + Math.Abs(dHatchOffset), pL);
pSubPL.ReverseOrientation();
}
}
ICurve pCurve;
if (dHatchOffset != 0)
{
pL.GetSubcurve(Math.Abs(dHatchOffset), pL.Length, false, out pCurve);
pSegM = pCurve as ISegmentM;
}
else
pSegM = pL as ISegmentM;
pSegM.SetMs(m, m);
return pSegM as ISegment;
}
示例3: ProfileCreateGraph
private static void ProfileCreateGraph(IApplication app, List<ProfileGraphDetails> ProfileGraph, IPolyline pPolyline, List<mainDetails> SewerColMains,
List<manholeDetails> SewerColManholes, List<tapDetails> SewerColTap, int CurrentDetail)
{
// profile the sewer line and the surface elevation data
// pPolyLine is a line composed from the edge results of the network trace
IWorkspace pWS = null;
ICursor pCursor = null;
IMxDocument pMxDoc = null;
IMap pMap = null;
IZ pPolyLineZ = null;
IZAware pZAwareLineZ = null;
ISurface pSurface = null;
IRasterLayer pRasterLayer = null;
//get the elevation layer
ILayer pRasLay = null;
IPoint pPtOrigFrom = null;
IPoint pPtOrigTo = null;
IStandaloneTableCollection pStandAloneTabColl = null;
IStandaloneTable pStandAloneTabMainLabel = null;
ITable pTapTable = null;
ITable pMainTable = null;
ITable pManholeTable = null;
ITable pSurfaceTable = null;
ITable pMainLabelTable = null;
ITableFields pTableFieldsMainLabel = null;
IStandaloneTable pStandAloneTabMain = null;
ITableFields pTableFieldsMain = null;
IStandaloneTable pStandAloneTabManhole = null;
ITableFields pTableFieldsManhole = null;
IStandaloneTable pStandAloneTabSurface = null;
ITableFields pTableFieldsSurface = null;
IStandaloneTable pStandAloneTabTap = null;
ITableFields pTableFieldsTap = null;
IRowBuffer pRowBuff = null;
ICursor pLabelCursor = null;
ICursor pTapCursor = null;
ISegment pSegment = null;
ILine pLine = null;
IPoint pFromPnt = null;
IPoint pToPnt = null;
IPoint pMidPnt = null;
IDataGraphBase pDataGraphBase = null;
IDataGraphT pDataGraphT = null;
IPointCollection pPtCollection = null;
IEnumVertex pEnumVertex = null;
IPoint pPt = null;
ISeriesProperties pAreaSeriesProps = null;
IColor pColor = null;
String strXDataFldName = null;
String strYDataFldName = null;
IDataSortSeriesProperties pSortFlds = null;
IPointSeriesProperties pScatterSeriesProps2 = null;
ISeriesProperties pScatterSeriesProps = null;
IBarSeriesProperties pManHoleSeries = null;
ILineSeriesProperties pLineSeriesProps2 = null;
ISeriesProperties pLineSeriesProps = null;
ITrackCancel pCancelTracker = null;
IDataGraphWindow2 pDataGraphWin = null;
IDataGraphCollection pDataGraphs = null;
try
{
pMxDoc = (IMxDocument)app.Document;
pMap = pMxDoc.FocusMap;
// Open the Workspace
pWS = Globals.CreateInMemoryWorkspace();
//get the elevation layer
bool FCorLayerRas = true;
pRasLay = Globals.FindLayer(pMap, ProfileGraph[CurrentDetail].Elevation_LayerName, ref FCorLayerRas);
if (pRasLay != null)
{
pRasterLayer = pRasLay as IRasterLayer;
// get the surface to interpolate from
pSurface = Globals.GetSurface(pRasterLayer);
// make the polyline z-aware
pZAwareLineZ = (IZAware)pPolyline;
pZAwareLineZ.ZAware = true;
// work around for InterpolateFromSurface sometimes flipping polyline
pPtOrigFrom = pPolyline.FromPoint;
pPtOrigTo = pPolyline.ToPoint;
pPolyline.Project((pRasterLayer as IGeoDataset).SpatialReference);
// add z values to the polyline
pPolyLineZ = (IZ)pPolyline;
pPolyLineZ.InterpolateFromSurface(pSurface);
pPolyline.ReverseOrientation();
//.........这里部分代码省略.........
示例4: CalculateExtendPointNew
/// <summary>
/// 计算延长线上的距离
/// </summary>
/// <params name="startP"></params>
/// <params name="endP"></params>
/// <params name="jjcd"></params>
/// <returns></returns>
public IPoint CalculateExtendPointNew(IPolyline plin, IPoint pntTo, double jjcd, out bool bres)
{
bres = false;
IPoint pntOut = new PointClass();
double distfrom = 0.0, distto = 0.0;
double outdistfrom = 0.0, outdistto = 0.0;
bool boolfrom = false;
plin.QueryPointAndDistance(esriSegmentExtension.esriExtendAtFrom, pntTo, false, pntOut, ref distfrom, ref outdistfrom, ref boolfrom);
plin.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, pntTo, false, pntOut, ref distto, ref outdistto, ref boolfrom);
if (distfrom < distto)//反向的
{
bres = true;
plin.ReverseOrientation();
plin.QueryPoint(esriSegmentExtension.esriExtendAtTo, jjcd + plin.Length, false, pntOut);
}
else//正向
{
bres = false;
plin.QueryPoint(esriSegmentExtension.esriExtendAtTo, jjcd + plin.Length, false, pntOut);
}
return pntOut;
}
示例5: GetPointPos
/// <summary>
/// 判断pline的frompoint 在pnt1和 pnt2组成的线的哪一侧
/// </summary>
/// <params name="pnt1"></params>
/// <params name="pnt2"></params>
/// <params name="pline"></params>
/// <returns>返回与回采方向相同的巷道线 </returns>
private IPolyline GetPointPos(IPoint pnt1, IPoint pnt2, IPolyline pline, int iDirect)
{
IPoint pntstart = pline.FromPoint;
if (pntstart == pnt1) //pline 起点与pnt1相同
{
return pline;
}
else if (pline.ToPoint == pnt1) //pline 终点与pnt1相同
{
pline.ReverseOrientation();
//return pline;
}
else //非切眼状态
{
//(p2-p0)*(p1-p0)>0 则p0p1在p1点拐向右侧得到p1p2,(p2-p0)*(p1-p0)<0 则p0p1在p1点拐向左侧得到p1p2, p1为共同点
IPoint p1p0 = new PointClass();
//p1-p0
p1p0.X = pnt1.X - pnt2.X;
p1p0.Y = pnt1.Y - pnt2.Y;
IPoint p2p0 = new PointClass();
//p2-p0
p2p0.X = pntstart.X - pnt2.X;
p2p0.Y = pntstart.Y - pnt2.Y;
//(p2-p0)*(p1-p0)
double newrel = p2p0.X * p1p0.Y - p1p0.X * p2p0.Y;
if (newrel > 0) //frompoint 在切眼右侧
{
if (iDirect == -1)
pline.ReverseOrientation();
}
else if (newrel < 0) //frompoint 在切眼左侧
{
if (iDirect == 1)
pline.ReverseOrientation();
//return pline;
}
}
return pline;
}
示例6: ProfileCreateGraph
//根据多段线和阀门数组创建高程剖面
public static void ProfileCreateGraph(MainFrm pMainFrm, IPolyline pPolyline, IArray pSewerElevArray)
{
AxMapControl axMap = pMainFrm.getMapControl();
IZ pPolylineZ = pPolyline as IZ;
IRasterLayer pRasterLyr = FindRasterLayer("Elevation", pMainFrm);
//获得表面进行插值
ISurface pSurface = GetSurface(pRasterLyr);
//创建Polyline z-ware;
IZAware pZAwareLineZ = pPolyline as IZAware;
pZAwareLineZ.ZAware = true;
//'* work around for InterpolateFromSurface sometimes flipping polyline
IPoint pPtOrigFrom = pPolyline.FromPoint;
IPoint pPtOrigTo = pPolyline.ToPoint;
//添加Z值到多边形上
pPolylineZ.InterpolateFromSurface(pSurface);
if (pPolyline.FromPoint.X != pPtOrigFrom.X || pPolyline.FromPoint.Y != pPtOrigFrom.Y)
pPolyline.ReverseOrientation();
//添加M值到线上
IMSegmentation pMSegmentation = pPolyline as IMSegmentation;
IMAware pMAware = pPolyline as IMAware;
pMAware.MAware = true;
pMSegmentation.SetMsAsDistance(false);
//创建表格
ITable pTable = ProfileCreateTable();
int i=0;
if (pTable != null)
{
//在图层列表控件中要确保该表格还不存在,如果存在则删除它
IStandaloneTableCollection pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection;
for ( i = 0; i<=pStandAloneTabColl.StandaloneTableCount - 1; i++)
{
if (pStandAloneTabColl.get_StandaloneTable(i).Name == "xxprofiletable")
pStandAloneTabColl.RemoveStandaloneTable(pStandAloneTabColl.get_StandaloneTable(i));
}
//创建一个新的独立表,并把它添加到地图集合中
IStandaloneTable pStandAloneTab = new StandaloneTableClass();
pStandAloneTab.Table = pTable;
pStandAloneTabColl = axMap.ActiveView.FocusMap as IStandaloneTableCollection;
pStandAloneTabColl.AddStandaloneTable(pStandAloneTab);
pTable = pStandAloneTab as ITable;
//为两个字段设置别名
ITableFields pTableFields = pStandAloneTab as ITableFields;
IFieldInfo pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("Z"));
pFieldInfo.Alias = "Ground Elevation";
pFieldInfo = pTableFields.get_FieldInfo(pTableFields.FindField("SewerElev"));
pFieldInfo.Alias = "Sewer Line Elevation";
//为表格获得一个插入光标
ICursor pCursor=pTable.Insert(true);
IRowBuffer pRowBuff;
//
IPointCollection pPtCollection = pPolyline as IPointCollection;
IEnumVertex pEnumVertex = pPtCollection.EnumVertices;
pEnumVertex.Reset();
IPoint pPT;
int iPartIndex;
int iVertexIndex;
i = 0;
//添加节点XYZ到新表格中
pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
while (pPT != null)
{
pRowBuff = pTable.CreateRowBuffer();
pRowBuff.set_Value(pRowBuff.Fields.FindField("X"),pPT.X);
pRowBuff.set_Value(pRowBuff.Fields.FindField("Y"),pPT.Y);
pRowBuff.set_Value(pRowBuff.Fields.FindField("Z"),pPT.Z);
pRowBuff.set_Value( pRowBuff.Fields.FindField("M"),pPT.M);
pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), Convert.ToDouble(pSewerElevArray.get_Element(i)));
pCursor.InsertRow(pRowBuff);
pEnumVertex.Next(out pPT, out iPartIndex, out iVertexIndex);
i = i + 1;
}
pCursor.Flush();
pCursor = null;
pCursor = pTable.Search(null, false);
IQueryFilter pQueryFilter = new QueryFilterClass();
pQueryFilter.WhereClause = "SewerElev <> -99";
ICursor pCursorSewerElev = pTable.Search(pQueryFilter, false);
pCursor = null;
pCursor = pTable.Update(null, false);
pRowBuff = pCursor.NextRow();
double m = 0;
double Mmin=0;
double Mmax=0;
double deltaM=0;
double deltaSewerElev=0;
double sewerelev=0;
double newZ=0;
int j = 0;
double minSewerElev=0;
double maxSewerElev=0;
IRow pRowSewerElev;
while (pRowBuff != null)
{
if (Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("SewerElev"))) == -99)
{
m = Convert.ToDouble(pRowBuff.get_Value(pRowBuff.Fields.FindField("M")));
newZ = (((m - Mmin) / deltaM) * deltaSewerElev) + sewerelev;
pRowBuff.set_Value(pRowBuff.Fields.FindField("SewerElev"), newZ);
//.........这里部分代码省略.........