13 namespace datastructure {
61 if ((x > -INFINITY) && (x < INFINITY) &&
62 (y > -INFINITY) && (y < INFINITY)) {
67 throw "Invalid points for polyline!";
93 bbox[0] = bbox[1] = INFINITY;
94 bbox[2] = bbox[3] = -INFINITY;
95 for (
int k = 0; k < points.size(); k += 2) {
96 if (points[k] < bbox[0])
98 if (points[k] > bbox[2])
100 if (points[k + 1] < bbox[1])
101 bbox[1] = points[k + 1];
102 if (points[k + 1] > bbox[3])
103 bbox[3] = points[k + 1];
105 center[0] = bbox[0] + (bbox[2] - bbox[0]) / 2.;
106 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);
Polyline(vector< float > pts)
Construct a polyline from sequence of points.
Definition: Polyline.h:42
const string COLON
Definition: DataStructure.h:51
const string OPEN_BOX
Definition: DataStructure.h:54
const string CLOSE_CURLY
Definition: DataStructure.h:53
This class defines a polyline and is part of the symbol collection. A polyline has a set of vertices ...
Definition: Polyline.h:24
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:32
virtual string getShapeType() const override
This method gets the type of the shape.
Definition: Polyline.h:51
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
void getCenter(float *center)
Get center of polyline - use its bounding box.
Definition: Polyline.h:91
const string CLOSE_BOX
Definition: DataStructure.h:55
void setPolyline(vector< float > pts)
Construct a polyline from sequence of points.
Definition: Polyline.h:83
const string getSymbolRepresentation() const override
This method returns the JSON representation of the shape.
Definition: Polyline.h:115
void addPoint(float x, float y)
This method adds a point to the polyline.
Definition: Polyline.h:60
vector< float > getPoints()
This method returns the point list of the polyline.
Definition: Polyline.h:75
Polyline()
default constructor
Definition: Polyline.h:34
vector< float > points
Definition: Polyline.h:28
const string COMMA
Definition: DataStructure.h:50
const string QUOTE
Definition: DataStructure.h:49