diff --git a/include/attribute_store.h b/include/attribute_store.h index 498c6c6c..9ac8adbf 100644 --- a/include/attribute_store.h +++ b/include/attribute_store.h @@ -42,7 +42,7 @@ class AttributeKeyStore { std::map keys2index; }; -enum class AttributePairType: uint8_t { Bool = 0, Float = 1, String = 2 }; +enum class AttributePairType: uint8_t { String = 0, Float = 1, Bool = 2 }; // AttributePair is a key/value pair (with minzoom) #pragma pack(push, 1) struct AttributePair { diff --git a/include/shared_data.h b/include/shared_data.h index 6172a1da..44b3bc66 100644 --- a/include/shared_data.h +++ b/include/shared_data.h @@ -34,7 +34,7 @@ struct LayerDef { bool allSourceColumns; bool indexed; std::string indexName; - std::map attributeMap; + std::map attributeMap; // string 0, number 1, bool 2 bool writeTo; const bool useColumn(std::string &col) { diff --git a/src/shp_processor.cpp b/src/shp_processor.cpp index 0cbe5c33..9e56b2ba 100644 --- a/src/shp_processor.cpp +++ b/src/shp_processor.cpp @@ -35,6 +35,7 @@ void ShpProcessor::fillPointArrayFromShapefile(vector *points, SHPObject } // Read requested attributes from a shapefile, and encode into an OutputObject +// columnTypeMap: 0 string, 1 int, 2 double, 3 boolean AttributeIndex ShpProcessor::readShapefileAttributes( DBFHandle &dbf, int recordNum, unordered_map &columnMap, unordered_map &columnTypeMap, @@ -53,6 +54,7 @@ AttributeIndex ShpProcessor::readShapefileAttributes( switch (columnTypeMap[pos]) { case 1: in_table[key] = DBFReadIntegerAttribute(dbf, recordNum, pos); break; case 2: in_table[key] = DBFReadDoubleAttribute(dbf, recordNum, pos); break; + case 3: in_table[key] = strcmp(DBFReadStringAttribute(dbf, recordNum, pos), "T")==0; break; default: in_table[key] = DBFReadStringAttribute(dbf, recordNum, pos); break; } } @@ -92,7 +94,10 @@ AttributeIndex ShpProcessor::readShapefileAttributes( case 2: attributeStore.addAttribute(attributes, key, static_cast(DBFReadDoubleAttribute(dbf, recordNum, pos)), 0); layer.attributeMap[key] = 1; break; - default: attributeStore.addAttribute(attributes, key, DBFReadStringAttribute(dbf, recordNum, pos), 0); + case 3: attributeStore.addAttribute(attributes, key, strcmp(DBFReadStringAttribute(dbf, recordNum, pos), "T")==0, 0); + layer.attributeMap[key] = 2; + break; + default: attributeStore.addAttribute(attributes, key, static_cast(DBFReadStringAttribute(dbf, recordNum, pos)), 0); layer.attributeMap[key] = 0; break; }