public virtual RoadNetwork CreateNetwork(FeatureSource featureSource)
        {
            featureSource.Open();
            QTreeSpatialIndex qtree = new QTreeSpatialIndex(featureSource.GetBoundingBox());

            #if DEBUG
            long featureCount = featureSource.GetCount();
            #endif

            RoadNetwork roadNetwork = new RoadNetwork();
            Collection<Feature> features = featureSource.GetAllFeatures(ReturningColumnsType.NoColumns);
            featureSource.Close();
            Collection<Collection<Feature>> featureGroups = GroupFeatures(features);
            int done = 0;
            var tasks = (from items in featureGroups
                         select Task.Factory.StartNew(() =>
                         {
                             var clonedFeatureSource = featureSource.CloneDeep();
                             clonedFeatureSource.Open();
                             foreach (var feature in items)
                             {
                                 Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
                                 // Get the lineshape of the processing feature.
                                 foreach (LineShape processingLineShape in processingLineShapes)
                                 {
                                     BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[0]);
                                     BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]);
                                 }
                                 done++;
                                 Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, done));
                             }

                         })).ToArray();
            //foreach (Feature feature in features)
            //{
            //    Task.Factory.StartNew(() =>
            //    {
            //        Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
            //        // Get the lineshape of the processing feature.
            //        foreach (LineShape processingLineShape in processingLineShapes)
            //        {
            //            BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[0]);
            //            BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]);
            //        }
            //    }
            //   );
            Task.WaitAll(tasks);

            #if DEBUG

            #endif

            //}
            //featureSource.Close();

            return roadNetwork;
        }
        private void Split()
        {
            var args = new UpdatingTaskProgressEventArgs(TaskState.Updating);

            featureSource.Open();
            Collection <Feature> allFeatures = featureSource.GetAllFeatures(featureSource.GetDistinctColumnNames());
            var columns = featureSource.GetColumns();

            featureSource.Close();

            var featuresGroups = allFeatures.GroupBy(tmpFeature
                                                     => tmpFeature.ColumnValues[splitColumnName]).ToArray();

            int i     = 0;
            int count = exportConfigs.Count;

            foreach (var config in exportConfigs)
            {
                try
                {
                    string folderName = outputPath;
                    string fileName   = config.Value;
                    if (String.IsNullOrEmpty(fileName))
                    {
                        fileName = String.Format(CultureInfo.InvariantCulture, "{0}_{1}.shp", layerName, config.Key);
                    }

                    fileName = Path.ChangeExtension(fileName, ".shp");
                    string finalShapeFilePath = Path.Combine(folderName, fileName);
                    var    featureGroup       = featuresGroups.FirstOrDefault(group => group.Key == config.Key || (config.Key.Equals("<Blank>", StringComparison.Ordinal) && group.Key.Equals(string.Empty, StringComparison.Ordinal)));
                    if (featureGroup != null)
                    {
                        var info = new FileExportInfo(featureGroup, columns, finalShapeFilePath, wkt);
                        Export(info);
                    }

                    args.Current    = ++i;
                    args.UpperBound = count;
                    args.Message    = String.Format(CultureInfo.InvariantCulture, "Building... ({0}/{1})", args.Current, args.UpperBound);
                    OnUpdatingProgress(args);
                    isCanceled = args.TaskState == TaskState.Canceled;

                    if (isCanceled)
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    var errorArgs = new UpdatingTaskProgressEventArgs(TaskState.Error);
                    errorArgs.Error = new ExceptionInfo(ex.Message, ex.StackTrace, ex.Source);
                    GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                    OnUpdatingProgress(errorArgs);
                    continue;
                }
            }
        }
        private Collection <Feature> GetFeaturesToExplode(FeatureSource featureSource)
        {
            featureSource.Open();
            var allFeatures = featureSource.GetAllFeatures(featureSource.GetDistinctColumnNames());

            columns = featureSource.GetColumns();
            featureSource.Close();

            return(allFeatures);
        }
        private Collection <Feature> GetFeaturesToDissolve()
        {
            featureSource.Open();
            featureColumns = featureSource.GetColumns();
            var allFeatures = featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

            featureSource.Close();

            return(allFeatures);
        }
