Пример #1
0
        private void readDataFeatures(IFMEOReader fmeReader, ref int featureCount)
        {
            // Initialize counters
            int numFeatures = 0;

            // Now, read all the different features
            IFMEOFeature fmeFeature = m_fmeSession.CreateFeature();

            while (fmeReader.Read(fmeFeature))
            {
                // Log the feature to the log file
                m_fmeLogFile.LogFeature(fmeFeature, FMEOMessageLevel.Inform, -1);

                // Increment feature count
                numFeatures++;

                // For every feature, we will put it into m_featureTypeDictionary
                insertIntoFeatureTypeDictionary(fmeFeature);

                // Check if we need to update status bar
                if ((numFeatures % m_kUpdateInterval) == 0)
                {
                    updateStatusBar("Read " + numFeatures.ToString() + " features...");
                }


                // Create a new feature for the next read
                fmeFeature = m_fmeSession.CreateFeature();
            }
            fmeFeature.Dispose();

            featureCount = numFeatures;
        }
Пример #2
0
        private void openOption_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (m_fmeDialog.SourcePrompt("", "", m_dataInfo, m_createDirectives))
                {
                    // Disposes and clears entries inside m_featureTypeDictionary
                    resetAllDictionaries();

                    // Add IFMEOReader code here
                    // Update status bar
                    updateStatusBar("Reading from source...");

                    // If we are here, then the user did not hit Cancel. Now let's
                    // create a reader to read in features. Caching is enabled for
                    // the reader to improve performance on subsequent re-reads.
                    IFMEOReader fmeReader = m_fmeSession.CreateReader(m_dataInfo.Format, false,
                                                                      m_createDirectives);
                    // Open the reader
                    StringCollection openParams = new StringCollection();
                    fmeReader.Open(m_dataInfo.Dataset, openParams);

                    int featureCount = 0;
                    // Now, read in the data features
                    readDataFeatures(fmeReader, ref featureCount);
                    // Update status bar with final feature count
                    updateStatusBar("Total features: " + featureCount.ToString());

                    // Clean up reader
                    fmeReader.Close();
                    fmeReader.Dispose();
                    fmeReader = null;

                    // Refresh the current tab
                    refreshCurrentTab();

                    // Enable the tab panels
                    tabControl1.Enabled = true;
                }
            }
            catch (FMEOException ex)
            {
                // Log errors to log file
                m_fmeLogFile.LogMessageString(ex.FmeErrorMessage, FMEOMessageLevel.Error);
                m_fmeLogFile.LogMessageString(ex.FmeStackTrace, FMEOMessageLevel.Error);
                m_fmeLogFile.LogMessageString(ex.FmeErrorNumber.ToString(),
                                              FMEOMessageLevel.Error);

                // Now exit the application
                Application.Exit();
            }
        }