本文整理汇总了C++中Row::addAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ Row::addAttribute方法的具体用法?C++ Row::addAttribute怎么用?C++ Row::addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Row
的用法示例。
在下文中一共展示了Row::addAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pointline
void pointline() {
std::vector<std::string> names;
std::vector<std::string> secondNames;
std::ifstream names_fin("../имена.txt");
std::ifstream secondNames_fin("../фамилии.txt");
std::copy(std::istream_iterator<std::string>(names_fin),
std::istream_iterator<std::string>(),
std::back_inserter(names));
std::copy(std::istream_iterator<std::string>(secondNames_fin),
std::istream_iterator<std::string>(),
std::back_inserter(secondNames));
srand(621);
DataBase &db = DataBase::getInstance();
// create
TableDescription roads, buildings;
roads.setName("Дороги");
roads.setSpatialKey("Дорога", SpatialType::LINE);
roads.setTemporalKey("Время транзакции", TemporalType::TRANSACTION_TIME);
buildings.setName("Строения");
buildings.setSpatialKey("Позиция", SpatialType::POINT);
buildings.setTemporalKey("Время транзакции", TemporalType::TRANSACTION_TIME);
AttributeDescription roadName; roadName.type = Type::STRING;
roadName.name = "Название"; roads.addColumn(roadName);
AttributeDescription buildingName, buildingType;
buildingName.type = Type::STRING; buildingName.name = "Название";
buildingType.type = Type::STRING; buildingType.name = "Тип";
buildings.addColumn(buildingName); buildings.addColumn(buildingType);
db.createTable(roads);
db.createTable(buildings);
//
db.showTableHeader("Дороги");
db.showTableHeader("Строения");
Attribute m4Atr;
m4Atr.setName("Название");
m4Atr.setValue("M4");
Row m4; m4.addAttribute(m4Atr);
m4.spatialKey.name = "Дорога";
m4.spatialKey.type = SpatialType::LINE;
m4.spatialKey.points = { make_float2(0.1, 0.1),
make_float2(0.2, 0.1),
make_float2(0.1, 0.2),
make_float2(0.1, 0.3),
make_float2(0.3, 0.4),
make_float2(0.4, 0.0),
make_float2(0.5, 0.0),
make_float2(0.7, 0.1),
make_float2(0.5, 0.4),
make_float2(0.5, 0.6),
make_float2(0.4, 0.6),
make_float2(0.4, 0.7),
make_float2(0.8, 0.7),
make_float2(0.9, 0.0)};
m4.temporalKey.name = "Время транзакции"; m4.temporalKey.type = TemporalType::TRANSACTION_TIME;
db.insertRow("Дороги", m4);
db.showTable("Дороги");
std::vector<std::string> localTypes = {"Кинотеатр", "Кафе", "Ресторан", "Отель", "Шаурма", "Церковь \"Ктулху\"", "Стадион", "Памятник"};
for (int i = 0; i < 35; i++) {
Row newBuilding;
newBuilding.spatialKey.name = "Позиция"; newBuilding.spatialKey.type = SpatialType::POINT;
newBuilding.spatialKey.points.push_back(make_float2(((rand() / ((double)RAND_MAX))), ((rand() / ((double)RAND_MAX)))));
newBuilding.temporalKey.name = "Время транзакции"; newBuilding.temporalKey.type = TemporalType::TRANSACTION_TIME;
Attribute name, type;
name.setName("Название");
name.setValue("Улица \"" + names[((rand() / ((double)RAND_MAX))) * names.size()] + "\"");
type.setName("Тип");
type.setValue(localTypes[((rand() / ((double)RAND_MAX))) * localTypes.size()]);
newBuilding.addAttribute(name);
newBuilding.addAttribute(type);
db.insertRow("Строения", newBuilding);
}
db.showTable("Строения");
std::vector<Row> roadRows = db.selectRow("Дороги", SELECT_ALL_ROWS()).unwrap();
auto buildingTT = db.selectTable("Строения").unwrap();
auto roadTT = db.selectTable("Дороги").unwrap();
double radious = 0.05;
auto outTT = db.linexpointPointsInBufferLine(roadTT, buildingTT, radious).unwrap();
std::vector<Row> buildingRows = db.selectRow("Строения", SELECT_ALL_ROWS()).unwrap();
std::vector<Row> linexpointRows = db.selectRow(outTT, SELECT_ALL_ROWS()).unwrap();
db.showTable(outTT);
if( !glfwInit() )
{
fprintf( stderr, "Failed to initialize GLFW\n" );
exit( EXIT_FAILURE );
}
glewExperimental = GL_TRUE;
glewInit();
glfwWindowHint(GLFW_SAMPLES, 4);
GLFWwindow* window = glfwCreateWindow (1000, 1000, "Hello Triangle", NULL, NULL);
//.........这里部分代码省略.........
示例2: tele3
void tele3() {
std::vector<std::string> names;
std::vector<std::string> secondNames;
std::ifstream names_fin("../имена.txt");
std::ifstream secondNames_fin("../фамилии.txt");
std::copy(std::istream_iterator<std::string>(names_fin),
std::istream_iterator<std::string>(),
std::back_inserter(names));
std::copy(std::istream_iterator<std::string>(secondNames_fin),
std::istream_iterator<std::string>(),
std::back_inserter(secondNames));
srand(0);
DataBase &db = DataBase::getInstance();
std::vector<Row> result;
{
{
TableDescription abonents, offices;
abonents.setName("Абоненты ТЕЛЕ-3");
abonents.setSpatialKey("Позиция", SpatialType::POINT);
abonents.setTemporalKey("Время", TemporalType::VALID_TIME);
AttributeDescription name, secondName;
name.name = "Имя"; name.type = Type::STRING;
secondName.name = "Фамилия"; secondName.type = Type::STRING;
abonents.addColumn(name); abonents.addColumn(secondName);
offices.setName("Офисы ТЕЛЕ-3");
offices.setSpatialKey("Граница офиса", SpatialType::POLYGON);
offices.setTemporalKey("Время внесения в таблицу", TemporalType::TRANSACTION_TIME);
AttributeDescription street, officeName;
street.name = "Адрес"; street.type = Type::STRING;
officeName.name = "Название офиса"; officeName.type = Type::STRING;
offices.addColumn(street); offices.addColumn(officeName);
db.createTable(abonents);
db.createTable(offices);
db.showTableHeader("Абоненты ТЕЛЕ-3");
db.showTableHeader("Офисы ТЕЛЕ-3");
}
for (int i = 0; i < 30; i++) {
Row r;
r.spatialKey.name = "Позиция";
r.temporalKey.name = "Время";
r.spatialKey.type = SpatialType::POINT;
r.temporalKey.type = TemporalType::VALID_TIME;
r.spatialKey.points.push_back({(float)(((rand() / ((double)RAND_MAX))) * 2.0 - 1.0), (float)(((rand() / ((double)RAND_MAX))) * 2.0 - 1.0)});
r.temporalKey.validTimeS = Date::getRandomDate(Date(2012, 01, 01, 00, 00, 00, 0), Date(2016,12, 31, 23, 59, 59, 999999));
r.temporalKey.validTimeE.setFromCode(r.temporalKey.validTimeS.codeDate() + (rand() / ((double)RAND_MAX)) * 60 * 999999);
if (r.temporalKey.validTimeS.codeDate() > r.temporalKey.validTimeE.codeDate()) {
myswap(r.temporalKey.validTimeS, r.temporalKey.validTimeE);
}
Attribute name, secondName;
name.setName("Имя");
secondName.setName("Фамилия");
name.setValue(names[((rand() / ((double)RAND_MAX))) * names.size()]);
secondName.setValue(secondNames[((rand() / ((double)RAND_MAX))) * secondNames.size()]);
r.addAttribute(name);
r.addAttribute(secondName);
db.insertRow("Абоненты ТЕЛЕ-3", r);
}
db.showTable("Абоненты ТЕЛЕ-3");
result = db.selectRow("Абоненты ТЕЛЕ-3", SELECT_ALL_ROWS()).unwrap();
for (uint i = 0; i < result.size(); i++) {
printf("\\(%f; %f\\) & %s - %s & %s & %s\\\\ \\hline\n", result[i].spatialKey.points[0].x, result[i].spatialKey.points[0].y,
result[i].temporalKey.validTimeS.toString().c_str(), result[i].temporalKey.validTimeE.toString().c_str(),
result[i].getAttribute(0).unwrap().getString().unwrap().c_str(), result[i].getAttribute(1).unwrap().getString().unwrap().c_str());
}
}
std::vector<std::vector<float2>> polygons;
{
polygons.resize(2);
polygons[0].push_back({0.0 - 1.0, 0.0});
polygons[0].push_back({1.0 - 1.0, 0.0});
polygons[0].push_back({1.0 - 1.0, 0.8});
polygons[0].push_back({0.7 - 1.0, 0.8});
polygons[0].push_back({0.7 - 1.0, 0.5});
polygons[0].push_back({0.3 - 1.0, 0.5});
polygons[0].push_back({0.3 - 1.0, 0.8});
polygons[0].push_back({0.0 - 1.0, 0.8});
polygons[1].push_back({1.0, -0.1});
polygons[1].push_back({0.0, -0.6});
polygons[1].push_back({-1.0, -0.1});
for (int i = 0; i < 2; i++) {
Row r;
r.spatialKey.name = "Граница офиса";
r.temporalKey.name = "Время внесения в таблицу";
r.spatialKey.type = SpatialType::POLYGON;
r.temporalKey.type = TemporalType::TRANSACTION_TIME;
r.spatialKey.points = polygons[i];
Attribute street, officeName;
street.setName("Адрес");
officeName.setName("Название офиса");
//.........这里部分代码省略.........