Skip to content

Commit 613b59b

Browse files
committed
restored predefined sets
1 parent d23dd27 commit 613b59b

File tree

6 files changed

+79
-187
lines changed

6 files changed

+79
-187
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ ZipFile = "a5390f91-8eb1-5f08-bee0-b1d1ffed6cea"
1717
[compat]
1818
HTTP = "1.10.15"
1919
Test = "1.11.0"
20-
julia = "1.6"
20+
julia = "1.11"

list_geoid_sets.jl

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/GeoIDs.jl

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ include("store.jl")
1616
include("fetch.jl")
1717
include("operations.jl")
1818
include("setup.jl")
19-
include("predefined_sets.jl") # Include the new predefined sets module
19+
#include("predefined_sets.jl") # Include the new predefined sets module
2020
include("list_all_geoids.jl") # Include the list_all_geoids function
2121

2222
# Import and re-export from sub-modules
@@ -28,7 +28,7 @@ using .Setup
2828
using .PredefinedSets
2929
using .ListGeoids
3030

31-
# Constants for holding pre-defined GEOID sets that will be loaded from the database
31+
Constants for holding pre-defined GEOID sets that will be loaded from the database
3232
const EASTERN_US_GEOIDS_DB = String[]
3333
const WESTERN_US_GEOIDS_DB = String[]
3434
const SOUTH_FLORIDA_GEOIDS_DB = String[]
@@ -393,50 +393,50 @@ function restore_geoid_sets(input_file::String, overwrite::Bool=false)
393393
end
394394

395395
# Initialize the module
396-
function __init__()
397-
# Setup database tables if they don't exist
398-
try
399-
# Ensure database exists and is properly initialized with data
400-
initialize_database()
401-
402-
# Initialize predefined GEOID sets in the database
403-
initialize_predefined_geoid_sets()
404-
405-
# Load constants from the database
406-
load_predefined_geoids()
407-
catch e
408-
@warn "Error during GeoIDs initialization: $e"
409-
end
410-
end
396+
# function __init__()
397+
# # Setup database tables if they don't exist
398+
# try
399+
# # Ensure database exists and is properly initialized with data
400+
# initialize_database()
401+
#
402+
# # Initialize predefined GEOID sets in the database
403+
# initialize_predefined_geoid_sets()
404+
#
405+
# # Load constants from the database
406+
# load_predefined_geoids()
407+
# catch e
408+
# @warn "Error during GeoIDs initialization: $e"
409+
# end
410+
# end
411411

412412
# Export functions from main module
413-
export backup_geoid_sets,
413+
# export backup_geoid_sets,
414414
restore_geoid_sets,
415-
EASTERN_US_GEOIDS_DB,
416-
WESTERN_US_GEOIDS_DB,
417-
SOUTH_FLORIDA_GEOIDS_DB,
418-
MIDWEST_GEOIDS_DB,
419-
MOUNTAIN_WEST_GEOIDS_DB,
420-
GREAT_PLAINS_GEOIDS_DB,
421-
EAST_OF_SIERRAS_GEOIDS_DB,
422-
FLORIDA_GEOIDS_DB,
423-
COLORADO_BASIN_GEOIDS_DB,
424-
WEST_OF_100TH_GEOIDS_DB,
425-
EAST_OF_100TH_GEOIDS_DB,
426-
MICHIGAN_UPPER_PENINSULA_GEOIDS_DB,
427-
NORTHERN_RURAL_CALIFORNIA_GEOIDS_DB,
428-
SOCAL_GEOIDS_DB,
429-
MISSOURI_RIVER_BASIN_DB,
430-
EAST_OF_CASCADES_DB,
415+
# EASTERN_US_GEOIDS_DB,
416+
# WESTERN_US_GEOIDS_DB,
417+
# SOUTH_FLORIDA_GEOIDS_DB,
418+
# MIDWEST_GEOIDS_DB,
419+
# MOUNTAIN_WEST_GEOIDS_DB,
420+
# GREAT_PLAINS_GEOIDS_DB,
421+
# EAST_OF_SIERRAS_GEOIDS_DB,
422+
# FLORIDA_GEOIDS_DB,
423+
# COLORADO_BASIN_GEOIDS_DB,
424+
# WEST_OF_100TH_GEOIDS_DB,
425+
# EAST_OF_100TH_GEOIDS_DB,
426+
# MICHIGAN_UPPER_PENINSULA_GEOIDS_DB,
427+
# NORTHERN_RURAL_CALIFORNIA_GEOIDS_DB,
428+
# SOCAL_GEOIDS_DB,
429+
# MISSOURI_RIVER_BASIN_DB,
430+
# EAST_OF_CASCADES_DB,
431431
# Export Setup module functions
432-
setup_census_schema,
433-
download_county_shapefile,
434-
load_counties_to_db,
435-
initialize_database,
436-
# Export utility functions
437-
list_all_geoids,
438-
which_sets,
439-
create_predefined_set,
440-
create_all_predefined_sets
432+
setup_census_schema,
433+
download_county_shapefile,
434+
load_counties_to_db,
435+
initialize_database,
436+
# Export utility functions
437+
list_all_geoids,
438+
which_sets,
439+
create_predefined_set,
440+
create_all_predefined_sets
441441

442442
end # module GeoIDs
File renamed without changes.

src/operations.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,39 @@ export union_geoid_sets,
154154
difference_geoid_sets,
155155
symmetric_difference_geoid_sets
156156

157+
"""
158+
get_centroid_longitude_range_geoids(min_long::Float64, max_long::Float64) -> Vector{String}
159+
160+
Returns GEOIDs for counties with centroids between the specified longitude range.
161+
Longitude values should be in decimal degrees, with negative values for western hemisphere.
162+
163+
# Arguments
164+
- `min_long::Float64`: Minimum longitude (western boundary)
165+
- `max_long::Float64`: Maximum longitude (eastern boundary)
166+
167+
# Returns
168+
- `Vector{String}`: Vector of county GEOIDs within the specified longitude range
169+
170+
# Example
171+
```julia
172+
# Get counties between -110°W and -115°W
173+
geoids = get_centroid_longitude_range_geoids(-115.0, -110.0)
174+
```
175+
"""
176+
function get_centroid_longitude_range_geoids(min_long::Float64, max_long::Float64)
177+
conn = get_connection()
178+
try
179+
query = """
180+
SELECT geoid
181+
FROM census.counties
182+
WHERE ST_X(ST_Centroid(geom)) BETWEEN $min_long AND $max_long
183+
ORDER BY geoid;
184+
"""
185+
result = execute(conn, query)
186+
return DataFrame(result).geoid
187+
finally
188+
return_connection(conn)
189+
end
190+
end
191+
157192
end # module Operations

test_constants.jl

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)