本文整理汇总了C#中PolylineClass.AddSegmentCollection方法的典型用法代码示例。如果您正苦于以下问题:C# PolylineClass.AddSegmentCollection方法的具体用法?C# PolylineClass.AddSegmentCollection怎么用?C# PolylineClass.AddSegmentCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolylineClass
的用法示例。
在下文中一共展示了PolylineClass.AddSegmentCollection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteTurnGeometry
public static void WriteTurnGeometry(string outputFileGdbPath, string StreetsFCName, string TurnFCName,
int numAltIDFields, double trimRatio, IGPMessages messages, ITrackCancel trackcancel)
{
messages.AddMessage("Writing turn geometries...");
// Open the feature classes in the file geodatabase
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.FileGDBWorkspaceFactory");
var wsf = Activator.CreateInstance(factoryType) as IWorkspaceFactory;
var fws = wsf.OpenFromFile(outputFileGdbPath, 0) as IFeatureWorkspace;
IFeatureClass streetsFC = fws.OpenFeatureClass(StreetsFCName);
IFeatureClass turnFC = fws.OpenFeatureClass(TurnFCName);
// Look up the Edge1End, EdgeFCID and EdgeFID fields on the turn feature class
int edge1EndField = turnFC.FindField("Edge1End");
int[] edgeFCIDFields = new int[numAltIDFields];
int[] edgeFIDFields = new int[numAltIDFields];
for (int i = 0; i < numAltIDFields; i++)
{
edgeFCIDFields[i] = turnFC.FindField("Edge" + (i + 1) + "FCID");
edgeFIDFields[i] = turnFC.FindField("Edge" + (i + 1) + "FID");
}
// Look up the FCID of the Streets feature class and open a random access cursor on it
int streetsFCID = streetsFC.FeatureClassID;
IRandomAccessCursor rac = (streetsFC as IRandomAccessTable).GetRandomRows("", true);
// Create an update cursor on the turn feature class
var qf = new QueryFilterClass() as IQueryFilter;
IFeatureCursor featCursor = turnFC.Update(qf, false);
IFeature turnFeat = null;
int numFeatures = 0;
double lastCurveLength = 0.0;
while ((turnFeat = featCursor.NextFeature()) != null)
{
// Get the geometry of the first line in the turn, rotate and trim it
var lineFeat = rac.GetRow((int)turnFeat.get_Value(edgeFIDFields[0])) as IFeature;
var featCurve = lineFeat.ShapeCopy as ICurve;
ICurve workingCurve = null;
switch ((string)turnFeat.get_Value(edge1EndField))
{
case "Y":
featCurve.GetSubcurve(1.0 - trimRatio, 1.0, true, out workingCurve);
break;
case "N":
featCurve.GetSubcurve(0.0, trimRatio, true, out workingCurve);
workingCurve.ReverseOrientation();
break;
default:
messages.AddWarning("ERROR: Invalid Edge1End value! Turn OID: " + turnFeat.OID);
break;
}
if (workingCurve == null)
{
continue;
}
// Create a new polyline and add the trimmed first line to it
var segColl = new PolylineClass() as ISegmentCollection;
segColl.AddSegmentCollection(workingCurve as ISegmentCollection);
// Remember the last point of the curve
IPoint lastCurveEnd = workingCurve.ToPoint;
bool earlyExit = false;
for (int i = 1; i < numAltIDFields; i++)
{
if ((int)turnFeat.get_Value(edgeFCIDFields[i]) != streetsFCID)
{
// This was the last part of the turn -- break out and finalize the geometry
break;
}
// Otherwise get the geometry of this line in the turn, rotate it if necessary,
// and add it to the segment collection
lineFeat = rac.GetRow((int)turnFeat.get_Value(edgeFIDFields[i])) as IFeature;
var poly = lineFeat.ShapeCopy as IPolycurve;
bool splitHappened;
int newPart, newSeg;
poly.SplitAtDistance(0.5, true, false, out splitHappened, out newPart, out newSeg);
featCurve = poly as ICurve;
IPoint myPoint = featCurve.FromPoint;
if (EqualPoints(myPoint, lastCurveEnd))
{
segColl.AddSegmentCollection(featCurve as ISegmentCollection);
}
else
{
myPoint = featCurve.ToPoint;
if (EqualPoints(myPoint, lastCurveEnd))
{
featCurve.ReverseOrientation();
segColl.AddSegmentCollection(featCurve as ISegmentCollection);
}
else
{
messages.AddWarning("ERROR: Edge " + (i+1) + " is discontinuous with the previous curve! Turn OID: " + turnFeat.OID);
//.........这里部分代码省略.........
示例2: HatchDraw
//.........这里部分代码省略.........
IMAware pPLM;
//IMCollection pMColl;
IGeometryCollection pGeomColl;
ILineElement pLineElement;
IElement pElement = null;
int cnt;
IPath pPath;
string txt;
double txtlen;
IPath pTxtPath;
double angle;
//IPoint pTxtPt;
ISegmentCollection pSC;
ISegment pSeg;
ISegmentM pSegM;
double m1 = 0;
//double m2 = 0;
//IPoint pFromPt;
//IMarkerSymbol pMSym;
IMask pMask;
ITextElement pTextElement;
ISegmentCollection pSegment;
ISegmentCollection pPolyline;
while (pFeature != null)
{
pPL = pFeature.Shape as IPolyline;
pPLM = pPL as IMAware;
if (pPLM.MAware)
{
if (bEndsOnly)
{
MakeHatchesEndsOnly(pPL, bEnds, pMajorHatchPL, pMinorHatchPL, dHatchLen, dTxtInterval, dHatchOffset);
}
else
{
}
// Draw the major hatches if they are lines
if (pHatchSymMajor is ILineSymbol)
{
pLineElement = new LineElementClass();
pLineElement.Symbol = pHatchSymMajor;
pElement = pLineElement as IElement;
pElement.Geometry = pMajorHatchPL as IGeometry;
pGraphicsContainer.AddElement(pElement, 0);
}
// Draw the major hatches if they are markers and the text...
pGeomColl = pMajorHatchPL as IGeometryCollection;
cnt = pGeomColl.GeometryCount - 1;
for (int j = 0; j <= cnt; j++)
{
pPath = pGeomColl.get_Geometry(j) as IPath;
if (bOverRideMajor)
angle = dMajorAngle;
else
angle = GetAngle(pPath) + dMajorAngle;
pSC = pPath as ISegmentCollection;
pSeg = pSC.get_Segment(0);
pSegM = pSeg as ISegmentM;
txt = Convert.ToString(Math.Round(m1, 1));
txtlen = pTxtSym.Size;
angle = GetAngle(pPath as ICurve);
if (ShouldFlip(angle))
{
pTxtPath = MakeTextPath(pPath, txtlen * 2);
angle += 180;
pTxtSym.RightToLeft = false;
pTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
pTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
}
else
{
//angle = angle;
pTxtPath = MakeTextPath(pPath, txtlen);
pTxtSym.RightToLeft = false;
pTxtSym.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
pTxtSym.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter;
}
pTxtSym.Angle = angle;
//Ϊ�ı�����MASK�����û�з��ţ�����Ϊ����
pMask = pTxtSym as IMask;
pMask.MaskSize = 2;
pMask.MaskStyle = esriMaskStyle.esriMSHalo;
pTextElement = new TextElementClass();
pTextElement.Symbol = pTxtSym;
pTextElement.Text = txt + " ";
pElement = pTextElement as IElement;
pSegment = pTxtPath as ISegmentCollection;
pPolyline = new PolylineClass();
pPolyline.AddSegmentCollection(pSegment);
pElement.Geometry = pPolyline as IGeometry;
pGraphicsContainer.AddElement(pElement, 0);
}
}
pFeature = pFeatCursor.NextFeature();
}
}
示例3: PolygonToPolyline
/// <summary>
/// 面转线
/// </summary>
/// <params name="pPolyline"></params>
/// <returns></returns>
public static IPolyline PolygonToPolyline(IPolygon Polygon)
{
IPolyline pPolyline = null;
if (Polygon != null && Polygon.IsEmpty == false)
{
IGeometryCollection pPolygonGeoCol = Polygon as IGeometryCollection;
ISegment pSegment = null;
ILine pline = new LineClass();
ISegmentCollection pLineSegment = new PolylineClass();
for (int i = 0; i < pPolygonGeoCol.GeometryCount; i++)
{
ISegmentCollection pPolygonSegCol = pPolygonGeoCol.get_Geometry(i) as ISegmentCollection;
//for (int j = 0; j < pPolygonSegCol.SegmentCount; j++)
//{
// pSegment = pPolygonSegCol.get_Segment(j);
// pline = pSegment as ILine;
//}
pLineSegment.AddSegmentCollection(pPolygonSegCol);
}
pPolyline = (IPolyline)pLineSegment;
}
return pPolyline;
}
示例4: MakeSignGeometry
private IGeometry MakeSignGeometry(ICurve fromEdgeCurve, ICurve toEdgeCurve,
bool reverseFromEdge, bool reverseToEdge)
{
ISegmentCollection resultSegments = new PolylineClass();
ICurve fromResultCurve, toResultCurve;
// add the part from the first line
if (reverseFromEdge)
{
fromEdgeCurve.GetSubcurve(0.0, 0.25, true, out fromResultCurve);
fromResultCurve.ReverseOrientation();
}
else
{
fromEdgeCurve.GetSubcurve(0.75, 1.0, true, out fromResultCurve);
}
resultSegments.AddSegmentCollection(fromResultCurve as ISegmentCollection);
// add the part from the second line
if (reverseToEdge)
{
toEdgeCurve.GetSubcurve(0.75, 1.0, true, out toResultCurve);
toResultCurve.ReverseOrientation();
}
else
{
toEdgeCurve.GetSubcurve(0.0, 0.25, true, out toResultCurve);
}
resultSegments.AddSegmentCollection(toResultCurve as ISegmentCollection);
return resultSegments as IGeometry;
}
示例5: ClipContour
//.........这里部分代码省略.........
{
NewLineStart = -1;
NewLineEnd = -1;
}
}
//if contour is out of bounds to the right, then try to shift it to the left
if (IsOutOfBoundsLeft == false && IsOutOfBoundsRight == true)
{
AmountOver = (DistanceFromStart + RangeRight) - PolylineLength;
if (((DistanceFromStart - RangeLeft) - AmountOver) >= 0)
{
NewLineStart = (DistanceFromStart - RangeLeft) - AmountOver;
NewLineEnd = PolylineLength;
}
else
{
NewLineStart = -1;
NewLineEnd = -1;
}
}
//since the contour is to short on both ends to create the new polyline,abound operation
if (IsOutOfBoundsLeft == true && IsOutOfBoundsRight == true)
{
NewLineStart = -1;
NewLineEnd = -1;
}
if (NewLineStart != -1 && NewLineEnd != -1)
{
NewPolyline = new PolylineClass();
npsPolyline.GetSubcurve(NewLineStart, NewLineEnd, false, out NewPolyline);
}
}
else //if polyline is closed
{
if ((RangeLeft + RangeRight) < PolylineLength)
{
pl1 = new PolylineClass();
pl2 = new PolylineClass();
newpl = new PolylineClass();
//if desired subcurve does not cross the start/end point of the closed polyline(circular) then get
//a sub curve as normal
if ((DistanceFromStart - RangeLeft) >= 0 && (DistanceFromStart + RangeRight) < PolylineLength)
{
NewLineStart = DistanceFromStart - RangeLeft;
NewLineEnd = DistanceFromStart + RangeRight;
NewPolyline = new PolylineClass();
npsPolyline.GetSubcurve(NewLineStart, NewLineEnd, false, out NewPolyline);
}
else
{
//if desired subcurve does cross the start/end point of the closed polyline(circular)
//then two subcurves will have to be formed each ending at the start/end point of the circle
//if left range oversteps start/end then...
if ((DistanceFromStart - RangeLeft) < 0)
{
start1 = PolylineLength - ((DistanceFromStart - RangeLeft) * -1);
end1 = PolylineLength;
start2 = 0;
end2 = DistanceFromStart + RangeRight;
}
//if right range oversteps start/end then...
if ((DistanceFromStart + RangeRight) > PolylineLength)
{
start1 = DistanceFromStart - RangeLeft;
end1 = PolylineLength;
start2 = 0;
end2 = (DistanceFromStart + RangeRight) - PolylineLength;
}
//combine sub curves
npsPolyline.GetSubcurve(start1, end1, false, out pl1);
npsPolyline.GetSubcurve(start2, end2, false, out pl2);
newpl.AddSegmentCollection(pl1 as ISegmentCollection);
newpl.AddSegmentCollection(pl2 as ISegmentCollection);
NewPolyline = newpl as ICurve;
}
}
}
return NewPolyline as IPolyline;
}
示例6: MakeSignGeometry
private IGeometry MakeSignGeometry(ArrayList edgesData, ArrayList reverseEdge)
{
ISegmentCollection resultSegments = new PolylineClass();
SignpostUtilities.FeatureData currentFeatureData = new SignpostUtilities.FeatureData(-1, null);
ICurve currentCurve, resultCurve;
for (int i = 0; i < edgesData.Count; i++)
{
// fetch the curve and reverse it as needed
currentFeatureData = (SignpostUtilities.FeatureData)edgesData[i];
currentCurve = currentFeatureData.feature as ICurve;
if ((bool)reverseEdge[i])
currentCurve.ReverseOrientation();
// trim the first and last geometries so that they only cover 25% of the street feature
if (i == 0)
currentCurve.GetSubcurve(0.75, 1.0, true, out resultCurve);
else if (i == (edgesData.Count - 1))
currentCurve.GetSubcurve(0.0, 0.25, true, out resultCurve);
else
resultCurve = currentCurve;
// add the resulting geometry to the collection
resultSegments.AddSegmentCollection(resultCurve as ISegmentCollection);
}
return resultSegments as IGeometry;
}