42 const std::map<int, std::string>& predefinedTagsMML,
43 const std::string& objectType,
47 unsigned char attrByte;
53 attr += 256 * attrByte;
55 int type = in->
peek();
74 const int type = in->
peek();
78 throw ProcessError(
"Invalid binary file, only supporting position vectors.");
88 *in >> myIntValues[attr];
91 *in >> myIntValues[attr];
93 *in >> myCharValues[attr];
114 *in >> myIntValues[attr];
117 *in >> myCharValues[attr];
120 *in >> myCharValues[attr];
123 std::ostringstream into(std::ios::binary);
129 int intsToRead = size - 1;
134 if (bitsOrEntry < 0) {
135 intsToRead = (-bitsOrEntry * (size - 1) - 1) /
sizeof(int) / 8 + 2;
137 while (intsToRead > 0) {
144 myStringValues[attr] = into.str();
148 throw ProcessError(
"Binary file is invalid, attribute type is unknown.");
167 const std::map<int, char>::const_iterator i =
myCharValues.find(
id);
171 return i->second != 0;
177 const std::map<int, int>::const_iterator i =
myIntValues.find(
id);
193 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
203 const std::string& str)
const {
204 const std::map<int, std::string>::const_iterator i =
myStringValues.find(
id);
214 const std::map<int, double>::const_iterator i =
myFloatValues.find(
id);
236 const std::string& )
const {
245 const char func = i->second;
259 const char type = i->second;
301 const int val = i->second;
302 return RGBColor(val & 0xff, (val >> 8) & 0xff, (val >> 16) & 0xff, (val >> 24) & 0xff);
308 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
318 const std::map<int, PositionVector>::const_iterator i =
myPositionVectors.find(attr);
322 if (i->second.size() != 2) {
325 return Boundary(i->second[0].x(), i->second[0].y(), i->second[1].x(), i->second[1].y());
340 for (std::set<int>::const_iterator i =
myAttrs.begin(); i !=
myAttrs.end(); ++i) {
346 std::vector<std::string>
348 std::vector<std::string> result;
349 for (std::set<int>::const_iterator i =
myAttrs.begin(); i !=
myAttrs.end(); ++i) {
358 std::map<std::string, std::string> attrs;
360 const std::string attrName =
myAttrIds.find(it->first)->second;
361 attrs[attrName] =
toString(it->second);
364 const std::string attrName =
myAttrIds.find(it->first)->second;
365 attrs[attrName] =
toString(it->second);
368 const std::string attrName =
myAttrIds.find(it->first)->second;
369 attrs[attrName] =
toString(it->second);
372 const std::string attrName =
myAttrIds.find(it->first)->second;
373 attrs[attrName] = it->second;
376 const std::string attrName =
myAttrIds.find(it->first)->second;
377 attrs[attrName] =
toString(it->second);
static StringBijection< RightOfWay > RightOfWayValues
righ of way algorithms
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
static StringBijection< SumoXMLNodeType > NodeTypes
node types
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
std::map< int, char > myCharValues
Map of attribute ids to char.
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
std::map< int, double > myFloatValues
Map of attribute ids to floats.
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...
const std::string & getObjectType() const
return the objecttype to which these attributes belong
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
Encapsulated Xerces-SAX-attributes.
std::map< int, std::string > myStringValues
Map of attribute ids to string.
RightOfWay
algorithms for computing right of way
A class that stores a 2D geometrical boundary.
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
How to compute right of way.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Encapsulated SAX-Attributes.
static double toDouble(const std::string &sData)
converts a string into the double value described by it by calling the char-type converter ...
A point in 2D or 3D with translation and scaling methods.
const std::map< int, std::string > & myAttrIds
Map of attribute ids to names.
T get(const std::string &str) const
static std::ostream & writeInt(std::ostream &strm, int value)
Writes an integer binary.
FringeType getFringeType(bool &ok) const
returns fringe type
static std::ostream & writeByte(std::ostream &strm, unsigned char value)
Writes a byte binary.
RGBColor getColor() const
Returns the value of the named attribute.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
std::map< int, int > myIntValues
Map of attribute ids to integers.
std::map< int, PositionVector > myPositionVectors
Map of attribute ids to string.
std::set< int > myAttrs
the attributes which are set
static StringBijection< FringeType > FringeTypeValues
fringe types
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
SUMOSAXAttributesImpl_Binary(const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType, BinaryInputDevice *in, const char version)
Constructor.
static long long int toLong(const std::string &sData)
converts a string into the long value described by it by calling the char-type converter, which
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
virtual ~SUMOSAXAttributesImpl_Binary()
Destructor.
FringeType
algorithms for computing right of way
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
static StringBijection< SumoXMLEdgeFunc > EdgeFunctions
edge functions
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.