本文整理汇总了C++中TraCIServer::readTypeCheckingPolygon方法的典型用法代码示例。如果您正苦于以下问题:C++ TraCIServer::readTypeCheckingPolygon方法的具体用法?C++ TraCIServer::readTypeCheckingPolygon怎么用?C++ TraCIServer::readTypeCheckingPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TraCIServer
的用法示例。
在下文中一共展示了TraCIServer::readTypeCheckingPolygon方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPolygon
bool
TraCIServerAPI_Polygon::processSet(TraCIServer& server, tcpip::Storage& inputStorage,
tcpip::Storage& outputStorage) {
std::string warning = ""; // additional description for response
// variable
int variable = inputStorage.readUnsignedByte();
if (variable != VAR_TYPE && variable != VAR_COLOR && variable != VAR_SHAPE && variable != VAR_FILL
&& variable != ADD && variable != REMOVE) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "Change Polygon State: unsupported variable specified", outputStorage);
}
// id
std::string id = inputStorage.readString();
Polygon* p = 0;
ShapeContainer& shapeCont = MSNet::getInstance()->getShapeContainer();
if (variable != ADD && variable != REMOVE) {
p = getPolygon(id);
if (p == 0) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "Polygon '" + id + "' is not known", outputStorage);
}
}
// process
switch (variable) {
case VAR_TYPE: {
std::string type;
if (!server.readTypeCheckingString(inputStorage, type)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The type must be given as a string.", outputStorage);
}
p->setType(type);
}
break;
case VAR_COLOR: {
RGBColor col;
if (!server.readTypeCheckingColor(inputStorage, col)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The color must be given using an according type.", outputStorage);
}
p->setColor(col);
}
break;
case VAR_SHAPE: {
PositionVector shape;
if (!server.readTypeCheckingPolygon(inputStorage, shape)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The shape must be given using an accoring type.", outputStorage);
}
shapeCont.reshapePolygon(id, shape);
}
break;
case VAR_FILL: {
int value = 0;
if (!server.readTypeCheckingUnsignedByte(inputStorage, value)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "'fill' must be defined using an unsigned byte.", outputStorage);
}
p->setFill(value != 0);
}
break;
case ADD: {
if (inputStorage.readUnsignedByte() != TYPE_COMPOUND) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "A compound object is needed for setting a new polygon.", outputStorage);
}
//readt itemNo
inputStorage.readInt();
std::string type;
if (!server.readTypeCheckingString(inputStorage, type)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The type must be given as a string.", outputStorage);
}
RGBColor col;
if (!server.readTypeCheckingColor(inputStorage, col)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The second polygon parameter must be the color.", outputStorage);
}
int value = 0;
if (!server.readTypeCheckingUnsignedByte(inputStorage, value)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The third polygon parameter must be 'fill' encoded as ubyte.", outputStorage);
}
bool fill = value != 0;
int layer = 0;
if (!server.readTypeCheckingInt(inputStorage, layer)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The fourth polygon parameter must be the layer encoded as int.", outputStorage);
}
PositionVector shape;
if (!server.readTypeCheckingPolygon(inputStorage, shape)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The fifth polygon parameter must be the shape.", outputStorage);
}
//
if (!shapeCont.addPolygon(id, type, col, (SUMOReal)layer,
Shape::DEFAULT_ANGLE, Shape::DEFAULT_IMG_FILE, shape, fill)) {
delete p;
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "Could not add polygon.", outputStorage);
}
}
break;
case REMOVE: {
int layer = 0; // !!! layer not used yet (shouldn't the id be enough?)
if (!server.readTypeCheckingInt(inputStorage, layer)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "The layer must be given using an int.", outputStorage);
}
if (!shapeCont.removePolygon(id)) {
return server.writeErrorStatusCmd(CMD_SET_POLYGON_VARIABLE, "Could not remove polygon '" + id + "'", outputStorage);
}
}
break;
default:
//.........这里部分代码省略.........