本文整理汇总了C#中Polyline类的典型用法代码示例。如果您正苦于以下问题:C# Polyline类的具体用法?C# Polyline怎么用?C# Polyline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Polyline类属于命名空间,在下文中一共展示了Polyline类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetRoute
public async Task<RouteResult> GetRoute(IEnumerable<MapPoint> stops, CancellationToken cancellationToken)
{
if (stops == null)
throw new ArgumentNullException("stops");
List<Graphic> stopList = new List<Graphic>();
foreach (var stop in stops)
{
stopList.Add(new Graphic(stop));
}
if (stopList.Count < 2)
throw new ArgumentException("Not enough stops");
//determine which route service to use. Long distance routes should use the long-route service
Polyline line = new Polyline() { SpatialReference = SpatialReferences.Wgs84 };
line.Paths.AddPart(stops.Select(m => m.Coordinate));
var length = GeometryEngine.GeodesicLength(line);
string svc = routeService;
if (length > 200000)
svc = longRouteService;
//Calculate route
RouteTask task = new OnlineRouteTask(new Uri(svc)) { HttpMessageHandler = messageHandler };
var parameters = await task.GetDefaultParametersAsync().ConfigureAwait(false);
parameters.Stops = new Esri.ArcGISRuntime.Tasks.NetworkAnalyst.FeaturesAsFeature(stopList);
parameters.ReturnStops = true;
parameters.OutputLines = OutputLine.TrueShapeWithMeasure;
parameters.OutSpatialReference = SpatialReferences.Wgs84;
parameters.DirectionsLengthUnit = LinearUnits.Meters;
parameters.UseTimeWindows = false;
parameters.RestrictionAttributeNames = new List<string>(new string[] { "OneWay " });
return await task.SolveAsync(parameters, cancellationToken);
}
开发者ID:Gue2014,项目名称:DS2014-GettingStarted,代码行数:33,代码来源:RouteService.cs
示例2: OverlapConvexHull
internal OverlapConvexHull(Polyline polyline, IEnumerable<Obstacle> obstacles) {
this.Polyline = polyline;
this.Obstacles = obstacles.ToList();
this.PrimaryObstacle = this.Obstacles[0];
Obstacle.RoundVertices(this.Polyline);
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:7,代码来源:OverlapConvexHull.cs
示例3: ViewDidLoad
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var camera = CameraPosition.FromCamera (0, -180, 3);
var mapView = MapView.FromCamera (CGRect.Empty, camera);
// Create a 'normal' polyline.
var polyline = new Polyline ();
var path = new MutablePath ();
path.AddCoordinate (new CLLocationCoordinate2D (37.772323, -122.214897));
path.AddCoordinate (new CLLocationCoordinate2D (21.291982, -157.821856));
path.AddCoordinate (new CLLocationCoordinate2D (-18.142599, 178.431));
path.AddCoordinate (new CLLocationCoordinate2D (-27.46758, 153.0278926));
polyline.Path = path;
polyline.StrokeColor = UIColor.Red;
polyline.StrokeWidth = 2;
polyline.Map = mapView;
// Copy the previous polyline, change its color, and mark it as geodesic.
polyline = (Polyline) polyline.Copy ();
polyline.StrokeColor = UIColor.Green;
polyline.Geodesic = true;
polyline.Map = mapView;
View = mapView;
}
开发者ID:asthanarht,项目名称:XamarinDiscountsApp,代码行数:29,代码来源:PolylinesViewController.cs
示例4: DistanceFromPointToPolyline
internal static double DistanceFromPointToPolyline(Point p, Polyline poly) {
double d = double.PositiveInfinity;
double u;
for (PolylinePoint pp = poly.StartPoint; pp.Next != null; pp = pp.Next)
d = Math.Min(d, Point.DistToLineSegment(p, pp.Point, pp.Next.Point, out u));
return d;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:7,代码来源:RouterBetweenTwoNodes.cs
示例5: Create
public void Create(BlockTableRecord btrPanel, Transaction t)
{
Polyline plContour = new Polyline();
plContour.LayerId = panelBase.Service.Env.IdLayerContourPanel;
// Определение подрезок и пустот
defineUndercuts();
// Outsides - части сторон панели без плитки - заходит под торец другой угловой панели
addOutsides(btrPanel, t);
definePtsLeftSide();
definePtsTopSide();
definePtsRightSide();
definePtsBotSide();
int i = 0;
ptsLeftSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
ptsTopSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
ptsRightSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
ptsBotSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
plContour.Closed = true;
btrPanel.AppendEntity(plContour);
t.AddNewlyCreatedDBObject(plContour, true);
}
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:26,代码来源:Contour.cs
示例6: Movil
//
public Movil(ref ObjectId line, ref ObjectId mobile, double minSeparation, double maxSeparation, bool loopTravel)
{
this.line = line;
this.mobile = mobile;
this.dPromMin = minSeparation;
this.dPromMax = maxSeparation;
this.loopTravel = loopTravel;
this.goal = false;
this.ruta = Lab3.DBMan.OpenEnity(line) as Polyline;
this.bloque = Lab3.DBMan.OpenEnity(mobile) as BlockReference;
this.bloqueCentro = new Point3d((bloque.GeometricExtents.MinPoint.X +
bloque.GeometricExtents.MaxPoint.X) / 2,
(bloque.GeometricExtents.MinPoint.Y +
bloque.GeometricExtents.MaxPoint.Y) / 2,
0);
this.numeroSegmentos = this.ruta.NumberOfVertices - 1;
this.segmentoActualIndex = 0;
this.segmentoActual = this.ruta.GetLineSegment2dAt(segmentoActualIndex);
Lab3.DBMan.UpdateBlockPosition(new Point3d(this.segmentoActual.StartPoint.X, this.segmentoActual.StartPoint.Y, 0), mobile);
//
AttributeManager attribute = new AttributeManager(mobile);
attribute.SetAttribute("Velocity", this.velocity+" [Kms/hr]");
//
this.pointActualCurve = 0;
this.velocityScale = 0.00001f;
this.velocity = this.UpdateDireccion();
Lab3.DBMan.UpdateBlockRotation(new Vector2d(this.velocity.X, this.velocity.Y).Angle, this.mobile);
}
开发者ID:JOndarza,项目名称:CAD,代码行数:29,代码来源:Movil.cs
示例7: Get
public static double Get(bool IsLeftComp, double r, Polyline line, Point2d TheIntersectPoint, int Index, Point2d StartPoint)
{
double oldBulge = line.GetBulgeAt(Index - 1);
if (oldBulge == 0)
return 0;//这里可能不对,可能有两个交点,而默认为一个交点
else
{
double delta = System.Math.Atan(System.Math.Abs(oldBulge)) * 2;
//这里计算新的半径时,要考虑方向因素,可能新半径会更小,也可能会更大
//取决于路径的偏移方向,以及圆心的位置
double newRadius = line.GetPoint2dAt(Index - 1).GetDistanceTo(line.GetPoint2dAt(Index)) / 2 / System.Math.Sin(delta);//新弧的半径
if (IsLeftComp)
{
if (oldBulge < 0)
newRadius += r;
else newRadius -= r;
}
else
{
if (oldBulge > 0)
newRadius += r;
else newRadius -= r;
}
double newChord = StartPoint.GetDistanceTo(TheIntersectPoint);
double newBulge = System.Math.Tan(
System.Math.Asin(newChord / 2 / newRadius) / 2
)
* line.GetBulgeAt(Index - 1) / System.Math.Abs(line.GetBulgeAt(Index - 1));
return -newBulge;
}
}
开发者ID:komelio,项目名称:Dimeng.LinkToMicrocad,代码行数:33,代码来源:GetOffsetCurveBulge.cs
示例8: GetNodesBetweenPointsReturnPointsInCorrectOrder1
public void GetNodesBetweenPointsReturnPointsInCorrectOrder1()
{
PointGeo start = new PointGeo(1, 1);
PointGeo middle1 = new PointGeo(1, 1.5);
PointGeo middle2 = new PointGeo(1, 1.6);
PointGeo middle3 = new PointGeo(1, 1.7);
PointGeo end = new PointGeo(1, 2);
Polyline<IPointGeo> line = new Polyline<IPointGeo>();
line.Nodes.Add(start);
line.Nodes.Add(middle1);
line.Nodes.Add(middle2);
line.Nodes.Add(middle3);
line.Nodes.Add(end);
var result = Topology.GetNodesBetweenPoints(new PointGeo(1, 1.1), new PointGeo(1, 1.9), line).ToList();
Assert.Equal(3, result.Count());
Assert.Equal(middle1, result[0]);
Assert.Equal(middle2, result[1]);
Assert.Equal(middle3, result[2]);
result = Topology.GetNodesBetweenPoints(new PointGeo(1, 1.9), new PointGeo(1, 1.1), line).ToList();
Assert.Equal(3, result.Count());
Assert.Equal(middle3, result[0]);
Assert.Equal(middle2, result[1]);
Assert.Equal(middle1, result[2]);
}
开发者ID:guifa,项目名称:traveltimeanalysis,代码行数:26,代码来源:TopologyTest.cs
示例9: CreateGeometries
/// <summary>
/// XAML creation of polygon and polyline geometries are currently not supported, so
/// here they are created in code. Points are generated in the XAML for this sample.
/// </summary>
private void CreateGeometries()
{
var layer = mapView1.Map.Layers.OfType<GraphicsLayer>().First();
int i = 0;
foreach (var g in layer.Graphics)
g.Attributes["Label"] = "Label #" + (++i).ToString();
Polyline line = new Polyline(FromArray(-100,-30, -80,0, -60,-30, -40,0), SpatialReferences.Wgs84);
var graphic = new Graphic(line, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["OutlinedAndDashedSymbol"]);
graphic.Attributes["Label"] = "OutlinedAndDashedSymbol";
layer.Graphics.Add(graphic);
Polygon polygon = new Polygon(FromArray(-30,-30, 0,-30, 0,0, -15,-10, -30,0, -30,-30), SpatialReferences.Wgs84);
graphic = new Graphic(polygon, (Esri.ArcGISRuntime.Symbology.Symbol)Resources["VertexFillSymbol"]);
graphic.Attributes["Label"] = "VertexFillSymbol";
layer.Graphics.Add(graphic);
//CIM symbols can only be created from JSON. The JSON is currently only constructed by publishing services to ArcGIS Server with advanced symbology
string CIMSymbolJson = "{\"type\":\"CIMSymbolReference\",\"symbol\":{\"type\":\"CIMLineSymbol\",\"symbolLayers\":[{\"type\":\"CIMFilledStroke\",\"enable\":true,\"effects\":[{\"type\":\"CIMGeometricEffectArrow\",\"geometricEffectArrowType\":\"Block\",\"primitiveName\":null,\"width\":35}],\"capStyle\":\"Round\",\"pattern\":{\"type\":\"CIMSolidPattern\",\"color\":[0,0,0,255]},\"width\":2,\"lineStyle3D\":\"Strip\",\"alignment\":\"Center\",\"joinStyle\":\"Miter\",\"miterLimit\":10,\"patternFollowsStroke\":true}]},\"symbolName\":null}";
var cimsymbol = Esri.ArcGISRuntime.Symbology.Symbol.FromJson(CIMSymbolJson);
Polyline line2 = new Polyline(FromArray(20, -30, 30, 0, 50, -30, 70, 0), SpatialReferences.Wgs84);
graphic = new Graphic(line2, cimsymbol);
graphic.Attributes["Label"] = "CIM Symbol";
layer.Graphics.Add(graphic);
i = 0;
foreach (var g in layer.Graphics)
{
g.Attributes["SymbolType"] = g.Symbol.GetType().Name;
g.Attributes["ID"] = ++i;
}
}
开发者ID:KrisFoster44,项目名称:arcgis-runtime-samples-dotnet,代码行数:36,代码来源:SymbolsAndLabels.xaml.cs
示例10: Add
public PolylineBuilder Add()
{
var polyline = new Polyline(this.Map);
this.Map.Polylines.Add(polyline);
return new PolylineBuilder(polyline);
}
开发者ID:razormad,项目名称:GooglemapMvc,代码行数:8,代码来源:PolylineFactory.cs
示例11: ExtrudedSolidCommand
public void ExtrudedSolidCommand()
{
var document = Application.DocumentManager.MdiActiveDocument;
if (document == null) // don't bother doing anything else
return;
using (var polyline = new Polyline())
{
var extrudedSquareInputResult = GetExtrusionInputFromUser();
// convenience variables
var width = extrudedSquareInputResult.Width;
var height = extrudedSquareInputResult.Height;
var depth = extrudedSquareInputResult.Depth;
// Using the polyline, we add vertices based on the user's input
polyline.AddVertexAt(0, Point2d.Origin, 0.0, 0.0, 0.0);
polyline.AddVertexAt(1, new Point2d(width, 0.0), 0.0, 0.0, 0.0);
polyline.AddVertexAt(2, new Point2d(width, height), 0.0, 0.0, 0.0);
polyline.AddVertexAt(3, new Point2d(0.0, height), 0.0, 0.0, 0.0);
polyline.Closed = true;
// add polyline to DBObjectCollection for us in creating region from curves
using (var dbObjectCollection = new DBObjectCollection { polyline })
{
using (var regionCollection = Region.CreateFromCurves(dbObjectCollection))
{
using (var region = (Region)regionCollection[0])
{
using (var solid = new Solid3d())
{
// extrude the region to the depth the user specified
solid.Extrude(region, depth, 0.0);
using (document.LockDocument())
{
using (var database = document.Database)
{
using (var transaction = database.TransactionManager.StartTransaction())
{
// get the current space for appending our extruded solid
using (var currentSpace = (BlockTableRecord)transaction.GetObject(database.CurrentSpaceId, OpenMode.ForWrite))
{
currentSpace.AppendEntity(solid);
}
transaction.AddNewlyCreatedDBObject(solid, true);
transaction.Commit();
}
}
}
}
}
}
}
}
}
开发者ID:Dotarp,项目名称:AutoCAD,代码行数:58,代码来源:Extrusions.cs
示例12: CreateSurveyPolylineFromLine
private static SurveyPolyline CreateSurveyPolylineFromLine(ILine line)
{
IPolyline polyline = new Polyline(line.Id,
line.RunDirection);
polyline.AddSegment(line);
return new SurveyPolyline(polyline);
}
开发者ID:tschroedter,项目名称:Selkie.WPF,代码行数:9,代码来源:SurveyFeatureSource.cs
示例13: PolylineAroundClosedCurve
public static Polyline PolylineAroundClosedCurve(ICurve curve) {
Polyline poly = new Polyline();
foreach (Point point in PointsOnAroundPolyline(curve))
poly.AddPoint(point);
if (Point.GetTriangleOrientation(poly.StartPoint.Point, poly.StartPoint.Next.Point, poly.StartPoint.Next.Next.Point) == TriangleOrientation.Counterclockwise)
poly = (Polyline)poly.Reverse();
poly.Closed = true;
return poly;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:9,代码来源:PenetrationDepth.cs
示例14: Polygon
internal Polygon(Polyline polyline) {
this.polyline = polyline;
points = new PolylinePoint[polyline.Count];
int i = 0;
PolylinePoint pp = polyline.StartPoint;
for (; i < polyline.Count; i++, pp = pp.Next)
points[i] = pp;
}
开发者ID:danielskowronski,项目名称:network-max-flow-demo,代码行数:9,代码来源:Polygon.cs
示例15: ProjectExtents
/// <summary>
/// Creates a new Polyline that is the result of projecting the transformed MinPoint and MaxPoint of 'extents'
/// parallel to 'direction' onto 'plane' and returns it.
/// </summary>
/// <param name="extents">The Extents3d of a transformed from World to dirPlane Polyline.</param>
/// <param name="plane">The plane onto which the points are to be projected.</param>
/// <param name="direction">Direction (in WCS coordinates) of the projection</param>
/// <param name="dirPlane">The plane which origin is 0, 0, 0 and 'direction' is the normal.</param>
/// <returns>The newly created Polyline.</returns>
internal static Polyline ProjectExtents(Extents3d extents, Plane plane, Vector3d direction, Plane dirPlane)
{
Point3d pt1 = extents.MinPoint.TransformBy(Matrix3d.PlaneToWorld(dirPlane));
Point3d pt2 = extents.MaxPoint.TransformBy(Matrix3d.PlaneToWorld(dirPlane));
Polyline projectedPline = new Polyline(2);
projectedPline.AddVertexAt(0, pt1.Project(plane, direction).Convert2d(), 0.0, 0.0, 0.0);
projectedPline.AddVertexAt(1, pt2.Project(plane, direction).Convert2d(), 0.0, 0.0, 0.0);
return projectedPline;
}
开发者ID:vildar82,项目名称:AcadLib,代码行数:18,代码来源:GeomExt.cs
示例16: CreatePart
/// <summary>
/// Creates the part.
/// </summary>
/// <returns>
/// UIElement
/// </returns>
public override UIElement CreatePart()
{
Lines = new Polyline();
PointCollection pointsCollection=new PointCollection {StartPoint, StepPoint, EndPoint};
Lines.Points = pointsCollection;
SetBindingForStrokeandStrokeThickness(Lines);
UiElement = Lines;
return Lines;
}
开发者ID:jcw-,项目名称:sparrowtoolkit,代码行数:15,代码来源:StepLinePart.cs
示例17: CreateAlign
// 만들어진 폴리라인을 가지고 선형을 만들어주는 메소드 선형뿐만아니라 그리드 뷰까지 찍어줌
public Alignment CreateAlign(Polyline guid)
{
Document dc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; // 현재 도큐먼트를 가져옴
Database db = dc.Database; // 현재 데이터베이스를 가져옴
CivilDocument doc = CivilApplication.ActiveDocument;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction acTrans = db.TransactionManager.StartTransaction())
{
BlockTable acBlktbl = acTrans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; // 선을 그리기 위한 블럭테이블 생성
BlockTableRecord acblkTblrec = acTrans.GetObject(acBlktbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; // 어디 도면에 그릴지 선택
PolylineOptions plops = new PolylineOptions(); // 폴리라인 옵션 지정
plops.AddCurvesBetweenTangents = true;
plops.EraseExistingEntities = true;
plops.PlineId = guid.ObjectId;
ObjectId testAlignmentID = Alignment.Create(doc, plops, "내가만든 선형", null, "0", "Proposed", "All Labels");
Alignment oAlignment = acTrans.GetObject(testAlignmentID, OpenMode.ForRead) as Alignment;
ObjectId layerId = oAlignment.LayerId;
// get first surface in the document
ObjectId surfaceId = doc.GetSurfaceIds()[0];
// get first style in the document
ObjectId styleId = doc.Styles.ProfileStyles[0];
// get the first label set style in the document
ObjectId labelSetId = doc.Styles.LabelSetStyles.ProfileLabelSetStyles[0];
try
{
ObjectId profileId = Profile.CreateFromSurface("My Profile", testAlignmentID, surfaceId, layerId, styleId, labelSetId);
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
ed.WriteMessage(e.Message);
}
PromptPointResult pPtRes;
PromptPointOptions pPtOpts = new PromptPointOptions("종단뷰를 그릴 위치를 찍어주세요~");
pPtRes = dc.Editor.GetPoint(pPtOpts);
Point3d ptStart = pPtRes.Value;
if (pPtRes.Status == PromptStatus.Cancel) return null;
// ObjectId ProfileViewId = ProfileView.Create(alignID, ptStart);
ObjectId pfrVBSStyleId = doc.Styles.ProfileViewBandSetStyles[8];
ObjectId ProfileViewId2 = ProfileView.Create(doc, "My Profile", pfrVBSStyleId, testAlignmentID, ptStart);
//doc, "My Profile View", pfrVBSStyleId, alignID, ptInsert
acTrans.Commit();
return oAlignment;
}
}
开发者ID:flycoflyco,项目名称:HyeSeong,代码行数:57,代码来源:Class1.cs
示例18: GetVertexes
public static List<PolylineVertex> GetVertexes(Polyline pl, string name)
{
var res = new List<PolylineVertex>();
for (int i = 0; i < pl.NumberOfVertices; i++)
{
var pt = pl.GetPoint2dAt(i);
res.Add(new PolylineVertex(name, i, pt));
}
return res;
}
开发者ID:vildar82,项目名称:AcadLib,代码行数:10,代码来源:PolylineVertex.cs
示例19: GetPolyline
public static Polyline GetPolyline(this Extents3d ext)
{
var pl = new Polyline();
pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0);
pl.AddVertexAt(1, new Point2d (ext.MinPoint.X, ext.MaxPoint.Y) , 0, 0, 0);
pl.AddVertexAt(2, ext.MaxPoint.Convert2d(), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0);
pl.Closed = true;
return pl;
}
开发者ID:vildar82,项目名称:AcadLib,代码行数:10,代码来源:ExtentsExtension.cs
示例20: PolylineNodesCountReturnsCorrectValue
public void PolylineNodesCountReturnsCorrectValue()
{
PointGeo p1 = new PointGeo(1, 2);
PointGeo p2 = new PointGeo(3, 4);
Polyline<PointGeo> target = new Polyline<PointGeo>();
target.Nodes.Add(p1);
target.Nodes.Add(p2);
Assert.Equal(2, target.NodesCount);
}
开发者ID:guifa,项目名称:traveltimeanalysis,代码行数:11,代码来源:PolylineTest.cs
注:本文中的Polyline类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论