Example #1
0
        public void Constructor_InitializedWithValidValues_CorrectPropertyTypes()
        {
            // Setup
            var referencePoint  = new Point2D(2.2, 3.3);
            var profileLocation = new ProfileLocation("id", null, 1.1, referencePoint);

            // Assert
            Assert.IsInstanceOf(typeof(string), profileLocation.Id);
            Assert.IsNull(profileLocation.Name);
            Assert.IsInstanceOf(typeof(double), profileLocation.Offset);
            Assert.IsInstanceOf(typeof(Point2D), profileLocation.Point);
        }
Example #2
0
        public void Constructor_InitializedWithValidValues_CorrectProperties()
        {
            // Setup
            var referencePoint  = new Point2D(2.2, 3.3);
            var profileLocation = new ProfileLocation("id", "name", 1.1, referencePoint);

            // Assert
            Assert.AreEqual("id", profileLocation.Id);
            Assert.AreEqual("name", profileLocation.Name);
            Assert.AreEqual(1.1, profileLocation.Offset);
            Assert.AreEqual(referencePoint, profileLocation.Point);
        }
Example #3
0
 private static DikeProfile CreateDikeProfile(ProfileLocation dikeProfileLocation, DikeProfileData dikeProfileData)
 {
     return(new DikeProfile(dikeProfileLocation.Point, dikeProfileData.DikeGeometry,
                            dikeProfileData.ForeshoreGeometry.Select(fg => fg.Point),
                            CreateBreakWater(dikeProfileData),
                            new DikeProfile.ConstructionProperties
     {
         Id = dikeProfileData.Id,
         Name = dikeProfileLocation.Name,
         X0 = dikeProfileLocation.Offset,
         Orientation = dikeProfileData.Orientation,
         DikeHeight = dikeProfileData.DikeHeight
     }));
 }
Example #4
0
        private static ForeshoreProfile CreateForeshoreProfile(ProfileLocation dikeProfileLocation, DikeProfileData dikeProfileData)
        {
            var foreshoreProfile = new ForeshoreProfile(dikeProfileLocation.Point,
                                                        dikeProfileData.ForeshoreGeometry.Select(fg => fg.Point),
                                                        CreateBreakWater(dikeProfileData),
                                                        new ForeshoreProfile.ConstructionProperties
            {
                Id          = dikeProfileData.Id,
                Name        = dikeProfileLocation.Name,
                X0          = dikeProfileLocation.Offset,
                Orientation = dikeProfileData.Orientation
            });

            return(foreshoreProfile);
        }
Example #5
0
        /// <summary>
        /// Get the next <see cref="ProfileLocation"/> from <paramref name="profileLocationReader"/>
        /// and add to <paramref name="profileLocations"/> in case it is close enough to the <see cref="ReferenceLine"/>.
        /// </summary>
        /// <param name="profileLocationReader">Reader reading <see cref="ProfileLocation"/> objects from a shapefile.</param>
        /// <param name="profileLocations">Collection of <see cref="ProfileLocation"/> objects
        /// to which the new <see cref="ProfileLocation"/> is to be added.</param>
        /// <exception cref="CriticalFileReadException">Thrown when the <paramref name="profileLocationReader"/> reads
        /// multiple locations for a profile.</exception>
        /// <exception cref="LineParseException">Thrown when either:
        /// <list type="bullet">
        /// <item>The shapefile misses a value for a required attribute.</item>
        /// <item>The shapefile has an attribute whose type is incorrect.</item>
        /// <item>The read <see cref="ProfileLocation"/> is outside the reference line.</item>
        /// </list></exception>
        private void AddNextProfileLocation(ProfileLocationReader profileLocationReader, Collection <ProfileLocation> profileLocations)
        {
            ProfileLocation profileLocation         = profileLocationReader.GetNextProfileLocation();
            double          distanceToReferenceLine = GetDistanceToReferenceLine(profileLocation.Point);

            if (distanceToReferenceLine > 1.0)
            {
                throw new LineParseException(string.Format(Resources.ProfilesImporter_AddNextProfileLocation_Location_with_id_0_outside_referenceline, profileLocation.Id));
            }

            if (profileLocations.Any(dpl => dpl.Id.Equals(profileLocation.Id)))
            {
                string message = string.Format(Resources.ProfilesImporter_AddNextProfileLocation_Location_with_id_0_already_read, profileLocation.Id);
                throw new CriticalFileReadException(message);
            }

            profileLocations.Add(profileLocation);
        }