12 namespace datastructure {
32 virtual string getShapeType()
const override {
62 if ((x > -INFINITY) && (x < INFINITY) &&
63 (y > -INFINITY) && (y < INFINITY)) {
68 throw "Invalid points for polyline!";
94 bbox[0] = bbox[1] = INFINITY;
95 bbox[2] = bbox[3] = -INFINITY;
96 for (
int k = 0; k < points.size(); k += 2) {
97 if (points[k] < bbox[0])
99 if (points[k] > bbox[2])
101 if (points[k + 1] < bbox[1])
102 bbox[1] = points[k + 1];
103 if (points[k + 1] > bbox[3])
104 bbox[3] = points[k + 1];
106 center[0] = bbox[0] + (bbox[2] - bbox[0]) / 2.;
107 center[1] = bbox[1] + (bbox[3] - bbox[1]) / 2.;
117 string shape_json = getSymbolAttributeRepresentation();
118 string shape = getShapeType();
122 vector<float>::iterator it;
123 for (
int k = 0; k < points.size(); k++) {
124 shape_json += to_string(points[k]) +
COMMA;
129 shape_json.erase(shape_json.size() - 1);
This class defines a polyline and is part of the symbol collection. A polyline has a set of vertices ...
Definition: Polyline.h:23
void addPoint(float x, float y)
This method adds a point to the polyline.
Definition: Polyline.h:61
vector< float > points
Definition: Polyline.h:38
Polyline()
default constructor
Definition: Polyline.h:44
vector< float > getPoints()
This method returns the point list of the polyline.
Definition: Polyline.h:76
void setPolyline(vector< float > pts)
Construct a polyline from sequence of points.
Definition: Polyline.h:84
const string getSymbolRepresentation() const override
This method returns the JSON representation of the shape.
Definition: Polyline.h:115
Polyline(vector< float > pts)
Construct a polyline from sequence of points.
Definition: Polyline.h:52
void getCenter(float *center)
Get center of polyline - use its bounding box.
Definition: Polyline.h:92
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:31
Support for drawing Bar charts.
Definition: alltypes.h:4
const string COLON
Definition: DataStructure.h:52
const string OPEN_BOX
Definition: DataStructure.h:55
const string COMMA
Definition: DataStructure.h:51
const string CLOSE_BOX
Definition: DataStructure.h:56
const string CLOSE_CURLY
Definition: DataStructure.h:54
const string QUOTE
Definition: DataStructure.h:50