<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def simplify( self, tolerance: float, altitude: Optional[str] = None, z_factor: float = 3.048, return_type: Type[Mask] = Type["Flight"], ) -> Mask: """Simplifies a trajectory with Douglas-Peucker algorithm. The method uses latitude and longitude, projects the trajectory to a conformal projection and applies the algorithm. By default, a 2D version is called, unless you pass a column name for altitude (z parameter). You may scale the z-axis for more relevance (z_factor); the default value works well in most situations. The method returns a Flight unless you specify a np.ndarray[bool] as return_type for getting a mask. """

        # returns a mask
        mask = douglas_peucker(
            df=self.data,
            tolerance=tolerance,
            lat="latitude",
            lon="longitude",
            z=altitude,
            z_factor=z_factor,
        )
        if return_type == Type["Flight"]:
            return self.__class__(self.data.loc[mask])
        else:
            return mask