17 namespace datastructure {
38 string name = string();
40 string shape_type =
"circle";
45 float default_location[2] = {0.0f, 0.0f};
46 Color default_fill_color{
"blue"};
47 Color default_stroke_color{
"white"};
48 int default_stroke_dash = 1;
49 float default_opacity = 1.0f;
50 float default_stroke_width = 1.0f;
51 string default_symbol =
"circle";
52 int default_font_size = 12;
56 string label = string();
57 Color fillColor{
"blue"},
60 float strokeWidth = 1.0f;
66 float location[2] = {0.0f, 0.0f};
69 int getNewIdentifier() {
100 identifier = getNewIdentifier();
106 virtual const string getSymbolRepresentation()
const = 0;
112 virtual vector<float> getDimensions()
const = 0;
120 identifier = getNewIdentifier();
168 fillColor =
Color(c);
194 strokeColor =
Color(c);
212 if (strokeWidth < 0.0f)
213 throw "Stroke width must be positive or null";
215 strokeWidth = strk_width;
233 if (op < 0.0f || op > 1.0f)
234 throw "Opacity must be between 0 and 1";
254 if (dash < 0 || dash > 10)
255 throw "Dash must be between 0 and 10 (inclusive)";
276 setLocation(
float(x),
float(y));
286 setLocation(
float(x),
float(y));
307 if ((x > -INFINITY && x < INFINITY) &&
308 (y > -INFINITY && y < INFINITY)) {
313 throw "Coordinates must be real numbers";
364 float angle_r = angle *
M_PI / 180.;
365 float c = cos(angle_r);
366 float s = sin(angle_r);
369 float tmp[] = { pt[0]*c - pt[1]*s, tmp[1] = pt[0] * s + pt[1] * c};
390 if (fillColor.getRepresentation() !=
391 default_fill_color.getRepresentation()) {
393 fillColor.getCSSRepresentation() +
COMMA;
396 if (opacity != default_opacity) {
398 to_string(opacity) +
COMMA;
401 if (strokeColor.getRepresentation() !=
402 default_stroke_color.getRepresentation()) {
404 strokeColor.getCSSRepresentation() +
COMMA;
407 if (strokeWidth != default_stroke_width) {
409 to_string(strokeWidth) +
COMMA;
412 if (strokeDash != default_stroke_dash) {
414 to_string(strokeDash) +
COMMA;
417 if (location[0] != default_location[0] ||
418 location[1] != default_location[1]) {
422 to_string(location[0]) +
COMMA +
424 to_string(location[1]) +
428 return symbol_attr_json;
void setLocation(double x, double y)
This method sets the symbol location.
Definition: Symbol.h:285
void setLabel(string lbl)
Set the symbol label.
Definition: Symbol.h:140
void setStrokeColor(Color c)
Definition: Symbol.h:184
Color getStrokeColor()
This method gets stroke color.
Definition: Symbol.h:202
const string COLON
Definition: DataStructure.h:51
void scalePoint(float *pt, float sx, float sy)
Scale a 2D point.
Definition: Symbol.h:351
const float * getLocation() const
This method gets the symbol location.
Definition: Symbol.h:320
#define M_PI
Definition: OSMData.h:13
void setLocation(int x, int y)
This method sets the symbol location.
Definition: Symbol.h:275
void setOpacity(float op)
This method sets the symbol opacity.
Definition: Symbol.h:232
void rotatePoint(float *pt, float angle)
Rotate a 2D point (about Z)
Definition: Symbol.h:362
void setStrokeColor(string c)
This method sets the symbol stroke color.
Definition: Symbol.h:193
Symbol()
default constructor
Definition: Symbol.h:99
const string CLOSE_CURLY
Definition: DataStructure.h:53
void setFillColor(string c)
This method sets the symbol fill color.
Definition: Symbol.h:167
string getLabel() const
Get the symbol label.
Definition: Symbol.h:149
This is an abstract class for deriving a number of Symbol shape objects, for use in a SymbolCollectio...
Definition: Symbol.h:33
void translatePoint(float *pt, float tx, float ty)
Translate a 2D point.
Definition: Symbol.h:340
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.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 setLocation(float x, float y)
This method sets the ssymbol location.
Definition: Symbol.h:306
const string OPEN_CURLY
Definition: DataStructure.h:52
const string getSymbolAttributeRepresentation() const
Get the JSON of the symbol representation.
Definition: Symbol.h:384
void setCenter(float x, float y)
This method sets the symbol location.
Definition: Symbol.h:296
int getStrokeDash()
This method gets stroke dash level.
Definition: Symbol.h:265
Symbol(string symb)
Create a symbol of type "symb".
Definition: Symbol.h:119
string getName() const
This method gets the name of the symbol.
Definition: Symbol.h:329
float getOpacity()
This method gets symbol opacity.
Definition: Symbol.h:244
void setShapeType(string s)
Set the shape type.
Definition: Symbol.h:82
void setFillColor(Color c)
Set the symbol fill color.
Definition: Symbol.h:159
const string COMMA
Definition: DataStructure.h:50
float getStrokeWidth()
This method gets stroke width.
Definition: Symbol.h:223
Color getFillColor()
This method gets fill color.
Definition: Symbol.h:175
const string QUOTE
Definition: DataStructure.h:49
int getIdentifier()
return the symbol identifier.
Definition: Symbol.h:131
string getShapeType() const
Definition: Symbol.h:90
void setStrokeDash(int dash)
This method sets the stroke dash level.
Definition: Symbol.h:253
void setStrokeWidth(float strk_width)
This method sets the symbol stroke width.
Definition: Symbol.h:211