public void WhenCreatingProfile_ProfileShouldBeCreatedWithDefaultAttributes() { var id = Guid.NewGuid(); var userId = Guid.NewGuid(); var location = new GeoLocation(63.0001, 15.0001, 123.5); var trackPoint = new TrackPoint(location, 0.0, DateTime.Now); var track = new Track(Guid.NewGuid(), new TrackPoint[] { trackPoint }); var coffeeAttribute = new PlaceAttribute(PlaceAttributeType.Coffee, true); var place = new Place(Guid.NewGuid(), userId, "Test place", "", location, GeoPolygon.CreateRect(location, 0.05), coffeeAttribute); var legs = new Leg[] { new Leg(trackPoint, trackPoint, 0.0, 0.0) }; var startSplit = new ResultSplit(trackPoint); var result = new Result(new Athlete(userId, "IAthlete"), new ResultSplit[] { startSplit, new ResultSplit(trackPoint, startSplit, startSplit) }); PlaceRepository.Add(place); var startProfilePlace = new ProfilePlace(place, trackPoint, true, true, new ProfilePlaceAttribute(coffeeAttribute.Type, coffeeAttribute.DefaultValue)); var finishProfilePlace = new ProfilePlace(place, trackPoint, true, true, new ProfilePlaceAttribute(coffeeAttribute.Type, coffeeAttribute.DefaultValue)); When(new CreateProfile(id, userId, Guid.Empty, "First", track)); Then(new ProfileCreated(id, userId, Guid.Empty, "First", DateTimeProvider.Now, track, 0.0, 0.0, trackPoint, trackPoint, null, new ProfilePlace[] { startProfilePlace, finishProfilePlace }, legs, result)); }
private void ExtractPlaces(Feature feature, string @namespace, Dictionary <string, Place> places) { // Is the passed in value a Placemark? Placemark placemark = feature as Placemark; if (placemark != null) { var name = placemark.Name; var fullName = @namespace + NamespaceSeparator + name; GeoLocation location = null; GeoPolygon fence = null; var point = placemark.Geometry as Point; if (point != null) { location = new GeoLocation(point.Coordinate.Latitude, point.Coordinate.Longitude, (double)point.Coordinate.Altitude); fence = GeoPolygon.CreateRect(location, 0.05); if (!places.ContainsKey(fullName)) { places.Add(fullName, new Place(Guid.NewGuid(), UserId, placemark.Name, @namespace, location, fence, PlaceAttribute.CreateDefault())); } else { var place = places[fullName]; place.Location = location; } } var polygon = placemark.Geometry as Polygon; if (polygon != null) { var locations = polygon.OuterBoundary.LinearRing.Coordinates.Select(vector => new GeoLocation(vector.Latitude, vector.Longitude, (double)vector.Altitude)); fence = new GeoPolygon(locations.ToArray()); location = fence.Boudary.GetCenter(); if (!places.ContainsKey(fullName)) { places.Add(fullName, new Place(Guid.NewGuid(), UserId, placemark.Name, @namespace, location, fence, null)); } else { var place = places[fullName]; place.Polygon = fence; } } } else { // Is it a Container, as the Container might have a child Placemark? Container container = feature as Container; if (container != null) { var newNamespace = string.Empty; if (!(container is Document)) { if (@namespace != string.Empty) { newNamespace = @namespace + NamespaceSeparator + container.Name; } else { newNamespace = container.Name; } } // Check each Feature to see if it's a Placemark or another Container foreach (var f in container.Features) { ExtractPlaces(f, newNamespace, places); } } } }