public Feature MapAsSingleFeature(APlus guidancePatternAdapt) { Point point = PointMapper.MapPoint2Point(guidancePatternAdapt.Point, _properties.AffineTransformation); _featProps.Add("Heading", guidancePatternAdapt.Heading.ToString()); return(new Feature(point, _featProps)); }
public UserService() { this.UserRepository = new UserRepository(); this.CommunityManagementRepository = new CommunityManagementRepository(); this.UserMapper = new UserMapper(); this.PointMapper = new PointMapper(); }
private void DrawMainPolygon(Canvas canvas, List <Point> points) { if (points.Count < 3) { return; } var path = new Path(); var pathSegmentCollection = new PathSegmentCollection(); var pathFigure = new PathFigure(); List <Point> processedPoints = JarvisAlgorithm.ConvexHull(points); for (int i = 0; i < processedPoints.Count; i++) { processedPoints[i] = new Point(processedPoints[i].X + 100, processedPoints[i].Y + 100); } pathFigure.StartPoint = PointMapper.fromMyPointToSystemPoint(processedPoints.First()); var beizerSegments = InterpolationUtils.InterpolatePointWithBeizerCurves(processedPoints, true); foreach (var beizerCurveSegment in beizerSegments) { var segment = new BezierSegment { Point1 = PointMapper.fromMyPointToSystemPoint(beizerCurveSegment.FirstControlPoint), Point2 = PointMapper.fromMyPointToSystemPoint(beizerCurveSegment.SecondControlPoint), Point3 = PointMapper.fromMyPointToSystemPoint(beizerCurveSegment.EndPoint) }; pathSegmentCollection.Add(segment); } pathFigure.Segments = pathSegmentCollection; var pathFigureCollection = new PathFigureCollection { pathFigure }; var pathGeometry = new PathGeometry { Figures = pathFigureCollection }; path.Data = pathGeometry; path.Stroke = Brushes.Black; path.StrokeThickness = 1; canvas.Children.Add(path); }
public static Polygon TransformToPolygon(Rectangle2D rectangle) => new Polygon(PointMapper.TranslateToSystemPoint(rectangle.Vertices));
public List <Feature> MapAsMultipleFeatures(PivotGuidancePattern guidancePatternAdapt) { _featProps.Add("DefinitionMethod", guidancePatternAdapt.DefinitionMethod.ToString()); List <Feature> centerPivotFeatures = new List <Feature>(); const string labelPT = "PointType"; const string labelCP = "Center"; const string labelRa = "Radius (m)"; List <Position> positions = new List <Position>(); var oneDegree = Math.PI / 180.0; switch (guidancePatternAdapt.DefinitionMethod) { case PivotGuidanceDefinitionEnum.PivotGuidancePatternStartEndCenter: case PivotGuidanceDefinitionEnum.PivotGuidancePatternThreePoints: while (_featProps.ContainsKey(labelPT)) { _featProps.Remove(labelPT); } Dictionary <string, object> featProps2 = new Dictionary <string, object>(_featProps); Dictionary <string, object> featProps3 = new Dictionary <string, object>(_featProps); var distanceEllipsoidal = GetDistanceEllipsoidal(guidancePatternAdapt.Center.X, guidancePatternAdapt.Center.Y, guidancePatternAdapt.StartPoint.X, guidancePatternAdapt.StartPoint.Y); _featProps.Add(labelPT, "StartPoint"); centerPivotFeatures.Add(new Feature(PointMapper.MapPoint2Point(guidancePatternAdapt.StartPoint, _properties.AffineTransformation), _featProps)); featProps2.Add(labelPT, labelCP); featProps2.Add(labelRa, distanceEllipsoidal); centerPivotFeatures.Add(new Feature(PointMapper.MapPoint2Point(guidancePatternAdapt.Center, _properties.AffineTransformation), featProps2)); featProps3.Add(labelPT, "EndPoint"); centerPivotFeatures.Add(new Feature(PointMapper.MapPoint2Point(guidancePatternAdapt.EndPoint, _properties.AffineTransformation), featProps3)); // extra "visually nice" Features var distanceCartesian = GetDistanceCartesian(guidancePatternAdapt.Center.X, guidancePatternAdapt.Center.Y, guidancePatternAdapt.StartPoint.X, guidancePatternAdapt.StartPoint.Y); for (int i = 0; i <= 360; i += 2) { // guidancePatternAdapt.GuidancePatternOptions ([1]Clockwise [2]Couter-clockwise [3]Full Circle) not yet available positions.Add(new Position((distanceCartesian * Math.Cos(i * oneDegree)) + guidancePatternAdapt.Center.Y, (distanceCartesian * Math.Sin(i * oneDegree)) + guidancePatternAdapt.Center.X)); } centerPivotFeatures.Add(new Feature(new GeoJSON.Net.Geometry.LineString(positions), new Dictionary <string, object>() { { labelRa, distanceEllipsoidal } })); centerPivotFeatures.Add(new Feature(LineStringMapper.MapLineString(guidancePatternAdapt.Center, guidancePatternAdapt.StartPoint, null), null)); centerPivotFeatures.Add(new Feature(LineStringMapper.MapLineString(guidancePatternAdapt.Center, guidancePatternAdapt.EndPoint, null), null)); break; case PivotGuidanceDefinitionEnum.PivotGuidancePatternCenterRadius: if (guidancePatternAdapt.Radius == null) { Console.WriteLine("Error if (guidancePatternAdapt.Radius == null)"); break; } while (_featProps.ContainsKey(labelPT)) { _featProps.Remove(labelPT); } _featProps.Add(labelPT, labelCP); _featProps.Add(labelRa, guidancePatternAdapt.Radius.Multiply(1000.0)); centerPivotFeatures.Add(new Feature(PointMapper.MapPoint2Point(guidancePatternAdapt.Center, _properties.AffineTransformation), _featProps)); // extra "visually nice" Features for (int i = 0; i <= 360; i += 2) { positions.Add(new Position((0.00036 * Math.Cos(i * oneDegree)) + guidancePatternAdapt.Center.Y, (0.00036 * Math.Sin(i * oneDegree)) + guidancePatternAdapt.Center.X)); } centerPivotFeatures.Add(new Feature(new GeoJSON.Net.Geometry.LineString(positions), new Dictionary <string, object>() { { labelRa, guidancePatternAdapt.Radius.Multiply(1000.0) } })); break; default: break; } return(centerPivotFeatures); }
public Axis(PointMapper mapper, AxisOrigin origin) { this.mapper = mapper; this.origin = origin; }
private Feature Map(RasterGridPrescription prescription) { GeoJSON.Net.Geometry.IGeometryObject geometry = null; Dictionary <string, object> properties = new Dictionary <string, object>(); if (prescription.BoundingBox != null) { geometry = PolygonMapper.MapBoundingBox(prescription.BoundingBox, _properties.AffineTransformation); } else { geometry = PointMapper.MapPoint2Point(prescription.Origin, _properties.AffineTransformation); } properties.Add("RowCount", prescription.RowCount); properties.Add("ColumnCount", prescription.ColumnCount); properties.Add("CellWidth", prescription.CellWidth.Value.Value); properties.Add("CellHeight", prescription.CellHeight.Value.Value); //properties.Add("RxProductLookups", prescription.RxProductLookups); // Id, ProductId, Representation, UnitOfMeasure // SpatialPrescription: not sure these rates mean anything for the geojson output double outOfFieldRate = -1.0; // something save to compare with if (prescription.OutOfFieldRate != null) { properties.Add("OutOfFieldRate", prescription.OutOfFieldRate.Value.Value); outOfFieldRate = prescription.OutOfFieldRate.Value.Value; } if (prescription.LossOfGpsRate != null) { properties.Add("LossOfGpsRate", prescription.LossOfGpsRate.Value.Value); } double minRate = double.MaxValue; double maxRate = -1.0; foreach (var rate in prescription.Rates) { if (rate.RxRates[0].Rate != outOfFieldRate) { minRate = Math.Min(minRate, rate.RxRates[0].Rate); maxRate = Math.Max(maxRate, rate.RxRates[0].Rate); } } properties.Add("MinRate", minRate); properties.Add("MaxRate", maxRate); List <Dictionary <string, object> > products = new List <Dictionary <string, object> > { }; foreach (var rxproduct in prescription.RxProductLookups) { if (products.Where(p => p.ContainsKey("productId") && (int)p["productId"] == rxproduct.ProductId).FirstOrDefault() == null) { Dictionary <string, object> product = new Dictionary <string, object>(); product.Add("productId", rxproduct.ProductId); product.Add("productCode", rxproduct.Representation.Code); product.Add("productUom", rxproduct.UnitOfMeasure.Code); Product adaptProduct = _dataModel.Catalog.Products.Where(p => p.Id.ReferenceId == rxproduct.ProductId).FirstOrDefault(); if (adaptProduct != null) { product.Add("productDescription", adaptProduct.Description); product.Add("productType", adaptProduct.ProductType.ToString()); // or via GetName? } products.Add(product); } } //Array Values = products.Select(x => (Object)x).ToArray(); ; properties.Add("Products", products.ToArray()); return(new Feature(geometry, properties)); }
public List <Feature> MapMultiple(OperationData operation, IEnumerable <SpatialRecord> spatialRecords) { List <DeviceElementUse> deviceElementUses = GetAllSections(operation); List <WorkingData> workingDatas = deviceElementUses.SelectMany(x => x.GetWorkingDatas()).ToList(); // meters // Display representaitons for debug Console.WriteLine($"Contains the following representations: "); foreach (var workingData in workingDatas) { Console.WriteLine($"{workingData.Representation.CodeSource}: {workingData.Representation.Code}"); } Console.WriteLine($""); // inspired by ISOv4Plugin/Mappers/TimeLogMapper List <Feature> features = new List <Feature>(); foreach (SpatialRecord spatialRecord in spatialRecords) { if (spatialRecord.Geometry != null && spatialRecord.Geometry as Point != null) { Dictionary <string, object> properties = new Dictionary <string, object>(); Point location = spatialRecord.Geometry as Point; if (location.X == 0 || location.Y == 0) { continue; } // altitude if (location.Z != null) { properties.Add("Elevation", location.Z); } // timeStamp properties.Add("Timestamp", spatialRecord.Timestamp.ToString()); // meter values var workingDatasWithValues = workingDatas.Where(x => spatialRecord.GetMeterValue(x) != null); foreach (WorkingData workingData in workingDatasWithValues) //.Where(d => _dlvOrdersByWorkingDataID.ContainsKey(d.Id.ReferenceId))) { string key = workingData.Representation.Code; object value = null; string uom = null; if (workingData is EnumeratedWorkingData) { EnumeratedWorkingData enumeratedMeter = workingData as EnumeratedWorkingData; if (enumeratedMeter != null && spatialRecord.GetMeterValue(enumeratedMeter) != null) { EnumeratedValue enumValue = (spatialRecord.GetMeterValue(enumeratedMeter) as EnumeratedValue); value = enumValue.Value.Value.ToString(); } } else if (workingData is NumericWorkingData) { NumericWorkingData numericMeter = workingData as NumericWorkingData; if (numericMeter != null && spatialRecord.GetMeterValue(numericMeter) != null) { NumericRepresentationValue numValue = spatialRecord.GetMeterValue(numericMeter) as NumericRepresentationValue; value = numValue.Value.Value; uom = numValue.Value.UnitOfMeasure.Code; // better key for DDI (hex2int) if (workingData.Representation.CodeSource == RepresentationCodeSourceEnum.ISO11783_DDI) { if (numValue.Designator != null && numValue.Designator != "") { key = numValue.Designator; } else if (workingData.Representation.Description != null && workingData.Representation.Description != "") { key = workingData.Representation.Description; } else { // ILaR cause: key missing in representation system int intKey = int.Parse(key, System.Globalization.NumberStyles.HexNumber); if (_missingDDI.ContainsKey(intKey)) { key = _missingDDI[intKey]; } else { key = "DDI_" + intKey.ToString(); } } } } } else // needed ? { value = spatialRecord.GetMeterValue(workingData); } if (value != null && key != null) { properties.Add(key, value); if (uom != null) { properties.Add(key + "_Uom", uom); } } } // add to FC features.Add(new Feature(PointMapper.MapPoint2Point(spatialRecord.Geometry as Point, _properties.AffineTransformation), properties)); } } return(features); }
private void MapPath_Loaded(object sender, RoutedEventArgs e) { var model = ((MapViewModel)DataContext); Map = new PointMapper(InkCanvas.ActualHeight, InkCanvas.ActualWidth, model.CameraCount, 30); }
private void Junction_Paint(object sender, PaintEventArgs e) { PointMapper.Offset.SetOffset(Size.Width / 2, Size.Height / 2); System.Drawing.Graphics graphics = e.Graphics; graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; foreach (Rectangle2D channel in SampleJunction.AllChannelBound) { graphics.FillPolygon(Brush_Road, GlobalAdapter.TransformToPolygon(channel).Vertices); } graphics.FillPolygon(Brush_Road, GlobalAdapter.TransformToPolygon(SampleJunction.Junction_BOX).Vertices); foreach (Rectangle2D road in SampleJunction.AllChannelBound) { LineSegment2D border = (new LineSegment2D(road.AD)).Move(10, road.Inclination + Angle.A270); graphics.DrawLine(new Pen(Color.FromArgb(28, 28, 28), 10), PointMapper.TranslateToSystemPoint(border.A), PointMapper.TranslateToSystemPoint(border.B)); } foreach (Rectangle2D road in SampleJunction.EntryBounds) { LineSegment2D yellow_left = (new LineSegment2D(road.AD)).Move(0.8, road.Inclination + Angle.A270); graphics.DrawLine(Pens_RoadYellowLine, PointMapper.TranslateToSystemPoint(new Point2D(yellow_left.A).Move(10, road.Inclination)), PointMapper.TranslateToSystemPoint(yellow_left.B)); LineSegment2D yellow_right = (new LineSegment2D(road.BC)).Move(1.3, road.Inclination + Angle.A90); graphics.DrawLine(Pens_RoadYellowLine, PointMapper.TranslateToSystemPoint(new Point2D(yellow_right.A)), PointMapper.TranslateToSystemPoint(yellow_right.B)); LineSegment2D ZebraLine = new LineSegment2D(new Point2D(yellow_left.A), new Point2D(yellow_left.A).Move(5, road.Inclination - Angle.A180)).Move(0.9, road.Inclination + Angle.A270); graphics.DrawLine(Pens_ZebraLine, PointMapper.TranslateToSystemPoint(ZebraLine.A), PointMapper.TranslateToSystemPoint(ZebraLine.B)); for (int i = 0; i < 5; ++i) { graphics.DrawLine(Pens_ZebraLine, PointMapper.TranslateToSystemPoint(ZebraLine.A.Move(1.2, road.Inclination - Angle.A90)), PointMapper.TranslateToSystemPoint(ZebraLine.B.Move(1.2, road.Inclination - Angle.A90))); } LineSegment2D EntryLine = new LineSegment2D(new Point2D(yellow_left.A).Move(6, road.Inclination - Angle.A180), new Point2D(yellow_right.A).Move(6, road.Inclination - Angle.A180)).Shirnk(-.25); graphics.DrawLine(Pens_ZebraLine, PointMapper.TranslateToSystemPoint(EntryLine.A), PointMapper.TranslateToSystemPoint(EntryLine.B)); } foreach (Rectangle2D road in SampleJunction.ExitBounds) { LineSegment2D yellow_left = (new LineSegment2D(road.AD)).Move(0.8, road.Inclination + Angle.A270); graphics.DrawLine(Pens_RoadYellowLine, PointMapper.TranslateToSystemPoint(new Point2D(yellow_left.A)), PointMapper.TranslateToSystemPoint(new Point2D(yellow_left.B).Move(10, road.Inclination - Angle.A180))); LineSegment2D yellow_right = (new LineSegment2D(road.BC)).Move(1.3, road.Inclination + Angle.A90); graphics.DrawLine(Pens_RoadYellowLine, PointMapper.TranslateToSystemPoint(new Point2D(yellow_right.A)), PointMapper.TranslateToSystemPoint(new Point2D(yellow_right.B))); LineSegment2D ZebraLine = new LineSegment2D(yellow_left.B, new Point2D(yellow_left.B).Move(5, road.Inclination)).Move(0.9, road.Inclination + Angle.A270); graphics.DrawLine(Pens_ZebraLine, PointMapper.TranslateToSystemPoint(ZebraLine.A), PointMapper.TranslateToSystemPoint(ZebraLine.B)); for (int i = 0; i < 5; ++i) { graphics.DrawLine(Pens_ZebraLine, PointMapper.TranslateToSystemPoint(ZebraLine.A.Move(1.2, road.Inclination - Angle.A90)), PointMapper.TranslateToSystemPoint(ZebraLine.B.Move(1.2, road.Inclination - Angle.A90))); } } foreach (GUI.Simulation.Roads.Road road in Simulation.Roads) { foreach (GUI.Simulation.Vehicles.Vehicle vehicle in road.LeftLane.Vehicles) { SolidBrush __brush; if (road.SignalState == 'G') { __brush = new SolidBrush(Color.Green); } else if (road.SignalState == 'Y') { __brush = new SolidBrush(Color.Yellow); } else if (road.SignalState == 'R') { __brush = new SolidBrush(Color.Red); } else { __brush = new SolidBrush(Color.Gray); } //if (vehicle.DurationWait > 15) // __brush = new SolidBrush(Color.Red); //else // __brush = new SolidBrush(Color.RoyalBlue); graphics.FillPolygon(__brush, GlobalAdapter.TransformToPolygon(vehicle.CurrentBound).Vertices); graphics.DrawLine(new Pen(Color.FromArgb(50, 50, 50), 2), PointMapper.TranslateToSystemPoint(vehicle.Position), PointMapper.TranslateToSystemPoint(vehicle.BrakeVector)); //graphics.DrawString(vehicle.Speed.ToString(), new Font("Calibri", 9), new SolidBrush(Color.Green), PointMapper.TranslateToSystemPoint(vehicle.Position)); } foreach (GUI.Simulation.Vehicles.Vehicle vehicle in road.RightLane.Vehicles) { SolidBrush __brush; if (road.SignalState == 'G') { __brush = new SolidBrush(Color.Green); } else if (road.SignalState == 'Y') { __brush = new SolidBrush(Color.Yellow); } else if (road.SignalState == 'R') { __brush = new SolidBrush(Color.Red); } else { __brush = new SolidBrush(Color.Gray); } //if (vehicle.DurationWait > 15) // __brush = new SolidBrush(Color.Red); //else // __brush = new SolidBrush(Color.RoyalBlue); graphics.FillPolygon(__brush, GlobalAdapter.TransformToPolygon(vehicle.CurrentBound).Vertices); graphics.DrawLine(new Pen(Color.FromArgb(50, 50, 50), 2), PointMapper.TranslateToSystemPoint(vehicle.Position), PointMapper.TranslateToSystemPoint(vehicle.BrakeVector)); //graphics.DrawString(vehicle.Speed.ToString(), new Font("Calibri", 9), new SolidBrush(Color.Green), PointMapper.TranslateToSystemPoint(vehicle.Position)); } } avgTime.Text = Math.Round(Simulation.AverageWaitTime.AverageValue, 2).ToString() + " s"; }