Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::GeometryTypeSet Class Reference

Public Member Functions

bool IsEmpty () const
bool IsUnknown () const
void Add (GeometryType geom_type, VertexType vert_type)
void Merge (const GeometryTypeSet &other)
void Clear ()
bool HasOnly (GeometryType geom_type, VertexType vert_type) const
bool HasSingleType () const
bool TryGetSingleType (GeometryType &geom_type, VertexType &vert_type) const
void AddWKBType (int32_t wkb_type)
vector< int32_t > ToWKBList () const
vector< string > ToString (bool snake_case) const

Static Public Member Functions

static GeometryTypeSet Unknown ()
static GeometryTypeSet Empty ()

Public Attributes

uint8_t sets [VERT_TYPES]

Static Public Attributes

static constexpr auto VERT_TYPES = 4
static constexpr auto PART_TYPES = 8

Member Function Documentation

◆ Unknown()

GeometryTypeSet duckdb::GeometryTypeSet::Unknown ( )
inlinestatic
15690 {
15691 GeometryTypeSet result;
15692 for (idx_t i = 0; i < VERT_TYPES; i++) {
15693 result.sets[i] = 0xFF;
15694 }
15695 return result;
15696 }
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ Empty()

GeometryTypeSet duckdb::GeometryTypeSet::Empty ( )
inlinestatic
15697 {
15698 GeometryTypeSet result;
15699 for (idx_t i = 0; i < VERT_TYPES; i++) {
15700 result.sets[i] = 0;
15701 }
15702 return result;
15703 }

◆ IsEmpty()

bool duckdb::GeometryTypeSet::IsEmpty ( ) const
inline
15705 {
15706 for (idx_t i = 0; i < VERT_TYPES; i++) {
15707 if (sets[i] != 0) {
15708 return false;
15709 }
15710 }
15711 return true;
15712 }

◆ IsUnknown()

bool duckdb::GeometryTypeSet::IsUnknown ( ) const
inline
15714 {
15715 for (idx_t i = 0; i < VERT_TYPES; i++) {
15716 if (sets[i] != 0xFF) {
15717 return false;
15718 }
15719 }
15720 return true;
15721 }

◆ Add()

void duckdb::GeometryTypeSet::Add ( GeometryType geom_type,
VertexType vert_type )
inline
15723 {
15724 const auto vert_idx = static_cast<uint8_t>(vert_type);
15725 const auto geom_idx = static_cast<uint8_t>(geom_type);
15726 D_ASSERT(vert_idx < VERT_TYPES);
15727 D_ASSERT(geom_idx < PART_TYPES);
15728 sets[vert_idx] |= (1 << geom_idx);
15729 }
::uint8_t uint8_t

◆ Merge()

void duckdb::GeometryTypeSet::Merge ( const GeometryTypeSet & other)
inline
15731 {
15732 for (idx_t i = 0; i < VERT_TYPES; i++) {
15733 sets[i] |= other.sets[i];
15734 }
15735 }

◆ Clear()

void duckdb::GeometryTypeSet::Clear ( )
inline
15737 {
15738 for (idx_t i = 0; i < VERT_TYPES; i++) {
15739 sets[i] = 0;
15740 }
15741 }

◆ HasOnly()

bool duckdb::GeometryTypeSet::HasOnly ( GeometryType geom_type,
VertexType vert_type ) const
inline

Check if only the given geometry and vertex type is present (all others are absent)

15745 {
15746 const auto vert_idx = static_cast<uint8_t>(vert_type);
15747 const auto geom_idx = static_cast<uint8_t>(geom_type);
15748 D_ASSERT(vert_idx < VERT_TYPES);
15749 D_ASSERT(geom_idx < PART_TYPES);
15750 for (uint8_t v_idx = 0; v_idx < VERT_TYPES; v_idx++) {
15751 for (uint8_t g_idx = 1; g_idx < PART_TYPES; g_idx++) {
15752 if (v_idx == vert_idx && g_idx == geom_idx) {
15753 if (!(sets[v_idx] & (1 << g_idx))) {
15754 return false;
15755 }
15756 } else {
15757 if (sets[v_idx] & (1 << g_idx)) {
15758 return false;
15759 }
15760 }
15761 }
15762 }
15763 return true;
15764 }

◆ HasSingleType()