Beispiel #5
0
        public virtual RoadNetwork CreateNetwork(FeatureSource featureSource)
        {
            featureSource.Open();
            QTreeSpatialIndex qtree = new QTreeSpatialIndex(featureSource.GetBoundingBox());

#if DEBUG
            long featureCount = featureSource.GetCount();
#endif

            RoadNetwork          roadNetwork = new RoadNetwork();
            Collection <Feature> features    = featureSource.GetAllFeatures(ReturningColumnsType.NoColumns);
            featureSource.Close();
            Collection <Collection <Feature> > featureGroups = GroupFeatures(features);
            int done  = 0;
            var tasks = (from items in featureGroups
                         select Task.Factory.StartNew(() =>
            {
                var clonedFeatureSource = featureSource.CloneDeep();
                clonedFeatureSource.Open();
                foreach (var feature in items)
                {
                    Collection <LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
                    // Get the lineshape of the processing feature.
                    foreach (LineShape processingLineShape in processingLineShapes)
                    {
                        BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[0]);
                        BuildNetworkNode(clonedFeatureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]);
                    }
                    done++;
                    Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, done));
                }
            })).ToArray();
            //foreach (Feature feature in features)
            //{
            //    Task.Factory.StartNew(() =>
            //    {
            //        Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
            //        // Get the lineshape of the processing feature.
            //        foreach (LineShape processingLineShape in processingLineShapes)
            //        {
            //            BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[0]);
            //            BuildNetworkNode(featureSource, qtree, roadNetwork, processingLineShape.Vertices[processingLineShape.Vertices.Count - 1]);
            //        }
            //    }
            //   );
            Task.WaitAll(tasks);

#if DEBUG
#endif

            //}
            //featureSource.Close();

            return(roadNetwork);
        }
Beispiel #6
0
 private Dictionary <PointShape, double> GetDataPoints()
 {
     return((from feature in FeatureSource.GetAllFeatures(GetReturningColumns())
             where double.Parse(feature.ColumnValues["MAGNITUDE"]) > 0
             select new PointShape
     {
         X = double.Parse(feature.ColumnValues["LONGITUDE"], CultureInfo.InvariantCulture),
         Y = double.Parse(feature.ColumnValues["LATITIUDE"], CultureInfo.InvariantCulture),
         Z = double.Parse(feature.ColumnValues["MAGNITUDE"], CultureInfo.InvariantCulture)
     }).ToDictionary(point => point, point => point.Z));
 }
 private Dictionary <PointShape, double> GetDataPoints()
 {
     return((from feature in FeatureSource.GetAllFeatures(GetReturningColumns())
             where double.Parse(feature.ColumnValues[Resources.MagnitudeColumnName]) > 0
             select new PointShape
     {
         X = double.Parse(feature.ColumnValues[Resources.LongitudeColumnName], CultureInfo.InvariantCulture),
         Y = double.Parse(feature.ColumnValues[Resources.LatitudeColumnName], CultureInfo.InvariantCulture),
         Z = double.Parse(feature.ColumnValues[Resources.MagnitudeColumnName], CultureInfo.InvariantCulture)
     }).ToDictionary(point => point, point => point.Z));
 }
        private Collection <Feature> GetFeaturesToBuffer(string featureSourceInString)
        {
            FeatureSource featureSource = (FeatureSource)GetObjectFromString(featureSourceInString);

            featureSource.Open();
            var allFeatures = featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);

            columns = featureSource.GetColumns();
            featureSource.Close();

            return(allFeatures);
        }
        private IEnumerable <Feature> GetFeaturesFromTempFile()
        {
            featureSource.Open();
            var allFeatures = featureSource.GetAllFeatures(featureSource.GetDistinctColumnNames());

            featureSource.Close();

            return(allFeatures.Where(f =>
            {
                var shape = f.GetShape();
                return shape is AreaBaseShape || shape is LineBaseShape;
            }));
        }
