pub enum Geoid {
State(State),
County(State, County),
CountySubdivision(State, County, CountySubdivision),
Place(State, Place),
CensusTract(State, County, CensusTract),
BlockGroup(State, County, CensusTract, BlockGroup),
Block(State, County, CensusTract, Block),
}Variants§
State(State)
County(State, County)
CountySubdivision(State, County, CountySubdivision)
Place(State, Place)
CensusTract(State, County, CensusTract)
BlockGroup(State, County, CensusTract, BlockGroup)
Block(State, County, CensusTract, Block)
Implementations§
Source§impl Geoid
impl Geoid
Sourcepub fn all_states() -> Vec<Geoid>
pub fn all_states() -> Vec<Geoid>
generates all state level Geoids for the U.S.
pub fn geoid_type(&self) -> GeoidType
pub fn variant_name(&self) -> String
Sourcepub fn truncate_geoid_to_type(
&self,
target: &GeoidType,
) -> Result<Geoid, String>
pub fn truncate_geoid_to_type( &self, target: &GeoidType, ) -> Result<Geoid, String>
manipulates this GEOID via truncation to transform it’s GEOID type.
GEOID is a hierarchical numeric identifier. we can truncate the values in order to reach a higher/larger geographic representation. this method supports that operation, where this Geoid instance will be truncated to transform it into some other GeoidType.
§Examples
converts GEOID 08059009838 (TRACT) to 08059 (COUNTY).
use bamcensus_core::model::identifier::{Geoid, GeoidType, fips};
let geoid = Geoid::CensusTract(
fips::State(8), // 08 Colorado
fips::County(59), // 059 Jefferson
fips::CensusTract(9838) // 009838
);
let result = geoid.truncate_geoid_to_type(&GeoidType::County).unwrap();
assert_eq!(result, Geoid::County(fips::State(8), fips::County(59)))Sourcepub fn is_parent_of(&self, child: &Geoid) -> bool
pub fn is_parent_of(&self, child: &Geoid) -> bool
predicate to filter by hierarchical geoshed.
Sourcepub fn to_parent(&self) -> Option<Geoid>
pub fn to_parent(&self) -> Option<Geoid>
manipulates this GEOID via truncation to transform it’s GEOID type to that of it’s parent.
the base case is None, which is the parent of State, and signifies “no restriction”
in census queries. for all other GeoidTypes, we simply remove the lowest area type.
§Note
Geoid::Block.to_parent() produces a CensusTract, not a BlockGroup, based on https://www.census.gov/programs-surveys/geography/guidance/geo-identifiers.html, which does not imply that all block groups are the first digit of all blocks.
pub fn to_state(&self) -> Geoid
pub fn to_state_abbreviation(&self) -> Result<String, String>
pub fn to_county(&self) -> Result<Geoid, String>
pub fn to_census_tract(&self) -> Result<Geoid, String>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Geoid
impl<'de> Deserialize<'de> for Geoid
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Geoid
Source§impl HasGeoidString for Geoid
impl HasGeoidString for Geoid
fn geoid_string(&self) -> String
impl StructuralPartialEq for Geoid
Auto Trait Implementations§
impl Freeze for Geoid
impl RefUnwindSafe for Geoid
impl Send for Geoid
impl Sync for Geoid
impl Unpin for Geoid
impl UnsafeUnpin for Geoid
impl UnwindSafe for Geoid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more