Пример #1
0
        /// <summary>
        /// Populates our 'year', 'state', 'summary level', and 'srid' controls,
        /// as well as any other "choose from a set" controls that come up.
        /// </summary>
        protected void PopulateLists()
        {
            this.cboYear.DataSource         = new BindingSource(FormController.Instance.AvailableYears, string.Empty);
            this.cboStates.DataSource       = new BindingSource(FormController.Instance.AvailableStates, string.Empty);
            this.cboSummaryLevel.DataSource = new BindingSource(FormController.Instance.AvailableLevels, string.Empty);


            this.cboStates.FormattingEnabled = true;
            this.cboStates.Format           += delegate(object sender, ListControlConvertEventArgs e)
            {
                AcsState state = (AcsState)e.Value;
                if (state == AcsState.None)
                {
                    e.Value = string.Empty;
                }
                else
                {
                    e.Value = state.ToString();
                }
            };

            this.cboSummaryLevel.FormattingEnabled = true;
            this.cboSummaryLevel.Format           += delegate(object sender, ListControlConvertEventArgs e)
            {
                BoundaryLevels level = (BoundaryLevels)e.Value;
                switch (level)
                {
                case BoundaryLevels.None:
                    e.Value = string.Empty;
                    break;

                //case BoundaryLevels.counties:
                //    e.Value = "Counties";
                //    break;
                //case BoundaryLevels.county_subdivisions:
                //    e.Value = "County Subdivisions";
                //    break;
                case BoundaryLevels.census_tracts:
                    e.Value = "Census Tracts";
                    break;

                case BoundaryLevels.census_blockgroups:
                    e.Value = "Census Blockgroups";
                    break;
                }
            };

            //NOTE! We're doing this initialization in "radioSRIDFromList_CheckedChanged",
            //instead of here, this is because it's expensive (we have to read through a whole file)
            //so we're shaving a half-second off the init, and moving it to a spot where the user shouldn't notice.
            //this.cboProjections.DataSource = new BindingSource(FormController.Instance.AvailableProjections, string.Empty);
        }
Пример #2
0
        /// <summary>
        /// Helper function for constructing the correct census URL for a particular Boundary Level / State
        /// </summary>
        /// <param name="level"></param>
        /// <param name="stateFips"></param>
        /// <returns></returns>
        public static string GetRemoteShapefileURL(BoundaryLevels level, string stateFips)
        {
            string url = string.Empty;

            switch (level)
            {
            case BoundaryLevels.census_blockgroups:
                url = Settings.ShapeFileBlockGroupURL + Settings.ShapeFileBlockGroupFilename;
                break;

            case BoundaryLevels.census_tracts:
                url = Settings.ShapeFileTractURL + Settings.ShapeFileTractFilename;
                break;

            /*
             * case BoundaryLevels.county_subdivisions:
             *  url = Settings.ShapeFileCountySubdivisionsURL + Settings.ShapeFileCountySubdivisionsFilename;
             *  break;
             * case BoundaryLevels.counties:
             *  url = Settings.ShapeFileCountiesURL + Settings.ShapeFileCountiesFilename;
             *  break;
             *
             * case BoundaryLevels.voting:
             *  url = Settings.ShapeFileVotingURL + Settings.ShapeFileVotingFilename;
             *  break;
             * case BoundaryLevels.zipthree:
             *  url = Settings.ShapeFileThreeDigitZipsURL + Settings.ShapeFileThreeDigitZipsFilename;
             *  break;
             * case BoundaryLevels.zipfive:
             *  url = Settings.ShapeFileFiveDigitZipsURL + Settings.ShapeFileFiveDigitZipsFilename;
             *  break;
             *
             *
             * case BoundaryLevels.states:
             * case BoundaryLevels.census_regions:
             * case BoundaryLevels.census_divisions:
             */
            default:
                break;
            }

            if (!string.IsNullOrEmpty(url))
            {
                url = url.Replace(Settings.FipsPlaceholder, stateFips);
            }

            return(url);
        }
Пример #3
0
        /// <summary>
        /// Downloads the SHAPE FILEs, must be run before initializing the database!  
        /// Since this will be imported into the database!
        /// </summary>
        /// <returns></returns>
        public bool CheckShapefiles()
        {
            BoundaryLevels[] shapeFileLevels = new BoundaryLevels[] {
                BoundaryLevels.census_blockgroups,
                BoundaryLevels.census_tracts,
                //BoundaryLevels.county_subdivisions,
                //BoundaryLevels.counties,

                /*
                 BoundaryLevels.census_regions,
                 BoundaryLevels.census_divisions,
                 BoundaryLevels.states
                 BoundaryLevels.zipthree,
                 BoundaryLevels.zipfive,
                 */
            };

            foreach (BoundaryLevels level in shapeFileLevels)
            {
                if (level == BoundaryLevels.None)
                    continue;

                string url = ShapefileHelper.GetRemoteShapefileURL(level, this.StateFIPS);
                string localPath = Path.Combine(this.WorkingPath, Path.GetFileName(url));
                string name = level.ToString();

                if (!DownloadAndImportShapefile(url, localPath, name, name))
                {
                    return false;
                }
            }

            return true;
        }
Пример #4
0
        /// <summary>
        /// Helper function for constructing the correct census URL for a particular Boundary Level / State
        /// </summary>
        /// <param name="level"></param>
        /// <param name="stateFips"></param>
        /// <returns></returns>
        public static string GetRemoteShapefileURL(BoundaryLevels level, string stateFips)
        {
            string url = string.Empty;
            switch (level)
            {
                case BoundaryLevels.census_blockgroups:
                    url = Settings.ShapeFileBlockGroupURL + Settings.ShapeFileBlockGroupFilename;
                    break;
                case BoundaryLevels.census_tracts:
                    url = Settings.ShapeFileTractURL + Settings.ShapeFileTractFilename;
                    break;

                /*
                case BoundaryLevels.county_subdivisions:
                    url = Settings.ShapeFileCountySubdivisionsURL + Settings.ShapeFileCountySubdivisionsFilename;
                    break;
                case BoundaryLevels.counties:
                    url = Settings.ShapeFileCountiesURL + Settings.ShapeFileCountiesFilename;
                    break;

                case BoundaryLevels.voting:
                    url = Settings.ShapeFileVotingURL + Settings.ShapeFileVotingFilename;
                    break;
                case BoundaryLevels.zipthree:
                    url = Settings.ShapeFileThreeDigitZipsURL + Settings.ShapeFileThreeDigitZipsFilename;
                    break;
                case BoundaryLevels.zipfive:
                    url = Settings.ShapeFileFiveDigitZipsURL + Settings.ShapeFileFiveDigitZipsFilename;
                    break;

                case BoundaryLevels.states:
                case BoundaryLevels.census_regions:
                case BoundaryLevels.census_divisions:
                */
                default:
                    break;
            }

            if (!string.IsNullOrEmpty(url))
            {
                url = url.Replace(Settings.FipsPlaceholder, stateFips);
            }

            return url;
        }