Beispiel #10
0
        private static Dictionary <PointShape, double> GetDataPoints(FeatureSource featureSource)
        {
            featureSource.Open();
            Dictionary <PointShape, double> features = (from feature in featureSource.GetAllFeatures(new string[] { "LONGITUDE", "LATITIUDE", "MAGNITUDE" })
                                                        where double.Parse(feature.ColumnValues["MAGNITUDE"]) > 0
                                                        select new PointShape
            {
                X = double.Parse(feature.ColumnValues["LONGITUDE"], CultureInfo.InvariantCulture),
                Y = double.Parse(feature.ColumnValues["LATITIUDE"], CultureInfo.InvariantCulture),
                Z = double.Parse(feature.ColumnValues["MAGNITUDE"], CultureInfo.InvariantCulture)
            }).ToDictionary(point => point, point => point.Z);

            return(features);
        }
        private void Initialize()
        {
            Dictionary <PointShape, double> dataPoints = new Dictionary <PointShape, double>();

            if (!FeatureSource.IsOpen)
            {
                FeatureSource.Open();
            }

            Collection <Feature> allFeatures = FeatureSource.GetAllFeatures(new Collection <string>()
            {
                Resources.LongitudeColumnName, Resources.LatitudeColumnName, Resources.MagnitudeColumnName
            });
            var featureColumnQuery = allFeatures.Where(n => double.Parse(n.ColumnValues[Resources.MagnitudeColumnName]) > 0).Select(n => new
            {
                Longitude = double.Parse(n.ColumnValues[Resources.LongitudeColumnName]),
                Latitude  = double.Parse(n.ColumnValues[Resources.LatitudeColumnName]),
                Magnitude = double.Parse(n.ColumnValues[Resources.MagnitudeColumnName])
            });

            foreach (var column in featureColumnQuery)
            {
                dataPoints.Add(new PointShape(column.Longitude, column.Latitude), column.Magnitude);
            }

            double[]            dataCollection = dataPoints.Select(n => n.Value).ToArray();
            Collection <double> isoLineLevels  = new Collection <double>(GetClassBreakValues(dataCollection, 12).ToList());

            isoLineLayer = new DynamicIsoLineLayer(dataPoints, isoLineLevels, new InverseDistanceWeightedGridInterpolationModel(3, double.MaxValue), IsoLineType.ClosedLinesAsPolygons);

            isoLineLayer.CustomStyles.Add(LevelClassBreakStyle);

            //Create the text styles to label the lines
            TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);

            textStyle.HaloPen               = new GeoPen(GeoColor.StandardColors.White, 2);
            textStyle.OverlappingRule       = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType            = SplineType.StandardSplining;
            textStyle.DuplicateRule         = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio  = 9999999;
            textStyle.FittingLineInScreen   = true;
            textStyle.SuppressPartialLabels = true;
            textStyle.NumericFormat         = "{0:0.00}";
            isoLineLayer.CustomStyles.Add(textStyle);
        }
