us_geo 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -0
- data/README.md +2 -1
- data/VERSION +1 -1
- data/db/migrate/20230620000100_fix_short_names.rb +58 -0
- data/explorer_app/app/controllers/urban_areas_controller.rb +4 -7
- data/lib/us_geo/urban_area.rb +8 -2
- data/lib/us_geo/urban_cluster.rb +2 -0
- data/lib/us_geo/urbanized_area.rb +2 -0
- data/lib/us_geo.rb +28 -28
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68802aa8e92d01352ec2107646d28307fcc14fb2c4fe2a103654d40b1ec1328c
|
4
|
+
data.tar.gz: 50f856f724b528654ef89a561aa0e7bf0cd9ac4f17a3a270ac92d6a41bc23927
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d721fcf6721324a42d7271bec405b6f0656631a3662482ddfcd9b000747040efbd7f6b6c46395607b0d752df96870328e2bf6d803b15048b55d768274e00f5b
|
7
|
+
data.tar.gz: 6aacb9847c137272d88fc212fa1ee4deb9c118d577d3bcd75f373c87d3d4c7b03b2e02a6d3bee3d125cdb3e1c35e6b78cac906fb44b095ec74786be8abb49649
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## 2.1.0
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Lazy load ActiveRecord classes so they don't add overhead during application initialization.
|
12
|
+
- Update distribution data files with latest Census data as of March 2024.
|
13
|
+
- Geographic data is based on 2023 Gazetteer files.
|
14
|
+
- Population and housing data are based on 2022 ACS estimates.
|
15
|
+
- Some of the Core Based Statistical Area, Combined Statisical Area, and Metropolitan Division names have changed.
|
16
|
+
- All Urban Areas now include "Urban Area" in their name. The Census Bureau no longer distinguishes between Urbanized Areas and Urban Clusters and the data now reflects the official names.
|
17
|
+
|
18
|
+
### Deprecated
|
19
|
+
|
20
|
+
- The USGeo::UrbanizedArea and USGeo::UrbanCluster classes are deprecated. These classes are now just aliases for USGeo::UrbanArea. You can still use the `urbanized?` and `cluster?` methods to determine the size of an UrbanArea based on the pre-2020 definition of greater or less then 50,000 residents.
|
21
|
+
|
22
|
+
## 2.0.4
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Remove "Urbanized Area" from short name for urban areas.
|
27
|
+
- Fix short name for Louisville, KY in the in the CBSA's, CSA's, and Urban Areas to omit "Jefferson County" so it matches convention for other short names of only showing the major city.
|
28
|
+
|
7
29
|
## 2.0.3
|
8
30
|
|
9
31
|
### Added
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# USGeo
|
2
2
|
|
3
|
-
[![
|
3
|
+
[![Continuous Integration](https://github.com/bdurand/us_geo/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/bdurand/us_geo/actions/workflows/continuous_integration.yml)
|
4
4
|
[![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/us_geo.svg)](https://badge.fury.io/rb/us_geo)
|
5
6
|
|
6
7
|
This gem provides a variety of U.S. geographic data ActiveRecord models. It is designed to provide a normalized way to access the data from a relational database. This is by no means a complete set of data.
|
7
8
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0
|
1
|
+
2.1.0
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class FixShortNames < ActiveRecord::Migration[5.0]
|
4
|
+
def up
|
5
|
+
update <<~SQL
|
6
|
+
UPDATE us_geo_core_based_statistical_areas
|
7
|
+
SET short_name = 'Louisville, KY'
|
8
|
+
WHERE short_name = 'Louisville/Jefferson County, KY'
|
9
|
+
SQL
|
10
|
+
|
11
|
+
update <<~SQL
|
12
|
+
UPDATE us_geo_combined_statistical_areas
|
13
|
+
SET short_name = 'Louisville, KY'
|
14
|
+
WHERE short_name = 'Louisville/Jefferson County, KY'
|
15
|
+
SQL
|
16
|
+
|
17
|
+
update <<~SQL
|
18
|
+
UPDATE us_geo_urban_areas
|
19
|
+
SET short_name = 'Louisville, KY'
|
20
|
+
WHERE short_name = 'Louisville/Jefferson County, KY'
|
21
|
+
SQL
|
22
|
+
|
23
|
+
select_all("SELECT geoid, name, short_name FROM us_geo_urban_areas").each do |row|
|
24
|
+
name = row["name"].sub(/\s+Urban(?:ized)? (?:Area|Cluster)/, "")
|
25
|
+
city, state = name.split(", ", 2)
|
26
|
+
short_name = "#{city.split("-").first.split("/").first}, #{state.split("-").first}"
|
27
|
+
escaped_short_name = short_name.gsub("'", "''")
|
28
|
+
|
29
|
+
if short_name != row["short_name"]
|
30
|
+
update <<~SQL
|
31
|
+
UPDATE us_geo_urban_areas
|
32
|
+
SET short_name = '#{escaped_short_name}'
|
33
|
+
WHERE geoid = '#{row["geoid"]}'
|
34
|
+
SQL
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def down
|
40
|
+
update <<~SQL
|
41
|
+
UPDATE us_geo_core_based_statistical_areas
|
42
|
+
SET short_name = 'Louisville/Jefferson County, KY'
|
43
|
+
WHERE short_name = 'Louisville, KY'
|
44
|
+
SQL
|
45
|
+
|
46
|
+
update <<~SQL
|
47
|
+
UPDATE us_geo_combined_statistical_areas
|
48
|
+
SET short_name = 'Louisville/Jefferson County, KY'
|
49
|
+
WHERE short_name = 'Louisville, KY'
|
50
|
+
SQL
|
51
|
+
|
52
|
+
update <<~SQL
|
53
|
+
UPDATE us_geo_urban_areas
|
54
|
+
SET short_name = 'Louisville/Jefferson County, KY'
|
55
|
+
WHERE short_name = 'Louisville, KY'
|
56
|
+
SQL
|
57
|
+
end
|
58
|
+
end
|
@@ -5,13 +5,10 @@ class UrbanAreasController < ApplicationController
|
|
5
5
|
urban_areas = USGeo::UrbanArea.not_removed
|
6
6
|
|
7
7
|
@tab = params[:tab]
|
8
|
-
if @tab
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"UrbanCluster"
|
13
|
-
end
|
14
|
-
urban_areas = urban_areas.where(type: type)
|
8
|
+
if @tab == "urbanized"
|
9
|
+
urban_areas = urban_areas.where(population: 50_000..)
|
10
|
+
elsif @tab == "cluster"
|
11
|
+
urban_areas = urban_areas.where(population: ...50_000)
|
15
12
|
end
|
16
13
|
|
17
14
|
@urban_areas = urban_areas.order(:name)
|
data/lib/us_geo/urban_area.rb
CHANGED
@@ -85,12 +85,18 @@ module USGeo
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
# Return true if the population is greater than or equal to 50,000.
|
89
|
+
#
|
90
|
+
# @return [Boolean]
|
88
91
|
def urbanized?
|
89
|
-
|
92
|
+
population >= 50_000
|
90
93
|
end
|
91
94
|
|
95
|
+
# Return true if the population is less than 50,000.
|
96
|
+
#
|
97
|
+
# @return [Boolean]
|
92
98
|
def cluster?
|
93
|
-
|
99
|
+
population < 50_000
|
94
100
|
end
|
95
101
|
end
|
96
102
|
end
|
data/lib/us_geo/urban_cluster.rb
CHANGED
data/lib/us_geo.rb
CHANGED
@@ -4,37 +4,37 @@ require "active_record"
|
|
4
4
|
|
5
5
|
require_relative "us_geo/version"
|
6
6
|
|
7
|
-
require_relative "us_geo/area"
|
8
|
-
require_relative "us_geo/population"
|
9
|
-
require_relative "us_geo/base_record"
|
10
|
-
|
11
|
-
require_relative "us_geo/region"
|
12
|
-
require_relative "us_geo/division"
|
13
|
-
require_relative "us_geo/state"
|
14
|
-
require_relative "us_geo/combined_statistical_area"
|
15
|
-
require_relative "us_geo/core_based_statistical_area"
|
16
|
-
require_relative "us_geo/metropolitan_area"
|
17
|
-
require_relative "us_geo/micropolitan_area"
|
18
|
-
require_relative "us_geo/metropolitan_division"
|
19
|
-
require_relative "us_geo/county"
|
20
|
-
require_relative "us_geo/county_subdivision"
|
21
|
-
require_relative "us_geo/place"
|
22
|
-
require_relative "us_geo/place_county"
|
23
|
-
require_relative "us_geo/urban_area"
|
24
|
-
require_relative "us_geo/urban_area_county"
|
25
|
-
require_relative "us_geo/urban_area_county_subdivision"
|
26
|
-
require_relative "us_geo/urban_cluster"
|
27
|
-
require_relative "us_geo/urbanized_area"
|
28
|
-
require_relative "us_geo/zcta"
|
29
|
-
require_relative "us_geo/zcta_county"
|
30
|
-
require_relative "us_geo/zcta_county_subdivision"
|
31
|
-
require_relative "us_geo/zcta_mapping"
|
32
|
-
require_relative "us_geo/zcta_place"
|
33
|
-
require_relative "us_geo/zcta_urban_area"
|
34
|
-
|
35
7
|
require_relative "us_geo/engine" if defined?(::Rails::Engine)
|
36
8
|
|
37
9
|
module USGeo
|
10
|
+
autoload :Area, "us_geo/area"
|
11
|
+
autoload :Population, "us_geo/population"
|
12
|
+
autoload :BaseRecord, "us_geo/base_record"
|
13
|
+
|
14
|
+
autoload :Region, "us_geo/region"
|
15
|
+
autoload :Division, "us_geo/division"
|
16
|
+
autoload :State, "us_geo/state"
|
17
|
+
autoload :CombinedStatisticalArea, "us_geo/combined_statistical_area"
|
18
|
+
autoload :CoreBasedStatisticalArea, "us_geo/core_based_statistical_area"
|
19
|
+
autoload :MetropolitanArea, "us_geo/metropolitan_area"
|
20
|
+
autoload :MicropolitanArea, "us_geo/micropolitan_area"
|
21
|
+
autoload :MetropolitanDivision, "us_geo/metropolitan_division"
|
22
|
+
autoload :County, "us_geo/county"
|
23
|
+
autoload :CountySubdivision, "us_geo/county_subdivision"
|
24
|
+
autoload :Place, "us_geo/place"
|
25
|
+
autoload :PlaceCounty, "us_geo/place_county"
|
26
|
+
autoload :UrbanArea, "us_geo/urban_area"
|
27
|
+
autoload :UrbanAreaCounty, "us_geo/urban_area_county"
|
28
|
+
autoload :UrbanAreaCountySubdivision, "us_geo/urban_area_county_subdivision"
|
29
|
+
autoload :UrbanCluster, "us_geo/urban_cluster"
|
30
|
+
autoload :UrbanizedArea, "us_geo/urbanized_area"
|
31
|
+
autoload :Zcta, "us_geo/zcta"
|
32
|
+
autoload :ZctaCounty, "us_geo/zcta_county"
|
33
|
+
autoload :ZctaCountySubdivision, "us_geo/zcta_county_subdivision"
|
34
|
+
autoload :ZctaMapping, "us_geo/zcta_mapping"
|
35
|
+
autoload :ZctaPlace, "us_geo/zcta_place"
|
36
|
+
autoload :ZctaUrbanArea, "us_geo/zcta_urban_area"
|
37
|
+
|
38
38
|
BASE_DATA_URI = "https://raw.githubusercontent.com/bdurand/us_geo/master/data/2020_dist"
|
39
39
|
|
40
40
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: us_geo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- db/migrate/20230417000500_allow_null_zcta_urban_areas_demographics.rb
|
84
84
|
- db/migrate/20230417000600_add_additional_time_zone_name_to_counties.rb
|
85
85
|
- db/migrate/20230426000100_add_index_on_zctas_geoids.rb
|
86
|
+
- db/migrate/20230620000100_fix_short_names.rb
|
86
87
|
- db/schema.rb
|
87
88
|
- explorer_app/.gitattributes
|
88
89
|
- explorer_app/.gitignore
|