us_geo 2.0.2 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/VERSION +1 -1
- data/db/migrate/20230620000100_fix_short_names.rb +58 -0
- data/explorer_app/app/helpers/application_helper.rb +1 -2
- data/explorer_app/app/views/counties/show.html.erb +5 -1
- data/explorer_app/app/views/county_subdivisions/show.html.erb +5 -1
- data/explorer_app/app/views/places/show.html.erb +5 -1
- data/explorer_app/app/views/shared/_demographics_cells.html.erb +2 -1
- data/explorer_app/app/views/shared/_demographics_headers.html.erb +1 -0
- data/explorer_app/app/views/zctas/show.html.erb +5 -1
- data/lib/us_geo/population.rb +14 -0
- 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: a6b963948f153ee9add87c2daa3d45fd79ec3ed1d79f156c94bec7cc8b9ca879
|
4
|
+
data.tar.gz: 69b5d532013234f466319b8fc52ba4ea1809579bedc663f80258c7fd80246fef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51b285a6397f15652483f2c9f36eebbf423fa8ceb7b97fd672cb5361860e351333d562a6b36fb39388c21adb67ef4e7156ceaf1ccb88e727683fab5471ff8b1c
|
7
|
+
data.tar.gz: d3ff6ae39376c494ac87f4533f6aeee5017546547f56ac1a1bb1cb35f8ad84cfac89f41090792c494de889d31718db6fff15cecbb13f8eb39ad5ee4823e0ae84
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,19 @@ 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.0.4
|
8
|
+
|
9
|
+
- Remove "Urbanized Area" from short name for urban areas.
|
10
|
+
- 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.
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
## 2.0.3
|
15
|
+
|
16
|
+
### Added
|
17
|
+
|
18
|
+
- Added methods to calculate housing density.
|
19
|
+
|
7
20
|
## 2.0.2
|
8
21
|
|
9
22
|
### Fixed
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.4
|
@@ -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
|
@@ -25,8 +25,7 @@ module ApplicationHelper
|
|
25
25
|
render "shared/demographics_cells", entity: entity, round_area: round_area
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
density = entity.population_density
|
28
|
+
def density(density)
|
30
29
|
return nil unless density
|
31
30
|
|
32
31
|
round = if density < 1
|
@@ -48,12 +48,16 @@
|
|
48
48
|
</tr>
|
49
49
|
<tr>
|
50
50
|
<th>Population Density</th>
|
51
|
-
<td><%=
|
51
|
+
<td><%= density(@county.population_density) %></td>
|
52
52
|
</tr>
|
53
53
|
<tr>
|
54
54
|
<th>Housing Units</th>
|
55
55
|
<td><%= formatted_number(@county.housing_units) %></td>
|
56
56
|
</tr>
|
57
|
+
<tr>
|
58
|
+
<th>Housing Density</th>
|
59
|
+
<td><%= density(@county.housing_density) %></td>
|
60
|
+
</tr>
|
57
61
|
<tr>
|
58
62
|
<th>Land Area (mi<sup>2</sup>)</th>
|
59
63
|
<td><%= formatted_number(@county.land_area, round: 0) %></td>
|
@@ -48,12 +48,16 @@
|
|
48
48
|
</tr>
|
49
49
|
<tr>
|
50
50
|
<th>Population Density</th>
|
51
|
-
<td><%=
|
51
|
+
<td><%= density(@county_subdivision.population_density) %></td>
|
52
52
|
</tr>
|
53
53
|
<tr>
|
54
54
|
<th>Housing Units</th>
|
55
55
|
<td><%= formatted_number(@county_subdivision.housing_units) %></td>
|
56
56
|
</tr>
|
57
|
+
<tr>
|
58
|
+
<th>Housing Density</th>
|
59
|
+
<td><%= density(@county_subdivision.housing_density) %></td>
|
60
|
+
</tr>
|
57
61
|
<tr>
|
58
62
|
<th>Land Area (mi<sup>2</sup>)</th>
|
59
63
|
<td><%= formatted_number(@county_subdivision.land_area, round: 0) %></td>
|
@@ -56,12 +56,16 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr>
|
58
58
|
<th>Population Density</th>
|
59
|
-
<td><%=
|
59
|
+
<td><%= density(@place.population_density) %></td>
|
60
60
|
</tr>
|
61
61
|
<tr>
|
62
62
|
<th>Housing Units</th>
|
63
63
|
<td><%= formatted_number(@place.housing_units) %></td>
|
64
64
|
</tr>
|
65
|
+
<tr>
|
66
|
+
<th>Housing Density</th>
|
67
|
+
<td><%= density(@place.housing_density) %></td>
|
68
|
+
</tr>
|
65
69
|
<tr>
|
66
70
|
<th>Land Area (mi<sup>2</sup>)</th>
|
67
71
|
<td><%= formatted_number(@place.land_area, round: 0) %></td>
|
@@ -1,5 +1,6 @@
|
|
1
1
|
<%= content_tag(:td, (entity.population ? formatted_number(entity.population) : "-"), class: "text-end", data: {sort: entity.population.to_i}) %>
|
2
|
-
<%= content_tag(:td,
|
2
|
+
<%= content_tag(:td, density(entity.population_density), class: "text-end", data: {sort: entity.population_density.to_f}) %>
|
3
3
|
<%= content_tag(:td, (entity.housing_units ? formatted_number(entity.housing_units) : "-"), class: "text-end", data: {sort: entity.housing_units.to_i}) %>
|
4
|
+
<%= content_tag(:td, density(entity.housing_density), class: "text-end", data: {sort: entity.housing_density.to_f}) %>
|
4
5
|
<%= content_tag(:td, (entity.land_area ? formatted_number(entity.land_area, round: round_area) : "-"), class: "text-end", data: {sort: entity.land_area.to_i}) %>
|
5
6
|
<%= content_tag(:td, (entity.water_area ? formatted_number(entity.water_area, round: round_area) : "-"), class: "text-end", data: {sort: entity.water_area.to_i}) %>
|
@@ -54,12 +54,16 @@
|
|
54
54
|
</tr>
|
55
55
|
<tr>
|
56
56
|
<th>Population Density</th>
|
57
|
-
<td><%=
|
57
|
+
<td><%= density(@zcta.population_density) %></td>
|
58
58
|
</tr>
|
59
59
|
<tr>
|
60
60
|
<th>Housing Units</th>
|
61
61
|
<td><%= formatted_number(@zcta.housing_units) %></td>
|
62
62
|
</tr>
|
63
|
+
<tr>
|
64
|
+
<th>Housing Density</th>
|
65
|
+
<td><%= density(@zcta.housing_density) %></td>
|
66
|
+
</tr>
|
63
67
|
<tr>
|
64
68
|
<th>Land Area (mi<sup>2</sup>)</th>
|
65
69
|
<td><%= formatted_number(@zcta.land_area, round: 0) %></td>
|
data/lib/us_geo/population.rb
CHANGED
@@ -22,5 +22,19 @@ module USGeo
|
|
22
22
|
def population_density_km
|
23
23
|
population.to_f / land_area_km if population && land_area.to_f > 0
|
24
24
|
end
|
25
|
+
|
26
|
+
# Housing units per square mile.
|
27
|
+
#
|
28
|
+
# @return [Float, nil]
|
29
|
+
def housing_density
|
30
|
+
housing_units.to_f / land_area if housing_units && land_area.to_f > 0
|
31
|
+
end
|
32
|
+
|
33
|
+
# Housing units per square kilometer.
|
34
|
+
#
|
35
|
+
# @return [Float, nil]
|
36
|
+
def housing_density_km
|
37
|
+
housing_units.to_f / land_area_km if housing_units && land_area.to_f > 0
|
38
|
+
end
|
25
39
|
end
|
26
40
|
end
|
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.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Durand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-20 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
|