Evt_Draw_Circle.prototype=new Event();function Evt_Draw_Circle(a){this._w=0;this._h=0;this._jg=new jsGraphics(_MAP_ID);this._autoclear=a;this._radius=0;this._map_coords=new Array(0,0);this._click_point=null;this._draw_tmp_line=false}Evt_Draw_Circle.prototype.mouse_over=function(b){try{Event.prototype.mouse_over(b);if(!this._draw_tmp_line){var d=_MAP_WRAPPER.convert_to_relative_pixel_coords(b.clientX,b.clientY);var a=_MAP_WRAPPER.convert_to_geo(d[0],d[1]);if(this._map_coords[0]!=a[0]||this._map_coords[1]!=a[1]){this._map_coords=a;_MAP_WRAPPER.clear_snap_point();this.do_operation(new Point(a[0],a[1]));_GENERIC_GIS_UTILS.snap_point_on_layers(d)}}}catch(c){throw"Evt_Draw_Circle.mouse_over(): "+c}};Evt_Draw_Circle.prototype.mouse_down=function(a){try{Event.prototype.mouse_down(a);this._draw_tmp_line=true;stop_propagating_event(a)}catch(b){throw"Evt_Draw_Circle.mouse_down(): "+b}};Evt_Draw_Circle.prototype.mouse_move=function(b){try{var d=_MAP_WRAPPER.convert_to_relative_pixel_coords(b.clientX,b.clientY);var a=_MAP_WRAPPER.convert_to_geo(d[0],d[1]);if(this._map_coords[0]!=a[0]||this._map_coords[1]!=a[1]){this._map_coords=a;_MAP_WRAPPER.clear_snap_point();this.do_operation(new Point(a[0],a[1]));_GENERIC_GIS_UTILS.snap_point_on_layers(d)}stop_propagating_event(b)}catch(c){throw"Evt_Draw_Circle.mouse_move(): "+c}};Evt_Draw_Circle.prototype.mouse_up=function(a){try{_MAP_WRAPPER.clear_snap_point();if(!this._map_loading&&this._autoclear){clear_extra_graphics(_EVENTS_DRAWING_ENGINE);this._jg.clear()}this._draw_tmp_line=false}catch(b){throw"Evt_Draw_Circle.mouse_up(): "+b}};Evt_Draw_Circle.prototype.do_operation=function(i){try{if(!this._draw_tmp_line){this._click_point=i}else{var h=0;var g=0;var c=_MAP_WRAPPER.convert_to_pixel(this._click_point._x,this._click_point._y,true);var a=_MAP_WRAPPER.convert_to_pixel(i._x,i._y,true);var j=new Array();j[0]=a[0]-c[0];j[1]=a[1]-c[1];var b=Math.sqrt(Math.pow(j[0],2)+Math.pow(j[1],2))*2;var d=new Array();d[0]=j[0]/b;d[1]=j[1]/b;h=d[0]<=0?c[0]-(b/2):c[0]-(b/2);g=d[1]<=0?c[1]-(b/2):c[1]-(b/2);this._radius=Math.sqrt(Math.pow((i._x-this._click_point._x),2)+Math.pow(i._y-this._click_point._y,2)).toFixed(_COORDINATE_PRECISION);if(!this._map_loading){_OP_USER._jg.clear();_OP_USER._jg=new jsGraphics(_MAP_ID);_OP_USER._jg.drawString(this._radius+" m",a[0]+10,a[1]-10);_OP_USER._jg.setColor("#fe8c01");_OP_USER._jg.drawLine(parseInt(c[0]),parseInt(c[1]),parseInt(a[0]),parseInt(a[1]));_OP_USER._jg.drawEllipse(h,g,b,b);_OP_USER._jg.paint()}}if(!this._map_loading){clear_extra_graphics(_EVENTS_DRAWING_ENGINE);draw_extra_graphics_object(false,i,_EVENTS_DRAWING_ENGINE)}}catch(f){throw"Evt_Draw_Circle.do_operation(): "+f}};Evt_Draw_Circle.prototype.get_radius=function(){return this._radius};Evt_Draw_Circle.prototype.get_center=function(){return _MAP_WRAPPER.convert_to_geo(this._x_click,this._y_click)};
