/// <summary>
 /// Moves branch features from <see cref="sourceBranch"/> to <see cref="targetBranch"/>
 /// </summary>
 /// <param name="targetBranch"></param>
 /// <param name="sourceBranch"></param>
 /// <param name="chainage"></param>
 public static void MergeBranchFeatures(IBranch sourceBranch, IBranch targetBranch, double chainage)
 {
     foreach (var branchFeature in sourceBranch.BranchFeatures.ToArray())
     {
         sourceBranch.BranchFeatures.Remove(branchFeature);
         branchFeature.Chainage = BranchFeature.SnapChainage(targetBranch.Length, branchFeature.Chainage + chainage);
         AddBranchFeatureToBranch(branchFeature, targetBranch, branchFeature.Chainage);
     }
 }
        public static void AddBranchFeatureToBranch(IBranchFeature branchFeature, IBranch branch, double chainage)
        {
            branchFeature.Branch   = branch; // set branch in advance
            branchFeature.Chainage = BranchFeature.SnapChainage(branch.Length, chainage);

            if (!(branchFeature is INetworkLocation))
            {
                branch.BranchFeatures.Add(branchFeature);
            }
        }
        public static double CalculationChainage(IBranch branch, double mapChainage)
        {
            var chainage = mapChainage;

            if (branch.IsLengthCustom)
            {
                chainage = BranchFeature.SnapChainage(branch.Length, chainage * branch.Length / branch.Geometry.Length);
            }
            return(chainage);
        }
Exemple #4
0
        public override object Clone()
        {
            BranchFeature newBranchFeature = (BranchFeature)Activator.CreateInstance(GetType());

            newBranchFeature.offset   = Offset;
            newBranchFeature.Geometry = Geometry == null ? null : ((IGeometry)Geometry.Clone());
            newBranchFeature.Name     = Name;
            newBranchFeature.CopyFrom(this);
            return(newBranchFeature);
        }
 /// <summary>
 /// Calculates the map (geometry) chainage from a user chainage
 /// </summary>
 /// <param name="branch"></param>
 /// <param name="effectiveBranchGeometry">The branch geometry to calculate with. Useful in case the current
 /// Branch.Geometry is about to be updated and not yet changed</param>
 /// <param name="chainage"></param>
 /// <returns></returns>
 public static double MapChainage(IBranch branch, IGeometry effectiveBranchGeometry, double chainage)
 {
     if (branch != null && branch.IsLengthCustom)
     {
         if (effectiveBranchGeometry != null)
         {
             return(BranchFeature.SnapChainage(effectiveBranchGeometry.Length, (effectiveBranchGeometry.Length / branch.Length) * chainage));
         }
     }
     return(chainage);
 }
Exemple #6
0
        public override object Clone()
        {
            BranchFeature newBranchFeature = (BranchFeature)Activator.CreateInstance(GetType());

            newBranchFeature.length   = Length;
            newBranchFeature.offset   = Offset;
            newBranchFeature.Geometry = Geometry == null ? null : ((IGeometry)Geometry.Clone());
            newBranchFeature.Name     = Name;
            //do it here?
            //newBranchFeature.attributes = (IFeatureAttributeCollection) Attributes.Clone();
            return(newBranchFeature);
        }
Exemple #7
0
        public override object Clone()
        {
            var newBranch = (Branch)Activator.CreateInstance(GetType());

            newBranch.Name           = Name;
            newBranch.Geometry       = Geometry == null ? null : (IGeometry)Geometry.Clone();
            newBranch.length         = Length;
            newBranch.isLengthCustom = IsLengthCustom;

            foreach (var branchFeature in BranchFeatures)
            {
                BranchFeature clonedBranchFeature = (BranchFeature)branchFeature.Clone();
                clonedBranchFeature.Branch = newBranch;
                newBranch.BranchFeatures.Add(clonedBranchFeature);
            }
            return(newBranch);
        }
 private void UpdateBranchFeatureChainages(double factor, double newLength)
 {
     branchFeatures.ForEach(bf => bf.Chainage = BranchFeature.SnapChainage(newLength, factor * bf.Chainage));
 }