svg_path_generator<OutputIterator,Path>::svg_path_generator() : svg_path_generator::base_type(svg) { boost::spirit::karma::uint_type uint_; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::lit_type lit; svg = point | linestring | polygon ; point = &uint_(mapnik::geometry::geometry_types::Point)[_1 = _type(_val)] << svg_point [_1 = _first(_val)] ; svg_point = &uint_ << lit("cx=\"") << coordinate << lit("\" cy=\"") << coordinate << lit('\"') ; linestring = &uint_(mapnik::geometry::geometry_types::LineString)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; polygon = &uint_(mapnik::geometry::geometry_types::Polygon)[_1 = _type(_val)] << lit("d=\"") << svg_path << lit("\"") ; svg_path %= ((&uint_(mapnik::SEG_MOVETO) << lit('M') | &uint_(mapnik::SEG_LINETO) << lit('L')) << coordinate << lit(' ') << coordinate) % lit(' ') ; }
wkt_generator<OutputIterator, Geometry>::wkt_generator(bool single) : wkt_generator::base_type(wkt) { boost::spirit::karma::uint_type uint_; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::lit_type lit; boost::spirit::karma::_a_type _a; boost::spirit::karma::_b_type _b; boost::spirit::karma::_c_type _c; boost::spirit::karma::_r1_type _r1; boost::spirit::karma::eps_type eps; boost::spirit::karma::string_type kstring; wkt = point | linestring | polygon ; point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << kstring[ phoenix::if_ (single) [_1 = "Point("] .else_[_1 = "("]] << point_coord [_1 = _first(_val)] << lit(')') ; linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << kstring[ phoenix::if_ (single) [_1 = "LineString("] .else_[_1 = "("]] << coords << lit(')') ; polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << kstring[ phoenix::if_ (single) [_1 = "Polygon("] .else_[_1 = "("]] << coords2 << lit("))") ; point_coord = &uint_ << coordinate << lit(' ') << coordinate ; polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1][_a = _x(_val)][ _b = _y(_val)] << kstring[ if_ (_r1 > 1) [_1 = "),("] .else_[_1 = "("]] | &uint_(mapnik::SEG_LINETO) << lit(',') << eps[_a = _x(_val)][_b = _y(_val)] ) << coordinate[_1 = _a] << lit(' ') << coordinate[_1 = _b] ; coords2 %= *polygon_coord(_a,_b,_c) ; coords = point_coord % lit(',') ; }
geometry_generator_grammar() : geometry_generator_grammar::base_type(coordinates) { boost::spirit::karma::uint_type uint_; boost::spirit::bool_type bool_; boost::spirit::karma::_val_type _val; boost::spirit::karma::_1_type _1; boost::spirit::karma::lit_type lit; boost::spirit::karma::_a_type _a; boost::spirit::karma::_r1_type _r1; boost::spirit::karma::eps_type eps; boost::spirit::karma::string_type kstring; coordinates = point | linestring | polygon ; point = &uint_(mapnik::geometry_type::types::Point)[_1 = _type(_val)] << point_coord [_1 = _first(_val)] ; linestring = &uint_(mapnik::geometry_type::types::LineString)[_1 = _type(_val)] << lit('[') << coords << lit(']') ; polygon = &uint_(mapnik::geometry_type::types::Polygon)[_1 = _type(_val)] << lit('[') << coords2 << lit("]]") ; point_coord = &uint_ << lit('[') << coord_type << lit(',') << coord_type << lit(']') ; polygon_coord %= ( &uint_(mapnik::SEG_MOVETO) << eps[_r1 += 1] << kstring[ if_ (_r1 > 1) [_1 = "],["] .else_[_1 = '[' ]] | &uint_(mapnik::SEG_LINETO) << lit(',')) << lit('[') << coord_type << lit(',') << coord_type << lit(']') ; coords2 %= *polygon_coord(_a) ; coords = point_coord % lit(',') ; }
int MovingObject::status() { printf("Method: %c\n", _method); printf("First: %d - Last: %d\n", _first(), _last); printf("RealQueueSize: %d\n", _realQueueSize); printf("Filled: %s\n", _filled?"true":"false"); printf("Valorized: %s\n", _valorized()?"true":"false"); int i, count; if (_valorized()) { for(i=_first(), count=0; _filled?count<_realQueueSize:i<=_last; i++, count++) { i=i%_realQueueSize; printf(" Values[%d]: %f, %f\n", i, _lastValues_X[i], _lastValues_Y[i]); } } printf("Distance: %f\n", coveredDistance()); printf("Speed: %f\n", speed()); printf("Direction: %f\n", direction()*180/PI); printf("---\n"); return 0; }
float MovingObject::_getMA(float *v) { float sum=0; int i, count; int coeff; int den=0; if (_valorized()) { for(i=_first(), count=0; _filled?count<_realQueueSize:i<=_last; i++, count++) { i=i%_realQueueSize; coeff=_method=='s'?1:count+1; den+=coeff; sum+=v[i]*coeff; } return sum/den; } }
MalVal *EVAL(MalVal *ast, GHashTable *env) { if (!ast || mal_error) return NULL; //g_print("EVAL: %s\n", _pr_str(ast,1)); if (ast->type != MAL_LIST) { return eval_ast(ast, env); } if (!ast || mal_error) return NULL; // apply list //g_print("EVAL apply list: %s\n", _pr_str(ast,1)); if (_count(ast) == 0) { return ast; } MalVal *a0 = _nth(ast, 0); assert_type(a0, MAL_SYMBOL, "Cannot invoke %s", _pr_str(a0,1)); MalVal *el = eval_ast(ast, env); if (!el || mal_error) { return NULL; } MalVal *(*f)(void *, void*) = (MalVal *(*)(void*, void*))_first(el); //g_print("eval_invoke el: %s\n", _pr_str(el,1)); return f(_nth(el, 1), _nth(el, 2)); }
float MovingObject::_first_Y() { return _lastValues_Y[_first()]; }