public void Stop(SnapResult snapResult, bool stayOnSameBranch) { if (!(SourceFeature is IBranchFeature)) { return; } if (null != snapResult && null == snapResult.SnappedFeature as IBranch) { return; } var branchFeature = (IBranchFeature)SourceFeature; if (moving) { branchFeature.SetBeingMoved(true); } var tolerance = Layer == null ? Tolerance : MapHelper.ImageToWorld(Layer.Map, 1); var branch = branchFeature.Branch; INetwork network = Network ?? branch.Network; // network must be known if (!stayOnSameBranch && branch != null) { branch.BranchFeatures.Remove(branchFeature); branchFeature.Branch = null; } base.Stop(); // set new geometry if (!stayOnSameBranch) { NetworkHelper.AddBranchFeatureToNearestBranch(network.Branches, branchFeature, tolerance); } if (moving) { branchFeature.SetBeingMoved(false); moving = false; } // todo move update distance to AddBranchFeatureToNearestBranch? double distance = GeometryHelper.Distance((ILineString)branchFeature.Branch.Geometry, branchFeature.Geometry.Coordinates[0]); if (branchFeature.Branch.IsLengthCustom) { distance *= branchFeature.Branch.Length / branchFeature.Branch.Geometry.Length; } branchFeature.Chainage = BranchFeature.SnapChainage(branchFeature.Branch.Length, distance); if (branchFeature.Geometry.GetType() == typeof(LineString)) { UpdateLineGeometry(branchFeature); } }