本文整理汇总了C#中Polyline类的典型用法代码示例。如果您正苦于以下问题:C# Polyline类的具体用法?C# Polyline怎么用?C# Polyline使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Polyline类属于命名空间,在下文中一共展示了Polyline类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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]);
}
示例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;
}
}
示例10: Add
public PolylineBuilder Add()
{
var polyline = new Polyline(this.Map);
this.Map.Polylines.Add(polyline);
return new PolylineBuilder(polyline);
}
示例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();
}
}
}
}
}
}
}
}
}
示例12: CreateSurveyPolylineFromLine
private static SurveyPolyline CreateSurveyPolylineFromLine(ILine line)
{
IPolyline polyline = new Polyline(line.Id,
line.RunDirection);
polyline.AddSegment(line);
return new SurveyPolyline(polyline);
}
示例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;
}
示例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;
}
示例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;
}