partial void Merge(PolygonLocation entity, LocationDTO dto, object state) { var zrange = dto.ZRange; if (zrange != null && zrange.Length == 2) { entity.ZRange = this.vector2DConverter.Convert(zrange, dto); } var points = dto.Points; if (points != null) { entity.Points = new List <Vector2D>(points.Length); foreach (var point in points) { if (point == null || point.Length != 2) { continue; } entity.Points.Add(this.vector2DConverter.Convert(point, dto)); } } }
/// <inheritdoc /> public Location Convert(LocationDTO value, object state) { var entity = new PolygonLocation(); this.Merge(entity, value, state); return(entity); }
/// <summary> /// Decodes the given location. /// </summary> public static ReferencedPolygon Decode(PolygonLocation location) { return(new ReferencedPolygon() { Coordinates = location.Coordinates.Clone() as Coordinate[] }); }
protected override void OnMouseMove(MouseEventArgs args) { base.OnMouseMove(args); args.Handled = true; PointD cursor = args.GetPosition(OutputBox).ToPointD(); // determine relative location of cursor PolygonLocation location = (_tolerance == 0m ? GeoAlgorithms.PointInPolygon(cursor, _polygon) : GeoAlgorithms.PointInPolygon(cursor, _polygon, (double)_tolerance)); LocationLabel.Content = location; }
public void DecodeReferencedPolygonLocation() { // build the location to decode. var location = new PolygonLocation(); location.Coordinates = new Model.Coordinate[5]; location.Coordinates[0] = new Model.Coordinate() { Latitude = 49.60576, Longitude = 6.12549 }; location.Coordinates[1] = new Model.Coordinate() { Latitude = 49.60591, Longitude = 6.12903 }; location.Coordinates[2] = new Model.Coordinate() { Latitude = 49.60834, Longitude = 6.12739 }; location.Coordinates[3] = new Model.Coordinate() { Latitude = 49.60870, Longitude = 6.12657 }; location.Coordinates[4] = new Model.Coordinate() { Latitude = 49.60795, Longitude = 6.12492 }; // decode the location //var decoder = new GeoCoordinateLocationDecoder(); var referencedDecoder = new ReferencedPolygonDecoder(null, null); var referencedLocation = referencedDecoder.Decode(location); // confirm result. Assert.IsNotNull(referencedLocation); Assert.AreEqual(referencedLocation.Coordinates[0].Latitude, location.Coordinates[0].Latitude); Assert.AreEqual(referencedLocation.Coordinates[0].Longitude, location.Coordinates[0].Longitude); Assert.AreEqual(referencedLocation.Coordinates[1].Latitude, location.Coordinates[1].Latitude); Assert.AreEqual(referencedLocation.Coordinates[1].Longitude, location.Coordinates[1].Longitude); Assert.AreEqual(referencedLocation.Coordinates[2].Latitude, location.Coordinates[2].Latitude); Assert.AreEqual(referencedLocation.Coordinates[2].Longitude, location.Coordinates[2].Longitude); Assert.AreEqual(referencedLocation.Coordinates[3].Latitude, location.Coordinates[3].Latitude); Assert.AreEqual(referencedLocation.Coordinates[3].Longitude, location.Coordinates[3].Longitude); Assert.AreEqual(referencedLocation.Coordinates[4].Latitude, location.Coordinates[4].Latitude); Assert.AreEqual(referencedLocation.Coordinates[4].Longitude, location.Coordinates[4].Longitude); }
/// <summary> /// Decodes the given data into a location reference. /// </summary> public static PolygonLocation Decode(byte[] data) { // just need to decode list of coordinate. var coordinates = new List <Coordinate>(); coordinates.Add(CoordinateConverter.Decode(data, 1)); // calculate the number of points. var previous = coordinates[0]; var location = 7; int points = 1 + (data.Length - 6) / 4; for (int idx = 0; idx < points - 1; idx++) { coordinates.Add(CoordinateConverter.DecodeRelative( coordinates[coordinates.Count - 1], data, location + (idx * 4))); } var polygonLocation = new PolygonLocation(); polygonLocation.Coordinates = coordinates.ToArray(); return(polygonLocation); }
// Implement this method in a buddy class to set properties that are specific to 'PolygonLocation' (if any) partial void Merge(PolygonLocation entity, LocationDTO dto, object state);