Beispiel #12
0
        public virtual void ImportData(FeatureSource featureSourceForRead, FeatureSource featureSourceForSave)
        {
            bool readCompleted = false;

            featureSourceForRead.Open();
            featureSourceForSave.Open();
#if DEBUG
            long featureCount = featureSourceForRead.GetCount();
#endif
            Collection <Feature> features = featureSourceForRead.GetAllFeatures(ReturningColumnsType.AllColumns);
            Collection <Collection <Feature> > featureGroups = GroupFeatures(features);
            var writeTasks = (from items in featureGroups
                              select Task.Factory.StartNew(() => WriteFeaturesIntoQueue(items, featureSourceForRead))).ToArray();


            var readTask = Task.Factory.StartNew(() =>
            {
                while (!readCompleted || queue.Count > 0)
                {
                    while (queue.Count > 0)
                    {
                        Collection <Feature> lineFeatures = queue.Dequeue();
                        SaveFeatures(lineFeatures, featureSourceForSave);
                    }
                }
            });

            Task.WaitAll(writeTasks);
            readCompleted = true;
            Task.WaitAny(readTask);
            #region Old version
            //foreach (Feature feature in features)
            //{
            //    Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
            //    // Get the lineshape of the processing feature.
            //    foreach (LineShape processingLineShape in processingLineShapes)
            //    {
            //        // Define a variable to save the points where the adjacent lines intersect with current processing line.
            //        Collection<PointShape> crossingPoints = new Collection<PointShape>();

            //        // Get all the lines in current processing shape bounds.
            //        Collection<Feature> adjacentFeatures = featureSourceForRead.GetFeaturesInsideBoundingBox(processingLineShape.GetBoundingBox(), ReturningColumnsType.NoColumns);

            //        // Loop and see if the queried shape is intersected with processing shape.
            //        foreach (Feature adjacentFeature in adjacentFeatures)
            //        {
            //            LineBaseShape adjacentLineShape = adjacentFeature.GetShape() as LineBaseShape;
            //            MultipointShape tempCrossingPoints = processingLineShape.GetCrossing(adjacentLineShape);

            //            // The queried shape is intersected with processing shape.
            //            foreach (PointShape point in tempCrossingPoints.Points)
            //            {
            //                bool hasAdded = false;
            //                foreach (var item in crossingPoints)
            //                {
            //                    if (point.X == item.X && point.Y == item.Y)
            //                    {
            //                        hasAdded = true;
            //                        break;
            //                    }
            //                }
            //                if (!hasAdded)
            //                {
            //                    crossingPoints.Add(point);
            //                }
            //            }
            //        }

            //        // Order the crossing points following the sequence of line vertex.
            //        Collection<FlagedVertex> vertecesOfNewLine = GeometryHelper.AddCrossingPointToLine(processingLineShape, crossingPoints);

            //        // Split current processing lineshape into segments.
            //        featureSourceForSave.BeginTransaction();
            //        Collection<Vertex> verteces = new Collection<Vertex>();
            //        foreach (var vertex in vertecesOfNewLine)
            //        {
            //            verteces.Add(vertex.Vertex);
            //            if (vertex.Flag)
            //            {
            //                if (verteces.Count >= 2)
            //                {
            //                    LineShape segment = new LineShape(verteces);
            //                    featureSourceForSave.AddFeature(new Feature(segment, feature.ColumnValues));

            //                    verteces.RemoveAt(0);
            //                }
            //            }
            //        }
            //        featureSourceForSave.CommitTransaction();
            //    }

            //#if DEBUG
            //Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, featureCount));
            //#endif
            //}

            #endregion
            featureSourceForRead.Close();
            featureSourceForSave.Close();
        }