bool duckdb::GeometryTypeSet::HasSingleType ( ) const
inline
15766 {
15767 idx_t type_count = 0;
15768 for (uint8_t v_idx = 0; v_idx < VERT_TYPES; v_idx++) {
15769 for (uint8_t g_idx = 1; g_idx < PART_TYPES; g_idx++) {
15770 if (sets[v_idx] & (1 << g_idx)) {
15771 type_count++;
15772 if (type_count > 1) {
15773 return false;
15774 }
15775 }
15776 }
15777 }
15778 return type_count == 1;
15779 }

◆ TryGetSingleType()

bool duckdb::GeometryTypeSet::TryGetSingleType ( GeometryType & geom_type,
VertexType & vert_type ) const
inline
15781 {
15782 auto result_geom = GeometryType::INVALID;
15783 auto result_vert = VertexType::XY;
15784 auto result_found = false;
15785
15786 for (uint8_t v_idx = 0; v_idx < VERT_TYPES; v_idx++) {
15787 for (uint8_t g_idx = 1; g_idx < PART_TYPES; g_idx++) {
15788 if (sets[v_idx] & (1 << g_idx)) {
15789 if (result_found) {
15790 // Multiple types found
15791 return false;
15792 }
15793 result_found = true;
15794 result_geom = static_cast<GeometryType>(g_idx);
15795 result_vert = static_cast<VertexType>(v_idx);
15796 }
15797 }
15798 }
15799 if (result_found) {
15800 geom_type = result_geom;
15801 vert_type = result_vert;
15802 }
15803 return result_found;
15804 }

◆ AddWKBType()

void duckdb::GeometryTypeSet::AddWKBType ( int32_t wkb_type)
inline
15806 {
15807 const auto vert_idx = static_cast<uint8_t>((wkb_type / 1000) % 10);
15808 const auto geom_idx = static_cast<uint8_t>(wkb_type % 1000);
15809 D_ASSERT(vert_idx < VERT_TYPES);
15810 D_ASSERT(geom_idx < PART_TYPES);
15811 sets[vert_idx] |= (1 << geom_idx);
15812 }

◆ ToWKBList()

vector< int32_t > duckdb::GeometryTypeSet::ToWKBList ( ) const
inline
15814 {
15815 vector<int32_t> result;
15816 for (uint8_t vert_idx = 0; vert_idx < VERT_TYPES; vert_idx++) {
15817 for (uint8_t geom_idx = 1; geom_idx < PART_TYPES; geom_idx++) {
15818 if (sets[vert_idx] & (1 << geom_idx)) {
15819 result.push_back(geom_idx + vert_idx * 1000);
15820 }
15821 }
15822 }
15823 return result;
15824 }

◆ ToString()

vector< string > duckdb::GeometryTypeSet::ToString ( bool snake_case) const
423427 {
423428 vector<string> result;
423429 for (auto d = 0; d < VERT_TYPES; d++) {
423430 for (auto i = 0; i < PART_TYPES; i++) {
423431 if (sets[d] & (1 << i)) {
423432 string str;
423433 switch (i) {
423434 case 1:
423435 str = snake_case ? "point" : "Point";
423436 break;
423437 case 2:
423438 str = snake_case ? "linestring" : "LineString";
423439 break;
423440 case 3:
423441 str = snake_case ? "polygon" : "Polygon";
423442 break;
423443 case 4:
423444 str = snake_case ? "multipoint" : "MultiPoint";
423445 break;
423446 case 5:
423447 str = snake_case ? "multilinestring" : "MultiLineString";
423448 break;
423449 case 6:
423450 str = snake_case ? "multipolygon" : "MultiPolygon";
423451 break;
423452 case 7:
423453 str = snake_case ? "geometrycollection" : "GeometryCollection";
423454 break;
423455 default:
423456 str = snake_case ? "unknown" : "Unknown";
423457 break;
423458 }
423459 switch (d) {
423460 case 1:
423461 str += snake_case ? "_z" : " Z";
423462 break;
423463 case 2:
423464 str += snake_case ? "_m" : " M";
423465 break;
423466 case 3:
423467 str += snake_case ? "_zm" : " ZM";
423468 break;
423469 default:
423470 break;
423471 }
423472
423473 result.push_back(str);
423474 }
423475 }
423476 }
423477 return result;
423478}

The documentation for this class was generated from the following files: