protected void OnBuildingIndex(BuildingIndexCsvFeatureSourceEventArgs e)
        {
            EventHandler <BuildingIndexCsvFeatureSourceEventArgs> handler = BuildingIndex;

            if (handler != null)
            {
                handler(null, e);
            }
        }
        protected virtual void BuildIndexFileCore(bool rebuild)
        {
            string idxPathFileName = Path.ChangeExtension(CsvPathFileName, ".idx");
            string idsPathFileName = Path.ChangeExtension(CsvPathFileName, ".ids");

            if (!File.Exists(idxPathFileName) && !File.Exists(idsPathFileName) || rebuild)
            {
                if (!string.IsNullOrEmpty(WktColumnName))
                {
                    RtreeSpatialIndex.CreateRectangleSpatialIndex(idxPathFileName, RtreeSpatialIndexPageSize.EightKilobytes, RtreeSpatialIndexDataFormat.Float);
                }
                else
                {
                    RtreeSpatialIndex.CreatePointSpatialIndex(idxPathFileName, RtreeSpatialIndexPageSize.EightKilobytes, RtreeSpatialIndexDataFormat.Float);
                }

                using (RtreeSpatialIndex tempRTree = new RtreeSpatialIndex(idxPathFileName, GeoFileReadWriteMode.ReadWrite))
                {
                    tempRTree.Open();
                    bool     isCanceled = false;
                    DateTime startDate  = DateTime.Now;
                    using (var csvReader = CreateCsvReader())
                    {
                        var allRecords = csvReader.DataRecords.ToArray();
                        int index      = 0;
                        foreach (var currentDataRecord in allRecords)
                        {
                            index++;
                            var feature = GetFeature(index.ToString(), currentDataRecord);
                            if (feature != null)
                            {
                                tempRTree.Add(feature);
                                BuildingIndexCsvFeatureSourceEventArgs e = new BuildingIndexCsvFeatureSourceEventArgs(allRecords.Length, index, feature, startDate, false);
                                OnBuildingIndex(e);
                                if (e.Cancel)
                                {
                                    isCanceled = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!isCanceled)
                    {
                        tempRTree.Flush();
                    }
                    else
                    {
                        if (File.Exists(idxPathFileName))
                        {
                            File.Delete(idxPathFileName);
                        }
                        if (File.Exists(idsPathFileName))
                        {
                            File.Delete(idsPathFileName);
                        }
                    }
                }
            }
        }