Beispiel #13
0
        public virtual void ImportData(FeatureSource featureSourceForRead, FeatureSource featureSourceForSave)
        {
            bool readCompleted = false;
            featureSourceForRead.Open();
            featureSourceForSave.Open();
            #if DEBUG
            long featureCount = featureSourceForRead.GetCount();
            #endif
            Collection<Feature> features = featureSourceForRead.GetAllFeatures(ReturningColumnsType.AllColumns);
            Collection<Collection<Feature>> featureGroups = GroupFeatures(features);
            var writeTasks = (from items in featureGroups
                              select Task.Factory.StartNew(() => WriteFeaturesIntoQueue(items, featureSourceForRead))).ToArray();

            var readTask = Task.Factory.StartNew(() =>
            {
                while (!readCompleted || queue.Count > 0)
                {
                    while (queue.Count > 0)
                    {
                        Collection<Feature> lineFeatures = queue.Dequeue();
                        SaveFeatures(lineFeatures, featureSourceForSave);
                    }
                }
            });

            Task.WaitAll(writeTasks);
            readCompleted = true;
            Task.WaitAny(readTask);
            #region Old version
            //foreach (Feature feature in features)
            //{
            //    Collection<LineShape> processingLineShapes = GeometryHelper.GetLineShapes(feature);
            //    // Get the lineshape of the processing feature.
            //    foreach (LineShape processingLineShape in processingLineShapes)
            //    {
            //        // Define a variable to save the points where the adjacent lines intersect with current processing line.
            //        Collection<PointShape> crossingPoints = new Collection<PointShape>();

            //        // Get all the lines in current processing shape bounds.
            //        Collection<Feature> adjacentFeatures = featureSourceForRead.GetFeaturesInsideBoundingBox(processingLineShape.GetBoundingBox(), ReturningColumnsType.NoColumns);

            //        // Loop and see if the queried shape is intersected with processing shape.
            //        foreach (Feature adjacentFeature in adjacentFeatures)
            //        {
            //            LineBaseShape adjacentLineShape = adjacentFeature.GetShape() as LineBaseShape;
            //            MultipointShape tempCrossingPoints = processingLineShape.GetCrossing(adjacentLineShape);

            //            // The queried shape is intersected with processing shape.
            //            foreach (PointShape point in tempCrossingPoints.Points)
            //            {
            //                bool hasAdded = false;
            //                foreach (var item in crossingPoints)
            //                {
            //                    if (point.X == item.X && point.Y == item.Y)
            //                    {
            //                        hasAdded = true;
            //                        break;
            //                    }
            //                }
            //                if (!hasAdded)
            //                {
            //                    crossingPoints.Add(point);
            //                }
            //            }
            //        }

            //        // Order the crossing points following the sequence of line vertex.
            //        Collection<FlagedVertex> vertecesOfNewLine = GeometryHelper.AddCrossingPointToLine(processingLineShape, crossingPoints);

            //        // Split current processing lineshape into segments.
            //        featureSourceForSave.BeginTransaction();
            //        Collection<Vertex> verteces = new Collection<Vertex>();
            //        foreach (var vertex in vertecesOfNewLine)
            //        {
            //            verteces.Add(vertex.Vertex);
            //            if (vertex.Flag)
            //            {
            //                if (verteces.Count >= 2)
            //                {
            //                    LineShape segment = new LineShape(verteces);
            //                    featureSourceForSave.AddFeature(new Feature(segment, feature.ColumnValues));

            //                    verteces.RemoveAt(0);
            //                }
            //            }
            //        }
            //        featureSourceForSave.CommitTransaction();
            //    }

            //#if DEBUG
            //Console.WriteLine(string.Format("Done {0} in {1}", feature.Id, featureCount));
            //#endif
            //}

            #endregion
            featureSourceForRead.Close();
            featureSourceForSave.Close();
        }
        private void Split()
        {
            try
            {
                var args = new UpdatingProgressLongRunningTaskPluginEventArgs(LongRunningTaskState.Updating);

                featureSource.Open();
                Collection <Feature> allFeatures = featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
                var columns = featureSource.GetColumns();
                featureSource.Close();

                var featuresGroups = allFeatures.GroupBy(tmpFeature
                                                         => tmpFeature.ColumnValues[splitColumnName]);

                int i     = 0;
                int count = exportConfigs.Count;
                exportConfigs.ForEach(config =>
                {
                    string folderName = outputPath;
                    string fileName   = config.Value;
                    if (String.IsNullOrEmpty(fileName))
                    {
                        fileName = String.Format(CultureInfo.InvariantCulture, "{0}_{1}.shp", layerName, config.Key);
                    }

                    if (!fileName.EndsWith(".shp", StringComparison.OrdinalIgnoreCase))
                    {
                        fileName += ".shp";
                    }

                    string finalShapeFilePath = Path.Combine(folderName, fileName);

                    if (File.Exists(finalShapeFilePath) && overwriteOutputFiles)
                    {
                        //CloseExistingLayersAndCollectOverlaysToRefresh(this, finalShapeFilePath);
                        RemoveShapeFile(finalShapeFilePath);
                    }

                    //this.OutputShapeFileNames.Add(finalShapeFilePath);
                    var featureGroup = featuresGroups.FirstOrDefault(group => group.Key == config.Key);
                    if (featureGroup != null)
                    {
                        ShpFileExporter exporter = new ShpFileExporter();
                        exporter.ExportToFile(new FileExportInfo(featureGroup, columns, finalShapeFilePath, wkt));
                    }

                    args.Message = String.Format(CultureInfo.InvariantCulture, "Building... ({0}/{1})", ++i, count);
                    OnUpdatingProgress(args);
                });
            }
            catch (Exception ex)
            {
                //HandleExceptionFromInvalidFeature(feature.Id, ex.Message);
            }
            finally
            {
                //this.IsBusy = false;
                //this.BusyContent = String.Empty;
                //this.CurrentThread = null;
            }
        }
        private IEnumerable <Feature> InverseClip(FeatureSource featureSource, IEnumerable <Feature> clippingFeatures)
        {
            lock (featureSource)
            {
                if (!featureSource.IsOpen)
                {
                    featureSource.Open();
                }
                Collection <Feature> results        = featureSource.GetFeaturesOutsideBoundingBox(ExtentHelper.GetBoundingBoxOfItems(clippingFeatures), ReturningColumnsType.AllColumns);
                Collection <Feature> sourceFeatures = new Collection <Feature>();
                ShapeFileType        shapeFileType  = ((ShapeFileFeatureSource)featureSource).GetShapeFileType();
                int index = 1;
                if (shapeFileType == ShapeFileType.Point || shapeFileType == ShapeFileType.Multipoint)
                {
                    featureSource.Open();
                    Collection <Feature> allFeatures = featureSource.GetAllFeatures(ReturningColumnsType.AllColumns);
                    featureSource.Close();
                    foreach (Feature f in results)
                    {
                        allFeatures.Remove(f);
                    }
                    foreach (var f in InverseClipPoints(allFeatures, clippingFeatures, shapeFileType))
                    {
                        results.Add(f);
                    }
                }
                else if (shapeFileType == ShapeFileType.Polyline)
                {
                    bool              isOpen        = false;
                    Projection        tmpProjection = null;
                    MultipolygonShape areaBaseShape = AreaBaseShape.Union(GetValidFeatures(clippingFeatures));
                    if (featureSource.Projection != null &&
                        featureSource.Projection is GISEditorManagedProj4Projection &&
                        ((GISEditorManagedProj4Projection)featureSource.Projection).IsProjectionParametersEqual)
                    {
                        tmpProjection = featureSource.Projection;
                        if (featureSource.IsOpen)
                        {
                            featureSource.Close();
                            featureSource.Projection.Close();
                            isOpen = true;
                        }
                        featureSource.Projection = null;
                    }
                    featureSource.Open();
                    featureSource.GetFeaturesInsideBoundingBox(areaBaseShape.GetBoundingBox(), ReturningColumnsType.AllColumns).ForEach(f => { if (!areaBaseShape.Contains(f))
                                                                                                                                               {
                                                                                                                                                   sourceFeatures.Add(f);
                                                                                                                                               }
                                                                                                                                        });
                    int count = sourceFeatures.Count;
                    if (tmpProjection != null)
                    {
                        featureSource.Projection = tmpProjection;
                        if (isOpen)
                        {
                            featureSource.Open();
                        }
                    }
                    if (featureSource.IsOpen)
                    {
                        featureSource.Close();
                    }
                    foreach (var feature in sourceFeatures)
                    {
                        ReportProgress(index * 100 / count);
                        index++;
                        try
                        {
                            if (areaBaseShape.IsDisjointed(feature))
                            {
                                results.Add(feature);
                            }
                            else
                            {
                                MultilineShape multiLine   = (MultilineShape)feature.GetShape();
                                MultilineShape resultShape = new MultilineShape();
                                foreach (LineShape lineShape in multiLine.Lines)
                                {
                                    if (areaBaseShape.IsDisjointed(lineShape))
                                    {
                                        resultShape.Lines.Add(lineShape);
                                    }
                                    else
                                    {
                                        Collection <PointShape> points = new Collection <PointShape>();
                                        points.Add(new PointShape(lineShape.Vertices[0]));
                                        lineShape.GetIntersection(areaBaseShape).Lines.ForEach(l =>
                                        {
                                            PointShape p1 = new PointShape(l.Vertices[0]);
                                            if (points.Count(p => p.X == p1.X && p.Y == p1.Y && p.Z == p1.Z) <= 0)
                                            {
                                                points.Add(p1);
                                            }
                                            PointShape p2 = new PointShape(l.Vertices[l.Vertices.Count - 1]);
                                            if (points.Count(p => p.X == p2.X && p.Y == p2.Y && p.Z == p2.Z) <= 0)
                                            {
                                                points.Add(p2);
                                            }
                                        });
                                        PointShape endPoint = new PointShape(lineShape.Vertices[lineShape.Vertices.Count - 1]);
                                        if (points.Count(p => p.X == endPoint.X && p.Y == endPoint.Y && p.Z == endPoint.Z) <= 0)
                                        {
                                            points.Add(endPoint);
                                        }

                                        for (int i = 0; i < points.Count; i++)
                                        {
                                            if (i != points.Count - 1)
                                            {
                                                LineBaseShape lineBaseShape = lineShape.GetLineOnALine(points[i], points[i + 1]);

                                                if (!areaBaseShape.Intersects(lineBaseShape.GetCenterPoint()))
                                                {
                                                    resultShape.Lines.Add((LineShape)lineBaseShape);
                                                }
                                            }
                                        }
                                    }
                                }
                                if (resultShape != null && resultShape.Lines.Count > 0)
                                {
                                    results.Add(new Feature(resultShape.GetWellKnownBinary(), feature.Id, feature.ColumnValues));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            HandleExceptionFromInvalidFeature(feature.Id, ex.Message);
                        }
                    }
                }
                else if (shapeFileType == ShapeFileType.Polygon)
                {
                    MultipolygonShape areaBaseShape = AreaBaseShape.Union(GetValidFeatures(clippingFeatures));

                    bool       isOpen        = false;
                    Projection tmpProjection = null;
                    if (featureSource.Projection != null &&
                        featureSource.Projection is GISEditorManagedProj4Projection &&
                        ((GISEditorManagedProj4Projection)featureSource.Projection).IsProjectionParametersEqual)
                    {
                        tmpProjection = featureSource.Projection;
                        if (featureSource.IsOpen)
                        {
                            featureSource.Close();
                            featureSource.Projection.Close();
                            isOpen = true;
                        }
                        featureSource.Projection = null;
                    }
                    if (!featureSource.IsOpen)
                    {
                        featureSource.Open();
                    }
                    featureSource.GetFeaturesInsideBoundingBox(areaBaseShape.GetBoundingBox(), ReturningColumnsType.AllColumns).ForEach(f => { if (!areaBaseShape.IsDisjointed(f))
                                                                                                                                               {
                                                                                                                                                   sourceFeatures.Add(f);
                                                                                                                                               }
                                                                                                                                        });
                    if (featureSource.IsOpen)
                    {
                        featureSource.Close();
                    }
                    if (tmpProjection != null)
                    {
                        featureSource.Projection = tmpProjection;
                        if (isOpen)
                        {
                            featureSource.Open();
                        }
                    }

                    int count = sourceFeatures.Count;
                    foreach (var feature in sourceFeatures)
                    {
                        ReportProgress(index * 100 / count);
                        index++;
                        try
                        {
                            if (areaBaseShape.IsDisjointed(feature))
                            {
                                results.Add(feature);
                            }
                            else
                            {
                                var clippedShape = ((AreaBaseShape)feature.GetShape()).GetDifference(areaBaseShape);
                                if (clippedShape != null && clippedShape.Polygons.Count > 0)
                                {
                                    results.Add(new Feature(clippedShape.GetWellKnownBinary(), feature.Id, feature.ColumnValues));
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            HandleExceptionFromInvalidFeature(feature.Id, ex.Message);
                        }
                    }
                }
                else
                {
                    throw new NotSupportedException("The ShapeFileType is not supported.");
                }
                return(results);
            }
        }