/// <summary> /// Logic that checks if a line drawn by user (representing a route segment) is ok to be futher processed /// </summary> /// <returns></returns> private bool LineIsValidRouteSegment(LineString line, double tolerance = 0.01) { // We don't want lines that has invalid geometry if (!line.IsValid) { return(false); } // We don't want lines that are not simple - i.e. self intersecting if (!line.IsSimple) { return(false); } // We don't want lines that are closes - i.e. where the ends of the line is snapped together if (line.IsClosed) { return(false); } // We don't want ends closer to each other than tolerance if (line.StartPoint.Distance(line.EndPoint) < tolerance) { return(false); } // We don't want ends closer to the edge than tolerance if (!GeometrySnapper.SnapToSelf(line, tolerance, false).Equals(line)) { return(false); } return(true); }
public bool LineIsValid(LineString lineString) { if (!lineString.IsValid) { LogValidationError("IsValid", lineString); return(false); } // We don't want lines that are not simple - i.e. self intersecting if (!lineString.IsSimple) { LogValidationError("IsSimple", lineString); return(false); } // We don't want lines that are closes - i.e. where the ends of the line is snapped together if (lineString.IsClosed) { LogValidationError("IsClosed", lineString); return(false); } // We don't want ends closer to each other than tolerance if (lineString.StartPoint.Distance(lineString.EndPoint) < _applicationSettings.Tolerance) { LogValidationError("EndsCloserToEachOtherThanTolereance", lineString); return(false); } // We don't want ends closer to the edge than tolerance if (!GeometrySnapper.SnapToSelf(lineString, _applicationSettings.Tolerance, false).Equals(lineString)) { LogValidationError("EndsCloserToTheEdgeThanTolereance", lineString); return(false); } return(true); }