var _GENERIC_GIS_UTILS=new Generic_GIS_Utils();function generic_gis_toolbar_handler(b){try{switch(b){case"toolbar_select":set_map_cursor("pointer");register_mouse_down_handler(evt_select_geometry);break;case"toolbar_query":set_map_cursor("pointer");register_mouse_down_handler(evt_query_geometry);break;case"toolbar_save":evt_but_save_geometry();break;case"toolbar_delete":evt_but_delete_geometry();break;case"toolbar_pan":set_map_cursor("move");register_mouse_down_handler(evt_event_move);break;case"toolbar_zoomin":set_map_cursor("crosshair");register_mouse_down_handler(evt_event_zoomin);break;case"toolbar_zoomout":set_map_cursor("crosshair");register_mouse_down_handler(evt_event_zoomout);break;case"toolbar_zoomback":evt_but_zoomback();break;case"toolbar_fullextent":_MAP_WRAPPER.recenter_map();break;case"toolbar_print":evt_but_print();break;case"toolbar_undo_draw":_GENERIC_GIS_UTILS.undo_draw_operation();break;case"toolbar_draw_point":set_map_cursor("crosshair");register_mouse_down_handler(evt_draw_point);change_system_status(new Evt_Draw_Point());break;case"toolbar_draw_line":set_map_cursor("crosshair");register_mouse_down_handler(evt_draw_line);change_system_status(new Evt_Draw_Line());break;case"toolbar_add_vertex":set_map_cursor("crosshair");register_mouse_down_handler(evt_add_vertex);change_system_status(new Evt_Add_Vertex());break;case"toolbar_add_arc":set_map_cursor("crosshair");register_mouse_down_handler(evt_add_arc);change_system_status(new Evt_Add_Arc());break;case"toolbar_delete_vertex":set_map_cursor("pointer");register_mouse_down_handler(evt_delete_vertex);break;case"toolbar_select_vertex":set_map_cursor("pointer");register_mouse_down_handler(evt_select_vertex);break;case"toolbar_move_vertex":set_map_cursor("crosshair");register_mouse_down_handler(evt_move_vertex);change_system_status(new Evt_Move_Vertex());break;case"toolbar_add_ring":evt_but_add_ring();break;case"toolbar_add_island":evt_but_add_island();break;case"toolbar_move_feature":set_map_cursor("move");register_mouse_down_handler(evt_move_feature);break;case"toolbar_select_segment":set_map_cursor("pointer");register_mouse_down_handler(evt_select_polygon_segment);break;case"toolbar_copy":evt_but_copy_geometry();break;case"toolbar_paste":evt_but_paste_geometry();break;case"toolbar_clear":reset_extra_graphics(_ALL_DRAWING_ENGINES);break}}catch(a){alert("Generic_GIS_Events_Manager.generic_gis_toolbar_handler(id): "+a)}}function generic_gis_menu_file_handler(b){try{switch(b){case"menu_file_home":window.location.href=_UI_HOME;break;case"menu_file_projects":_GENERIC_GIS_UTILS.open_new_window(_UI_PROJECTS,get_width(0.5),get_height(0.6),true,false);break;case"menu_file_manager":_GENERIC_GIS_UTILS.open_new_window(_UI_FILE_MANAGER,get_width(0.8),get_height(0.8),true,false);break;case"menu_file_map_visio":loading_message(true);window.location.href=_URL_MAP_VISIO.replace("https://","http://");break;case"menu_file_print":evt_but_print();break;case"menu_file_planimetry":evt_but_open_planimetry(false,"A4","PDF",500,"");break;case"menu_file_plot":reset_extra_graphics(_ALL_DRAWING_ENGINES);set_map_cursor("crosshair");generic_gis_toolbar_select_button(null);register_mouse_down_handler(evt_create_plot);break;case"menu_file_logout":window.location.href=_UI_LOGIN;break}}catch(a){alert("Generic_GIS_Events_Manager.generic_gis_menu_file_handler(id): "+a)}}function generic_gis_menu_modify_handler(f){try{switch(f){case"menu_modify_copy":evt_but_copy_geometry();break;case"menu_modify_paste":evt_but_paste_geometry();break;case"menu_modify_update_attributes":if(_LIST_OF_SELECTED_OBJECTS.length==0){alert("Selezionare una o più Geometrie dello stesso Livello!");return}else{if(_LIST_OF_SELECTED_OBJECTS.length==1){_GENERIC_GIS_UTILS.open_new_window(_UI_ATTRIBUTES+"?type=attributes&action=update&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry+"&layer_name="+_LIST_OF_SELECTED_OBJECTS[0]._layer_name,get_width(0.6),get_height(0.7),true,true)}else{var b=_LIST_OF_SELECTED_OBJECTS[0]._layer_name;var d=new Array(_LIST_OF_SELECTED_OBJECTS[0]._id_geometry);for(var a=1;a<_LIST_OF_SELECTED_OBJECTS.length;a++){d.push(_LIST_OF_SELECTED_OBJECTS[a]._id_geometry);if(_LIST_OF_SELECTED_OBJECTS[a]._layer_name!=b){alert("Le Geometrie selezionate non sono dello stesso Livello!");return}}_GENERIC_GIS_UTILS.open_new_window(_UI_ATTRIBUTES+"?type=attributes&action=update_block&list_of_id_geometry="+d.toString()+"&layer_name="+b,get_width(0.6),get_height(0.7),true,true)}}break}}catch(c){alert("Generic_GIS_Events_Manager.generic_gis_menu_modify_handler(id): "+c)}}function generic_gis_menu_layers_handler(d){try{switch(d){case"menu_layers_vector_layer":_GENERIC_GIS_UTILS.open_new_window(_UI_ADD_VECTOR_LAYER+"?type=project&action=add_vector_layer",500,500,true,false);break;case"menu_layers_database_layer":_GENERIC_GIS_UTILS.open_new_window(_UI_ADD_DATABASE_LAYER+"?type=project&action=add_database_layer",600,500,true,false);break;case"menu_layers_zoom_to_layer_extension":case"context_menu_zoom_to_layer_extension":if(!_MAP_WRAPPER.check_is_layer_selected()){return}_MAP_WRAPPER.abort_loading_map();var c="type=map&action=zoom_to_layer_extension&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;loading_message(true);process_ajax_call(c,_CNTR_EVENTS_URL,function(f){try{if(!f){_MAP_WRAPPER.update_map(this.responseXML)}else{loading_message(false)}}catch(g){alert("process_ajax_call: "+g);loading_message(false)}});break;case"menu_layers_create_vertex_layer":case"context_menu_create_vertex_layer":if(!_MAP_WRAPPER.check_is_layer_selected()){return}var c="type=layer&action=create_vertex_layer&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;loading_message(true);process_ajax_call(c,_CNTR_LAYER_EDITOR,function(f){try{if(!f){var h=this.responseXML.getElementsByTagName("id_layer")[0].firstChild.nodeValue;_MAP_WRAPPER.load_layers(new Array(h))}else{loading_message(false)}}catch(g){alert("process_ajax_call: "+g);loading_message(false)}});break;case"menu_layers_copy_layer":if(!_MAP_WRAPPER.check_is_layer_selected()){return}var c="type=layer&action=copy&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;loading_message(true);process_ajax_call(c,_CNTR_LAYER_EDITOR,function(f){try{if(!f){var h=this.responseXML.getElementsByTagName("id_layer")[0].firstChild.nodeValue;_MAP_WRAPPER.load_layers(new Array(h))}else{loading_message(false)}}catch(g){alert("process_ajax_call: "+g);loading_message(false)}});break;case"menu_layers_delete_layer":case"context_menu_delete_layer":if(!_MAP_WRAPPER.check_is_layer_selected()){return}if(confirm("Eliminare Layer?")){var a=_MAP_WRAPPER.get_selected_layer();var c="type=map&action=remove_layer&layer_name="+a._name;loading_message(true);process_ajax_call(c,_CNTR_MAP_URL,function(f){try{if(!f){_MAP_WRAPPER.remove_layer(a);if(a._active){_MAP_WRAPPER.reload_map()}else{loading_message(false)}_GUI_FACTORY.create_gui_command("update_layers_panel").execute()}else{loading_message(false)}}catch(g){alert("process_ajax_call: "+g);loading_message(false)}})}break;case"menu_layers_attributes":case"context_menu_attributes":if(!_MAP_WRAPPER.check_is_layer_selected()){return}if(_MAP_WRAPPER.check_is_layer_measure(_MAP_WRAPPER.get_selected_layer())){alert("Attributi non possibili su Livello Misurazioni!");return}_GENERIC_GIS_UTILS.open_new_window(_UI_TABLE_ATTRIBUTES+"?type=attributes&action=load&layer_name="+_MAP_WRAPPER.get_selected_layer()._name,get_width(0.6),get_height(0.8),true,false);break;case"menu_layers_save_order":var c="type=map&action=save_layers_classes_order";loading_message(true);process_ajax_call(c,_CNTR_MAP_URL,function(f){try{if(!f){alert("Ordine Livelli/Classi salvato correttamente!");loading_message(false)}else{loading_message(false)}}catch(g){alert("process_ajax_call: "+g);loading_message(false)}});break;case"menu_layers_property":case"context_menu_property":if(!_MAP_WRAPPER.check_is_layer_selected()){return}_GENERIC_GIS_UTILS.open_new_window(_UI_LAYER+"?type=layer&action=update&id_layer="+_MAP_WRAPPER.get_selected_layer()._id,get_width(0.45),get_height(0.9),true,false);break;case"context_menu_class_property":_GENERIC_GIS_UTILS.open_new_window(_UI_CLASS_PARAMETERS+"?type=class&action=update&id_class="+_MAP_WRAPPER.get_selected_layer().get_selected_class()._id+"&id_layer="+_MAP_WRAPPER.get_selected_layer()._id,get_width(0.45),get_height(0.9),true,false);break}}catch(b){alert("Generic_GIS_Events_Manager.generic_gis_menu_layers_handler(id): "+b)}}function generic_gis_menu_digitalize_handler(A){try{switch(A){case"menu_digitization_draw_point":generic_gis_toolbar_select_button("toolbar_draw_point");set_map_cursor("crosshair");register_mouse_down_handler(evt_draw_point);change_system_status(new Evt_Draw_Point());break;case"menu_digitization_draw_line":generic_gis_toolbar_select_button("toolbar_draw_line");set_map_cursor("crosshair");register_mouse_down_handler(evt_draw_line);change_system_status(new Evt_Draw_Line());break;case"menu_digitization_arc_2_points":if(_LIST_OF_POINTS.length==0){alert(_MSG_SET_POINT);return}var o=configure_line_path_object();o._optimized_drawing=false;var t=null;var C=0;var s=o._list_of_graphics.length;var M=null;var J=null;var I=null;if(s>0){var O=o._list_of_graphics[s-1];var g=o._list_of_graphics[0];if(_SELECTED_VERTEX!=null){var y=o.get_nearest_vertex_to_point(_SELECTED_VERTEX);if(g.constructor==Line&&O.constructor==Line){if(g._p1.equals(y)||g._p2.equals(y)){M=_LIST_OF_POINTS[0].clone();J=g._p1.clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.splice(0,0,t)}else{M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.push(t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(g.constructor==Arc&&O.constructor==Line){if(g._p1.equals(y)||g._p3.equals(y)){M=_LIST_OF_POINTS[0].clone();J=(g._p1.equals(y))?g._p1.clone():g._p3.clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.splice(0,0,t)}else{M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.push(t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(g.constructor==Arc&&O.constructor==Arc){if(g._p1.equals(y)||g._p3.equals(y)){M=_LIST_OF_POINTS[0].clone();J=(g._p1.equals(y))?g._p1.clone():g._p3.clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.splice(0,0,t)}else{M=(O._p1.equals(y))?O._p1.clone():O._p3.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.splice(0,0,t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(g.constructor==Line&&O.constructor==Arc){if(g._p1.equals(y)||g._p2.equals(y)){M=_LIST_OF_POINTS[0].clone();J=g._p1.clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.splice(0,0,t)}else{M=(O._p1.equals(y))?O._p1.clone():O._p3.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o._list_of_graphics.splice(0,0,t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(O.constructor==Line){M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o.add_graphics(t)}else{if(O.constructor==Arc){M=O._p3.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o.add_graphics(t)}else{if(O.constructor==Circle){alert("Aggiungi Arco impossibile sui Cerchi!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}else{alert("Impossibile aggiungere l'Arco!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}}}}}}}}else{if(O.constructor==Line){M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o.add_graphics(t)}else{if(O.constructor==Arc){M=O._p3.clone();J=_LIST_OF_POINTS[0].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o.add_graphics(t)}else{if(O.constructor==Circle){alert("Aggiungi Arco impossibile sui Cerchi!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}else{alert("Impossibile aggiungere l'Arco!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}}}}}else{if(_LIST_OF_POINTS.length==1){alert(_MSG_SET_POINT);return}M=_LIST_OF_POINTS[0].clone();J=_LIST_OF_POINTS[1].clone();C=prompt(_MSG_SET_RADIUS);if(C==null){return}I=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,J,parseFloat(C));t=new Arc(M,I,J);o.add_graphics(t)}_GENERIC_GIS_UTILS.log_draw_operation("draw_arc",t.clone());clear_points(_SELECTION_DRAWING_ENGINE);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_digitization_arc_3_points":var t=null;if(_LIST_OF_POINTS.length==0){alert(_MSG_SET_POINT);return}var o=configure_line_path_object();o._optimized_drawing=false;var m=o._list_of_graphics.length;var M=null;var J=null;var I=null;if(m>0){if(_LIST_OF_POINTS.length<2){alert(_MSG_SET_2_POINTS);return}var O=o._list_of_graphics[m-1];var g=o._list_of_graphics[0];if(_SELECTED_VERTEX!=null){var y=o.get_nearest_vertex_to_point(_SELECTED_VERTEX);if(g.constructor==Line&&O.constructor==Line){if(g._p1.equals(y)||g._p2.equals(y)){M=_LIST_OF_POINTS[1].clone();J=_LIST_OF_POINTS[0].clone();I=g._p1.clone();t=new Arc(M,J,I);o._list_of_graphics.splice(0,0,t)}else{M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o._list_of_graphics.push(t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(g.constructor==Arc&&O.constructor==Line){if(g._p1.equals(y)||g._p3.equals(y)){M=_LIST_OF_POINTS[1].clone();J=_LIST_OF_POINTS[0].clone();I=(g._p1.equals(y))?g._p1.clone():g._p3.clone();t=new Arc(M,J,I);o._list_of_graphics.splice(0,0,t)}else{M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o._list_of_graphics.push(t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(g.constructor==Arc&&O.constructor==Arc){if(g._p1.equals(y)||g._p3.equals(y)){M=_LIST_OF_POINTS[1].clone();J=_LIST_OF_POINTS[0].clone();I=(g._p1.equals(y))?g._p1.clone():g._p3.clone();t=new Arc(M,J,I);o._list_of_graphics.splice(0,0,t)}else{M=(O._p1.equals(y))?O._p1.clone():O._p3.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o._list_of_graphics.splice(0,0,t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(g.constructor==Line&&O.constructor==Arc){if(g._p1.equals(y)||g._p2.equals(y)){M=_LIST_OF_POINTS[1].clone();J=_LIST_OF_POINTS[0].clone();I=g._p1.equals(y);t=new Arc(M,J,I);o._list_of_graphics.splice(0,0,t)}else{M=(O._p1.equals(y))?O._p1.clone():O._p3.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o._list_of_graphics.splice(0,0,t)}remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}else{if(O.constructor==Line){M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o.add_graphics(t)}else{if(O.constructor==Arc){M=O._p3.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o.add_graphics(t)}else{if(O.constructor==Circle){alert("Aggiungi Arco impossibile sui Cerchi!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}else{alert("Impossibile aggiungere l'Arco!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}}}}}}}}else{if(O.constructor==Line){M=O._p2.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o.add_graphics(t)}else{if(O.constructor==Arc){M=O._p3.clone();J=_LIST_OF_POINTS[0].clone();I=_LIST_OF_POINTS[1].clone();t=new Arc(M,J,I);o.add_graphics(t)}else{if(O.constructor==Circle){alert("Aggiungi Arco impossibile sui Cerchi!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}else{alert("Impossibile aggiungere l'Arco!");clear_points(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);return}}}}}else{if(_LIST_OF_POINTS.length<3){alert(_MSG_SET_3_POINTS);return}M=_LIST_OF_POINTS[0].clone();J=_LIST_OF_POINTS[1].clone();I=_LIST_OF_POINTS[2].clone();t=new Arc(M,J,I);o.add_graphics(t)}_GENERIC_GIS_UTILS.log_draw_operation("draw_arc",t.clone());clear_points(_SELECTION_DRAWING_ENGINE);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_digitization_circle_radius":if(_LIST_OF_POINTS.length<1){alert(_MSG_SET_POINT);return}var C=prompt(_MSG_RAY);if(C==""||isNaN(C)||parseFloat(C)==0){alert(_MSG_NUMERIC_VALUE_REQUIRED);return}var x=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",x);var n=new Circle(x,parseFloat(C));n._optimized_drawing=false;remove_from_extra_graphics(x,_SELECTION_DRAWING_ENGINE);var o=configure_line_path_object();o.add_graphics(n);_LIST_OF_EXTRA_GRAPHICS.push(n);_GENERIC_GIS_UTILS.log_draw_operation("draw_circle",n);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_digitization_circle_3_points":if(_LIST_OF_POINTS.length<3){alert(_MSG_SET_POINT);return}var I=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",I);var J=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",J);var M=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",M);var C=_GENERIC_GIS_UTILS.calculate_radius(M,J,I);var r=new Point((M._x+J._x)/2,(M._y+J._y)/2);var f=new Point((J._x+I._x)/2,(J._y+I._y)/2);var F=-1/((J._y-M._y)/(J._x-M._x));var u=-1/((I._y-J._y)/(I._x-J._x));var d=-F*r._x+r._y;var E=-u*f._x+f._y;var N=new Point(M._x,M._x*F+d);var q=new Point(J._x,J._x*u+E);var l=new Parametric_Line(r,N);var k=new Parametric_Line(f,q);var v=_GENERIC_GIS_UTILS.intersect_lines(l,k);var n=new Circle(v,C);n._optimized_drawing=false;remove_from_extra_graphics(I,_SELECTION_DRAWING_ENGINE);remove_from_extra_graphics(J,_SELECTION_DRAWING_ENGINE);remove_from_extra_graphics(M,_SELECTION_DRAWING_ENGINE);var o=configure_line_path_object();o.add_graphics(n);_LIST_OF_EXTRA_GRAPHICS.push(n);_GENERIC_GIS_UTILS.log_draw_operation("draw_circle",n);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_digitization_modify_radius":var o=configure_line_path_object();var m=o._list_of_graphics.length;var C=0;if(m>0){var O=o._list_of_graphics[m-1];if(_SELECTED_VERTEX!=null){o=_LINE_PATH;var b=o.get_line_paths_containing_point(_SELECTED_VERTEX);var p=false;for(var H=0;H<b.length;H++){var z=b[H].get_lines_containing_point(_SELECTED_VERTEX);for(var G=0;G<z.length;G++){var h=z[G];if(h instanceof Arc){if(h._p1.equals(_SELECTED_VERTEX)||h._p2.equals(_SELECTED_VERTEX)||h._p3.equals(_SELECTED_VERTEX)){var M=h._p1;var I=h._p3;C=prompt(_MSG_SET_RADIUS);if(C==null){continue}var J=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,I,parseFloat(C));_GENERIC_GIS_UTILS.log_draw_operation("modify_radius",new Array(h,h._p2.clone()));h._p2=J;h._optimized_drawing=false;p=true}}else{if(h instanceof Circle){var L=new Point(h._center._x-h._radius,h._center._y);var w=new Point(h._center._x,h._center._y+h._radius);var c=new Point(h._center._x+h._radius,h._center._y);var a=new Point(h._center._x,h._center._y-h._radius);if(L.equals(_SELECTED_VERTEX)||w.equals(_SELECTED_VERTEX)||c.equals(_SELECTED_VERTEX)||a.equals(_SELECTED_VERTEX)){C=prompt(_MSG_SET_RADIUS);if(C==null){continue}if(C==""||isNaN(C)||parseFloat(C)==0){alert(_MSG_NUMERIC_VALUE_REQUIRED);return}_GENERIC_GIS_UTILS.log_draw_operation("modify_radius",new Array(h,h._radius));h._radius=parseFloat(C);h._optimized_drawing=false;p=true}}}}}if(p){remove_from_extra_graphics(_SELECTED_VERTEX,_SELECTION_DRAWING_ENGINE);_SELECTED_VERTEX=null}}else{if(O.constructor==Arc){var M=O._p1;var I=O._p3;C=prompt(_MSG_SET_RADIUS);if(C==null){return}var J=_MAP_WRAPPER.calculate_circle_point_from_2_points(M,I,parseFloat(C));_GENERIC_GIS_UTILS.log_draw_operation("modify_radius",new Array(O,O._p2.clone()));O._p2=J;O._optimized_drawing=false}else{if(O.constructor==Circle){C=prompt(_MSG_SET_RADIUS);if(C==null){return}if(C==""||isNaN(C)||parseFloat(C)==0){alert(_MSG_NUMERIC_VALUE_REQUIRED);return}_GENERIC_GIS_UTILS.log_draw_operation("modify_radius",new Array(O,O._radius));O._radius=parseFloat(C);O._optimized_drawing=false}else{alert(_MSG_OBJECT_NOT_ARC);return}}}}else{alert(_MSG_OBJECT_NOT_ARC);return}clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_digitization_add_vertex":generic_gis_toolbar_select_button("toolbar_add_vertex");set_map_cursor("crosshair");register_mouse_down_handler(evt_add_vertex);change_system_status(new Evt_Add_Vertex());break;case"menu_digitization_add_arc":generic_gis_toolbar_select_button("toolbar_add_arc");set_map_cursor("crosshair");register_mouse_down_handler(evt_add_arc);change_system_status(new Evt_Add_Arc());break;case"menu_digitization_delete_vertex":generic_gis_toolbar_select_button("toolbar_delete_vertex");set_map_cursor("pointer");register_mouse_down_handler(evt_delete_vertex);break;case"menu_digitization_select_vertex":generic_gis_toolbar_select_button("toolbar_select_verted");set_map_cursor("pointer");register_mouse_down_handler(evt_select_vertex);break;case"menu_digitization_move_vertex":generic_gis_toolbar_select_button("toolbar_move_vertex");set_map_cursor("crosshair");register_mouse_down_handler(evt_move_vertex);change_system_status(new Evt_Move_Vertex());break;case"menu_digitization_add_ring":generic_gis_toolbar_select_button("toolbar_add_ring");evt_but_add_ring();break;case"menu_digitization_remove_ring":generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_remove_ring);break;case"menu_digitization_add_island":generic_gis_toolbar_select_button("toolbar_add_island");evt_but_add_island();break;case"menu_digitization_remove_island":generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_remove_island);break;case"menu_digitization_build_polar_figure":generic_gis_toolbar_select_button(null);change_system_status(new Idle());var D=_GENERIC_GIS_UTILS.open_new_window(_UI_POLAR_FIGURE_URL,250,100,true,false);var B=findPos(document.getElementById(_EVENTS_ID));D.move(get_width(1)-300,B[1]+10);break;case"menu_digitization_reverse_geometry":if(_LINE_PATH!=null){_LINE_PATH.reverse_geometry();_GENERIC_GIS_UTILS.log_draw_operation("reverse_geometry")}}}catch(K){alert("Generic_GIS_Events_Manager.generic_gis_menu_digitalize_handler(id): "+K)}}function generic_gis_menu_geometry_processing_handler(f){try{switch(f){case"menu_geometry_processing_select_polygon_segment":generic_gis_toolbar_select_button("toolbar_select_segment");set_map_cursor("pointer");register_mouse_down_handler(evt_select_polygon_segment);break;case"menu_geometry_processing":_GENERIC_GIS_UTILS.open_new_window(_UI_GEOMETRY_PROCESSOR+"?type=geometry_processing&action=process",get_width(0.4),get_height(0.4),true,true);break;case"menu_geometry_processing_cut_segment":if(_LIST_OF_SELECTED_OBJECTS.length==1&&_LIST_OF_SELECTED_OBJECTS[0]._type=="MULTICURVE"&&_LIST_OF_SELECTED_OBJECTS[0]._layer_name!=""&&(_SELECTED_VERTEX!=null||_LIST_OF_POINTS.length==1)){var d="type=geometry_processing&action=cut_segment&layer_name="+_LIST_OF_SELECTED_OBJECTS[0]._layer_name+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry;if(_SELECTED_VERTEX!=null){d+="&x="+_SELECTED_VERTEX._x+"&y="+_SELECTED_VERTEX._y}else{d+="&x="+_LIST_OF_POINTS[0]._x+"&y="+_LIST_OF_POINTS[0]._y}loading_message(true);process_ajax_call(d,_CNTR_GEOMETRY_PROCESSING,function(g){try{if(!g){alert("La geometria è stata tagliata correttamente!");reset_extra_graphics(_ALL_DRAWING_ENGINES);_MAP_WRAPPER.reload_map()}else{loading_message(false)}}catch(h){alert("process_ajax_call: "+h);loading_message(false)}})}else{alert("Seleziona una linea e imposta un punto")}break;case"menu_geometry_processing_cut_polygon":if(_LIST_OF_SELECTED_OBJECTS.length==1&&_LIST_OF_SELECTED_OBJECTS[0]._type=="MULTISURFACE"&&_LIST_OF_SELECTED_OBJECTS[0]._id_geometry!=-1&&_LIST_OF_SELECTED_OBJECTS[0]._layer_name!=""){for(var a=0;a<_LIST_OF_EXTRA_GRAPHICS.length;a++){if(_LIST_OF_EXTRA_GRAPHICS[a] instanceof Line_Path&&_LIST_OF_EXTRA_GRAPHICS[a]._id_geometry==-1){if(_LIST_OF_EXTRA_GRAPHICS[a]._list_of_graphics.length>0){var c=_LIST_OF_EXTRA_GRAPHICS[a].to_post_request();break}}}}else{if(_LIST_OF_SELECTED_OBJECTS.length==2&&_LIST_OF_SELECTED_OBJECTS[0]._type=="MULTISURFACE"&&_LIST_OF_SELECTED_OBJECTS[0]._id_geometry!=-1&&_LIST_OF_SELECTED_OBJECTS[0]._layer_name!=""&&_LIST_OF_SELECTED_OBJECTS[1]._type=="MULTICURVE"&&_GENERIC_GIS_UTILS.is_line_path_drawn()){var c=_GENERIC_GIS_UTILS.encode_save_line_to_http()}else{alert("Seleziona un poligono e un linea, oppure disegna un linea e seleziona un poligono");return}}var d="type=layer&action=set_geometry_session&layer_name="+_LIST_OF_SELECTED_OBJECTS[0]._layer_name+"&geometry_type=MULTICURVE&geometry="+c;loading_message(true);process_ajax_call(d,_CNTR_LAYER_EDITOR,function(g){try{if(!g){var i="type=geometry_processing&action=cut_polygon&layer_name="+_LIST_OF_SELECTED_OBJECTS[0]._layer_name+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry;process_ajax_call(i,_CNTR_GEOMETRY_PROCESSING,function(j){try{if(!j){alert("La geometria è stata tagliata correttamente!");reset_extra_graphics(_ALL_DRAWING_ENGINES);_MAP_WRAPPER.reload_map()}else{loading_message(false)}}catch(k){alert("process_ajax_call: "+k);loading_message(false)}})}else{loading_message(false)}}catch(h){alert("process_ajax_call: "+h);loading_message(false)}});break;case"menu_geometry_processing_multi_to_single":if(_LIST_OF_SELECTED_OBJECTS.length==1&&_LIST_OF_SELECTED_OBJECTS[0]._layer_name!=""){var d="type=geometry_processing&action=multi_to_single&layer_name="+_LIST_OF_SELECTED_OBJECTS[0]._layer_name+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry;loading_message(true);process_ajax_call(d,_CNTR_GEOMETRY_PROCESSING,function(g){try{if(!g){alert("Geometria suddivisa correttamente!");reset_extra_graphics(_ALL_DRAWING_ENGINES);_MAP_WRAPPER.reload_map()}else{loading_message(false)}}catch(h){alert("process_ajax_call: "+h);loading_message(false)}})}else{alert("Seleziona una geometria di tipo multi")}break}}catch(b){alert("Generic_GIS_Events_Manager.generic_gis_menu_geometry_processing_handler(id): "+b)}}function generic_gis_menu_analysis_handler(b){try{switch(b){case"menu_analysis_attributes_query":_GENERIC_GIS_UTILS.open_new_window(_UI_ATTRIBUTES_QUERY+"?type=attributes_query&action=insert",get_width(0.6),get_height(0.5),true,true);break;case"menu_analysis_functional_query":_GENERIC_GIS_UTILS.open_new_window(_UI_FUNCTIONAL_QUERY+"?type=functional_query&action=insert",get_width(0.6),get_height(0.5),true,true);break;case"menu_analysis_spatial_query":_GENERIC_GIS_UTILS.open_new_window(_UI_SPATIAL_QUERY+"?type=spatial_query&action=insert",get_width(0.5),get_height(0.5),true,true);break;case"menu_analysis_spatial_intersection":_GENERIC_GIS_UTILS.open_new_window(_UI_SPATIAL_INTERSECTION+"?type=spatial_intersection&action=insert",get_width(0.5),get_height(0.5),true,true);break;case"menu_analysis_query_management":_GENERIC_GIS_UTILS.open_new_window(_UI_QUERY_MANAGEMENT+"?type=query&action=management",get_width(0.5),get_height(0.5),true,false);break}}catch(a){alert("Generic_GIS_Events_Manager.generic_gis_menu_analysis_handler(id): "+a)}}function generic_gis_menu_straight_line_handler(a){try{switch(a){case"menu_straight_line_from_segment":generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_select_segment);break;case"menu_straight_line_from_2_points":if(_LIST_OF_POINTS.length<2){alert(_MSG_SET_2_POINTS);return}var j=_LIST_OF_POINTS.pop();var g=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",j);_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",g);var k=new Parametric_Line(j,g);remove_from_extra_graphics(j,_SELECTION_DRAWING_ENGINE);remove_from_extra_graphics(g,_SELECTION_DRAWING_ENGINE);_LIST_OF_LINES.push(k);_LIST_OF_EXTRA_GRAPHICS.push(k);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_straight_line_perpendicular":if(_LIST_OF_POINTS.length<1||_LIST_OF_LINES.length<1){alert(_MSG_ONE_POINT_ONE_STRAIGHT);return}var d=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",d);var h=_LIST_OF_LINES[_LIST_OF_LINES.length-1].snap_point(d);var k=new Parametric_Line(d,h);_LIST_OF_LINES.push(k);_LIST_OF_EXTRA_GRAPHICS.push(k);remove_from_extra_graphics(d,_SELECTION_DRAWING_ENGINE);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_straight_line_parallel":register_mouse_down_handler(evt_move_straight_line);break;case"menu_straight_line_projection":if(_LIST_OF_POINTS.length<1||_LIST_OF_LINES.length<1){alert(_MSG_ONE_POINT_ONE_STRAIGHT);return}var d=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",d);var h=_LIST_OF_LINES[_LIST_OF_LINES.length-1].snap_point(d);_LIST_OF_POINTS.push(h);_LIST_OF_EXTRA_GRAPHICS.push(h);remove_from_extra_graphics(d,_SELECTION_DRAWING_ENGINE);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_straight_line_intersection":if(_LIST_OF_LINES.length<2){alert(_MSG_TWO_INTERECANT_STRAIGTH);return}var i=_LIST_OF_LINES[_LIST_OF_LINES.length-1];var f=_LIST_OF_LINES[_LIST_OF_LINES.length-2];if(_GENERIC_GIS_UTILS.are_lines_parallel(i,f)){alert("Rette sono parallele");return}var c=_GENERIC_GIS_UTILS.intersect_lines(i,f);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",c);_LIST_OF_POINTS.push(c);_LIST_OF_EXTRA_GRAPHICS.push(c);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_straight_line_delete":generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_remove_straight_line);break;case"menu_straight_line_delete_all":clear_lines(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break}}catch(b){alert("Generic_GIS_Events_Manager.generic_gis_menu_straight_line_handler(id): "+b)}}function generic_gis_menu_circle_handler(o){try{switch(o){case"menu_circle_ray":if(_LIST_OF_POINTS.length<1){alert(_MSG_SET_POINT);return}var l=prompt(_MSG_RAY);if(l==""||isNaN(l)){alert(_MSG_NUMERIC_VALUE_REQUIRED);return}var q=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",q);var g=new Circle(q,parseFloat(l));g._optimized_drawing=false;remove_from_extra_graphics(q,_SELECTION_DRAWING_ENGINE);_LIST_OF_CIRCLES.push(g);_LIST_OF_EXTRA_GRAPHICS.push(g);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_circle_3_points":if(_LIST_OF_POINTS.length<3){alert(_MSG_SET_POINT);return}var a=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",a);var b=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",b);var c=_LIST_OF_POINTS.pop();_GENERIC_GIS_UTILS.remove_draw_operation("draw_point",c);var f=_GENERIC_GIS_UTILS.calculate_radius(c,b,a);var m=new Point((c._x+b._x)/2,(c._y+b._y)/2);var u=new Point((b._x+a._x)/2,(b._y+a._y)/2);var v=-1/((b._y-c._y)/(b._x-c._x));var h=-1/((a._y-b._y)/(a._x-b._x));var s=-v*m._x+m._y;var d=-h*u._x+u._y;var r=new Point(c._x,c._x*v+s);var n=new Point(b._x,b._x*h+d);var k=new Parametric_Line(m,r);var j=new Parametric_Line(u,n);var p=_GENERIC_GIS_UTILS.intersect_lines(k,j);var g=new Circle(p,f);g._optimized_drawing=false;remove_from_extra_graphics(a,_SELECTION_DRAWING_ENGINE);remove_from_extra_graphics(b,_SELECTION_DRAWING_ENGINE);remove_from_extra_graphics(c,_SELECTION_DRAWING_ENGINE);_LIST_OF_CIRCLES.push(g);_LIST_OF_EXTRA_GRAPHICS.push(g);clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_circle_intersect_straight_line":if(_LIST_OF_CIRCLES.length<1||_LIST_OF_LINES.length<1){alert(_MSG_NO_INTERSECTION);return}var i=_GENERIC_GIS_UTILS.line_intersect_circle(_LIST_OF_LINES[_LIST_OF_LINES.length-1],_LIST_OF_CIRCLES[_LIST_OF_CIRCLES.length-1]);if(i.length>1){_LIST_OF_EXTRA_GRAPHICS.push(i[0]);_LIST_OF_EXTRA_GRAPHICS.push(i[1]);_LIST_OF_POINTS.push(i[0]);_LIST_OF_POINTS.push(i[1]);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",i[0]);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",i[1])}else{if(i.length==1){_LIST_OF_EXTRA_GRAPHICS.push(i[0]);_LIST_OF_POINTS.push(i[0]);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",i[0])}else{alert(_MSG_NO_INTERSECTION);return}}clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_circle_intersect_circle":if(_LIST_OF_CIRCLES.length<2){alert(_MSG_TWO_CIRCLES);return}var i=_GENERIC_GIS_UTILS.intersect_circle(_LIST_OF_CIRCLES[_LIST_OF_CIRCLES.length-1],_LIST_OF_CIRCLES[_LIST_OF_CIRCLES.length-2]);if(i.length>1){_LIST_OF_EXTRA_GRAPHICS.push(i[0]);_LIST_OF_EXTRA_GRAPHICS.push(i[1]);_LIST_OF_POINTS.push(i[0]);_LIST_OF_POINTS.push(i[1]);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",i[0]);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",i[1])}else{if(i.length==1){_LIST_OF_EXTRA_GRAPHICS.push(i[0]);_LIST_OF_POINTS.push(i[0]);_GENERIC_GIS_UTILS.log_draw_operation("draw_point",i[0])}else{alert(_MSG_NO_INTERSECTION);return}}clear_extra_graphics(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break;case"menu_circle_delete":generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_remove_circle);break;case"menu_circle_delete_all":clear_circles(_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);break}}catch(t){alert("Generic_GIS_Events_Manager.generic_gis_menu_circle_handler(id): "+t)}}function generic_gis_menu_measure_handler(v){try{switch(v){case"menu_measure_manual":generic_gis_toolbar_select_button(null);set_map_cursor("crosshair");register_mouse_down_handler(evt_event_measure);change_system_status(new Evt_Draw_Circle(true));break;case"menu_measure_point_point":if(_LIST_OF_POINTS.length<2){alert(_MSG_SET_2_POINTS);return}var g=_LIST_OF_POINTS[_LIST_OF_POINTS.length-1];var d=_LIST_OF_POINTS[_LIST_OF_POINTS.length-2];var h=g.distance(d);var p=new Line(g,d);p.set_color("#ff0000");p.set_stroke(2);var r=null;if(_COORDINATE_PRECISION!=0){r=new Text((g._x+d._x)/2,(g._y+d._y)/2,new Number(h).toFixed(_COORDINATE_PRECISION)+" m")}else{r=new Text((g._x+d._x)/2,(g._y+d._y)/2,new Number(h)+" m")}if((d._x-g._x>0&&d._y-g._y<0)||(d._x-g._x<0&&d._y-g._y>0)){r._offset_y=-15}_LIST_OF_EXTRA_GRAPHICS.push(p);_LIST_OF_EXTRA_GRAPHICS.push(r);draw_extra_graphics_object(false,p,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,r,_SELECTION_DRAWING_ENGINE);break;case"menu_measure_ortogonal":if(_LIST_OF_POINTS.length<3){alert(_MSG_SET_3_POINTS);return}var g=_LIST_OF_POINTS[_LIST_OF_POINTS.length-3];var d=_LIST_OF_POINTS[_LIST_OF_POINTS.length-2];var c=_LIST_OF_POINTS[_LIST_OF_POINTS.length-1];var f=new Parametric_Line(g,d);var b=f.snap_point(c);var s=new Line(g,b);s.set_color("#ff0000");s.set_stroke(2);var w=new Line(c,b);w.set_color("#ff0000");w.set_stroke(2);var m=g.distance(b);var u=c.distance(b);var j=null;if(_COORDINATE_PRECISION!=0){j=new Text((g._x+b._x)/2,(g._y+b._y)/2,new Number(m).toFixed(_COORDINATE_PRECISION)+" m")}else{j=new Text((g._x+b._x)/2,(g._y+b._y)/2,new Number(m)+" m")}if((b._x-g._x>0&&b._y-g._y<0)||(b._x-g._x<0&&b._y-g._y>0)){j._offset_y=-15}var t=null;if(_COORDINATE_PRECISION!=0){t=new Text((b._x+c._x)/2,(b._y+c._y)/2,new Number(u).toFixed(_COORDINATE_PRECISION)+" m")}else{t=new Text((b._x+c._x)/2,(b._y+c._y)/2,new Number(u)+" m")}if((c._x-b._x>0&&c._y-b._y<0)||(c._x-b._x<0&&c._y-b._y>0)){t._offset_y=-15}_LIST_OF_EXTRA_GRAPHICS.push(f);_LIST_OF_EXTRA_GRAPHICS.push(s);_LIST_OF_EXTRA_GRAPHICS.push(w);_LIST_OF_EXTRA_GRAPHICS.push(j);_LIST_OF_EXTRA_GRAPHICS.push(t);draw_extra_graphics_object(false,f,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,s,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,w,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,j,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,t,_SELECTION_DRAWING_ENGINE);break;case"menu_measure_polar":if(_LIST_OF_POINTS.length<3){alert(_MSG_SET_3_POINTS);return}var g=_LIST_OF_POINTS[_LIST_OF_POINTS.length-3];var d=_LIST_OF_POINTS[_LIST_OF_POINTS.length-2];var c=_LIST_OF_POINTS[_LIST_OF_POINTS.length-1];var h=g.distance(c);var f=new Parametric_Line(g,d);var q=new Line(g,c);q.set_color("#ff0000");q.set_stroke(2);var k=new Circle(g,parseFloat(h/3));k._optimized_drawing=false;var r=null;if(_COORDINATE_PRECISION!=0){r=new Text((g._x+c._x)/2,(g._y+c._y)/2,new Number(h).toFixed(_COORDINATE_PRECISION)+" m")}else{r=new Text((g._x+c._x)/2,(g._y+c._y)/2,new Number(h)+" m")}if((c._x-g._x>0&&c._y-g._y<0)||(c._x-g._x<0&&c._y-g._y>0)){r._offset_y=-15}var a=_GENERIC_GIS_UTILS.compute_direction_vector(g,d);var E=_GENERIC_GIS_UTILS.compute_direction_vector(g,c);var y=_GENERIC_GIS_UTILS.compute_versor_vector(a);var x=_GENERIC_GIS_UTILS.compute_versor_vector(E);var A=_MAP_WRAPPER.rad_to_deg(f.angle(q));var o=new Text(g._x+h*(y[0]+x[0])/6,g._y+h*(y[1]+x[1])/6,new Number(A).toFixed(2)+"°");var n=new Text(g._x-h*(y[0]+x[0])/6,g._y-h*(y[1]+x[1])/6,new Number(360-A).toFixed(2)+"°");_LIST_OF_EXTRA_GRAPHICS.push(k);_LIST_OF_EXTRA_GRAPHICS.push(f);_LIST_OF_EXTRA_GRAPHICS.push(q);_LIST_OF_EXTRA_GRAPHICS.push(r);_LIST_OF_EXTRA_GRAPHICS.push(o);_LIST_OF_EXTRA_GRAPHICS.push(n);draw_extra_graphics_object(false,k,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,f,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,q,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,r,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,o,_SELECTION_DRAWING_ENGINE);draw_extra_graphics_object(false,n,_SELECTION_DRAWING_ENGINE);break;case"menu_measure_new_linear_measurement":if(_LIST_OF_POINTS.length<2){alert(_MSG_SET_2_POINTS);return}var g=_LIST_OF_POINTS[_LIST_OF_POINTS.length-2];var d=_LIST_OF_POINTS[_LIST_OF_POINTS.length-1];var c=new Point(g._x+(d._x-g._x)/2,g._y+(d._y-g._y)/2);if(g.equals(d)){alert("Inseriti 2 punti uguali, impossibile continuare!");return}var l=new Measure("linear_measure",g,d,c);reset_extra_graphics(_ALL_DRAWING_ENGINES);_LIST_OF_EXTRA_GRAPHICS.push(l);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_move_measure);break;case"menu_measure_new_aligned_measurement":if(_LIST_OF_POINTS.length<2){alert(_MSG_SET_2_POINTS);return}var g=_LIST_OF_POINTS[_LIST_OF_POINTS.length-2];var d=_LIST_OF_POINTS[_LIST_OF_POINTS.length-1];var c=new Point(g._x+(d._x-g._x)/2,g._y+(d._y-g._y)/2);if(g.equals(d)){alert("Inseriti 2 punti uguali, impossibile continuare!");return}var C=new Measure("aligned_measure",new Point(g._x,g._y),new Point(d._x,d._y),c);reset_extra_graphics(_ALL_DRAWING_ENGINES);_LIST_OF_EXTRA_GRAPHICS.push(C);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_move_measure);break;case"menu_measure_save_measurement":if(_LIST_OF_EXTRA_GRAPHICS!=0){for(var z=0;z<_LIST_OF_EXTRA_GRAPHICS.length;z++){if(_LIST_OF_EXTRA_GRAPHICS[z] instanceof Measure){var D=_LIST_OF_EXTRA_GRAPHICS[z].encode_to_http();if(_LIST_OF_EXTRA_GRAPHICS[z]._id_measure==null){if(!_MAP_WRAPPER.check_is_layer_measure(_MAP_WRAPPER.get_selected_layer())){alert("Selezionare un Livello Misurazioni!");return}D="type=measure&action=insert&layer_name="+_MAP_WRAPPER.get_selected_layer()._name+D}else{D="type=measure&action=update&layer_name="+_LIST_OF_EXTRA_GRAPHICS[z]._layer_name+"&id_measure="+_LIST_OF_EXTRA_GRAPHICS[z]._id_measure+D}remove_from_extra_graphics(_LIST_OF_EXTRA_GRAPHICS[z],_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE);loading_message(true);process_ajax_call(D,_CNTR_MEASURES,function(i){try{if(!i){_MAP_WRAPPER.reload_map();loading_message(false)}else{loading_message(false)}}catch(F){alert("process_ajax_call: "+F);loading_message(false)}});return}}}alert("Nessuna Misurazione!");break;case"menu_measure_select_measurement":generic_gis_toolbar_select_button(null);set_map_cursor("crosshair");register_mouse_down_handler(evt_select_measure);break;case"menu_measure_delete_measurement":if(_LIST_OF_EXTRA_GRAPHICS!=0){for(var z=0;z<_LIST_OF_EXTRA_GRAPHICS.length;z++){if(_LIST_OF_EXTRA_GRAPHICS[z] instanceof Measure){if(_LIST_OF_EXTRA_GRAPHICS[z]._id_measure==null||_LIST_OF_EXTRA_GRAPHICS[z]._layer_name==""){alert("Selezionare una misurazione!")}else{if(confirm("Sicuro di voler cancellare la misurazione selezionata?")){var D="type=measure&action=delete&id_measure="+_LIST_OF_EXTRA_GRAPHICS[z]._id_measure+"&layer_name="+_LIST_OF_EXTRA_GRAPHICS[z]._layer_name;loading_message(true);process_ajax_call(D,_CNTR_MEASURES,function(i){try{if(!i){_MAP_WRAPPER.reload_map();loading_message(false)}else{loading_message(false)}}catch(F){alert("process_ajax_call: "+F);loading_message(false)}});remove_from_extra_graphics(_LIST_OF_EXTRA_GRAPHICS[z],_SELECTION_DRAWING_ENGINE);draw_extra_graphics(false,_SELECTION_DRAWING_ENGINE)}}return}}}alert("Nessuna Misurazione selezionata!");break;case"menu_measure_measures_management":_GENERIC_GIS_UTILS.open_new_window(_UI_MEASURES_MANAGEMENT+"?type=measures&action=manage",get_width(0.5),get_height(0.5),true,false);break}}catch(B){alert("Generic_GIS_Events_Manager.generic_gis_menu_measure_handler(id): "+B)}}function generic_gis_menu_tools_handler(d){try{switch(d){case"menu_tools_settings":_GENERIC_GIS_UTILS.open_new_window(_UI_MAP_SETTINGS+"?type=map&action=update&id_map="+_MAP_WRAPPER._id_map,get_width(0.47),get_height(0.85),true,false);break;case"menu_tools_query_parcel":generic_gis_toolbar_select_button(null);set_map_cursor("crosshair");register_mouse_down_handler(evt_event_query_parcel);break;case"menu_tools_generic_positioner":var b=_GENERIC_GIS_UTILS.open_new_window(_UI_GENERIC_POSITIONER+"?type=layer&action=position",460,180,true,false);var c=findPos(document.getElementById(_EVENTS_ID));b.move(get_width(1)-510,c[1]+10);break;case"menu_tools_scale":generic_gis_toolbar_select_button(null);set_map_cursor("pointer");register_mouse_down_handler(evt_event_zoom_to_scale);break;case"menu_tools_rotate":evt_but_popup_rotate_map();break;case"menu_owners_manager":_GENERIC_GIS_UTILS.open_new_window(_UI_OWNERS_MANAGER,get_width(0.4),get_height(0.5),true,true);break}}catch(a){alert("Generic_GIS_Events_Manager.generic_gis_menu_tools_handler(id): "+a)}}function generic_gis_menu_context_handler(d){try{switch(d){case"context_menu_activate_selected":var b=new Array();for(var a=0;a<_MAP_WRAPPER._list_of_layers.length;a++){if(_MAP_WRAPPER._list_of_layers[a]._selected&&_MAP_WRAPPER._list_of_layers[a]._active==false){_MAP_WRAPPER._list_of_layers[a].toggle_status();b.push(_MAP_WRAPPER._list_of_layers[a])}}_MAP_WRAPPER.update_layers_status(b);break;case"context_menu_deactivate_selected":var b=new Array();for(var a=0;a<_MAP_WRAPPER._list_of_layers.length;a++){if(_MAP_WRAPPER._list_of_layers[a]._selected&&_MAP_WRAPPER._list_of_layers[a]._active==true){_MAP_WRAPPER._list_of_layers[a].toggle_status();b.push(_MAP_WRAPPER._list_of_layers[a])}}_MAP_WRAPPER.update_layers_status(b);break;case"context_menu_activate_snap_selected":_MAP_WRAPPER.set_snap_selected_layers(true);break;case"context_menu_deactivate_snap_selected":_MAP_WRAPPER.set_snap_selected_layers(false);break}}catch(c){alert("Generic_GIS_Events_Manager.generic_gis_context_menu_handler(id): "+c)}}function generic_gis_toolbar_select_button(b){var a=_GUI_FACTORY.create_gui_command("select_toolbar_button");a._button_id=b;a.execute()}function evt_but_save_geometry(){if(!_MAP_WRAPPER.check_is_layer_selected()){return}try{var c="type=layer&action=decode_layer_geometry&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;if(!c){return}var a="";loading_message(true);process_ajax_sync_call(c,_CNTR_LAYER_EDITOR,function(d){if(!d){a=this.responseXML.getElementsByTagName("geometry_type")[0].firstChild.nodeValue;loading_message(false)}else{loading_message(false)}});if(a=="POINT"){if(_LIST_OF_SELECTED_OBJECTS.length==0){if(_LIST_OF_POINTS.length==0){alert(_MSG_DEFINE_GEOMETRY);return}c="type=layer&action=set_geometry_session&geometry_type=POINT&x="+_LIST_OF_POINTS[0]._x+"&y="+_LIST_OF_POINTS[0]._y+"&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;loading_message(true);process_ajax_sync_call(c,_CNTR_LAYER_EDITOR,function(d){if(!d){loading_message(false);_GENERIC_GIS_UTILS.open_new_window(_UI_ATTRIBUTES+"?type=attributes&action=insert&layer_name="+_MAP_WRAPPER.get_selected_layer()._name+"&geometry_type=POINT",600,500,true,true)}else{loading_message(false)}})}else{if(_LIST_OF_SELECTED_OBJECTS[0].constructor==Point&&_LIST_OF_SELECTED_OBJECTS[0]._id_geometry!=-1){c="type=layer&action=update_geometry&x="+_LIST_OF_SELECTED_OBJECTS[0]._x+"&y="+_LIST_OF_SELECTED_OBJECTS[0]._y+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry+"&geometry_type=POINT&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;execut_map_ajax_call(c,_CNTR_LAYER_EDITOR)}else{alert(_MSG_SET_POINT);return}}}else{if(a=="MULTICURVE"){if(_LINE_PATH==null||_LINE_PATH._list_of_graphics.length==0){alert(_MSG_DEFINE_GEOMETRY);return}if(_LIST_OF_SELECTED_OBJECTS.length==0){c="type=layer&action=set_geometry_session&geometry_type="+a+"&geometry="+_GENERIC_GIS_UTILS.encode_save_line_to_http()+"&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;loading_message(true);process_ajax_sync_call(c,_CNTR_LAYER_EDITOR,function(d){if(!d){loading_message(false);_GENERIC_GIS_UTILS.open_new_window(_UI_ATTRIBUTES+"?type=attributes&action=insert&layer_name="+_MAP_WRAPPER.get_selected_layer()._name+"&geometry_type="+a,600,500,true,true)}else{loading_message(false)}})}else{if(_LIST_OF_SELECTED_OBJECTS[0].constructor==Line_Path&&_LIST_OF_SELECTED_OBJECTS[0]._id_geometry!=-1&&_LINE_PATH!=null&&_LINE_PATH._list_of_graphics.length!=0){c="type=layer&action=update_geometry&geometry="+_GENERIC_GIS_UTILS.encode_update_line_to_http()+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry+"&geometry_type="+a+"&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;execut_map_ajax_call(c,_CNTR_LAYER_EDITOR)}else{alert(_MSG_DEFINE_GEOMETRY);return}}}else{if(a=="MULTISURFACE"){if(_LINE_PATH==null||_LINE_PATH._list_of_graphics.length==0){alert(_MSG_DEFINE_GEOMETRY);return}if(_LIST_OF_SELECTED_OBJECTS.length==0){c="type=layer&action=set_geometry_session&geometry_type="+a+"&geometry="+_GENERIC_GIS_UTILS.encode_save_polygon_to_http()+"&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;loading_message(true);process_ajax_sync_call(c,_CNTR_LAYER_EDITOR,function(d){if(!d){loading_message(false);_GENERIC_GIS_UTILS.open_new_window(_UI_ATTRIBUTES+"?type=attributes&action=insert&layer_name="+_MAP_WRAPPER.get_selected_layer()._name+"&geometry_type="+a,600,500,true,true)}else{loading_message(false)}})}else{if(_LIST_OF_SELECTED_OBJECTS[0].constructor==Line_Path&&_LIST_OF_SELECTED_OBJECTS[0]._id_geometry!=-1&&_LINE_PATH!=null){c="type=layer&action=update_geometry&geometry="+_GENERIC_GIS_UTILS.encode_update_polygon_to_http()+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry+"&geometry_type="+a+"&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;execut_map_ajax_call(c,_CNTR_LAYER_EDITOR)}}}}}}catch(b){alert("Generic_GIS_Events_Manager.evt_but_save_geometry(): "+b);loading_message(false)}}function evt_select_geometry(a){if(!_MAP_WRAPPER.check_is_layer_selected()){return}process_mouse_down(a,new Evt_Select_Geometry())}function evt_query_geometry(a){if(!_MAP_WRAPPER.check_is_layer_selected()){return}process_mouse_down(a,new Evt_Query_Geometry())}function evt_but_delete_geometry(){try{if(_LIST_OF_SELECTED_OBJECTS.length==1&&_LIST_OF_SELECTED_OBJECTS[0]._layer_name!=""&&_LIST_OF_SELECTED_OBJECTS[0]._id_geometry!=""){if(confirm("Sicuro di voler cancellare la geometria selezionata?")){var b="type=layer&action=delete_feature&layer_name="+_LIST_OF_SELECTED_OBJECTS[0]._layer_name+"&id_geometry="+_LIST_OF_SELECTED_OBJECTS[0]._id_geometry;execut_map_ajax_call(b,_CNTR_LAYER_EDITOR)}}else{alert("Selezionare una geometria")}}catch(a){alert("Generic_GIS_Events_Manager.evt_but_delete_geometry(): "+a)}}function evt_but_copy_geometry(){try{if(_LIST_OF_SELECTED_OBJECTS.length==0){alert(_MSG_SELECT_OBJECT);return}clear_extra_graphics(_ALL_DRAWING_ENGINES);setTimeout("draw_extra_graphics(false, _ALL_DRAWING_ENGINES)",500);var a=_GUI_FACTORY.create_gui_command("change_toolbar_status");a._button="toolbar_paste";a._disabled=false;a.execute()}catch(b){alert("Generic_GIS_Events_Manager.evt_but_copy_geometry(): "+b);loading_message(false)}}function evt_but_paste_geometry(){try{if(!_MAP_WRAPPER.check_is_layer_selected()){return}var d="type=layer&action=decode_layer_geometry&layer_name="+_MAP_WRAPPER.get_selected_layer()._name;var b="";loading_message(true);process_ajax_sync_call(d,_CNTR_LAYER_EDITOR,function(e){if(!e){b=this.responseXML.getElementsByTagName("geometry_type")[0].firstChild.nodeValue;loading_message(false)}else{loading_message(false)}});if(_LIST_OF_SELECTED_OBJECTS.length>0){if(_LIST_OF_SELECTED_OBJECTS[0]._type!=b){alert("Livello di destinazione ha una geometria diversa da quella copiata");return}clear_extra_graphics(_ALL_DRAWING_ENGINES);if(b=="MULTICURVE"||b=="MULTISURFACE"){_LIST_OF_SELECTED_OBJECTS.splice(0,_LIST_OF_SELECTED_OBJECTS.length)}else{if(b=="POINT"){clear_points(_ALL_DRAWING_ENGINES);_LIST_OF_POINTS.push(_LIST_OF_SELECTED_OBJECTS[0]);_LIST_OF_SELECTED_OBJECTS.splice(0,_LIST_OF_SELECTED_OBJECTS.length)}}setTimeout("draw_extra_graphics(false, _ALL_DRAWING_ENGINES)",500)}var a=_GUI_FACTORY.create_gui_command("change_toolbar_status");a._button="toolbar_paste";a._disabled=true;a.execute()}catch(c){alert("Generic_GIS_Events_Manager.evt_but_paste_geometry(): "+c);loading_message(false)}}function evt_select_measure(a){if(!_MAP_WRAPPER.check_is_layer_measure(_MAP_WRAPPER.get_selected_layer())){alert("Selezionare un Livello Misurazioni!");_OP_USER=new Idle();return}process_mouse_down(a,new Evt_Select_Measure())}function evt_move_measure(a){process_mouse_down(a,new Evt_Move_Measure())}function evt_but_zoomback(){try{if(_MAP_WRAPPER._list_of_extents.length<=1){return}_MAP_WRAPPER.abort_loading_map();_MAP_WRAPPER.remove_old_map_images();var j=_MAP_WRAPPER._list_of_extents.shift();var k=_MAP_WRAPPER.get_current_extent();var d=_MAP_WRAPPER.convert_to_pixel(j._min_x,j._min_y,false);var i=_MAP_WRAPPER.convert_to_pixel(j._max_x,j._max_y,false);var h=(i[0]+d[0])/2-_MAP_WRAPPER._width/2;var g=(i[1]+d[1])/2-_MAP_WRAPPER._height/2;var b=(i[0]-d[0])/_MAP_WRAPPER._width;var a=(i[1]-d[1])/_MAP_WRAPPER._height;if(b<a){_MAP_WRAPPER.move_map_image(h,-g);_MAP_WRAPPER.resize_map_image(b)}else{_MAP_WRAPPER.move_map_image(h,-g);_MAP_WRAPPER.resize_map_image(a)}var c="type=map&action=zoom_to_extent&minx="+k._min_x+"&miny="+k._min_y+"&maxx="+k._max_x+"&maxy="+k._max_y;loading_message(true);process_ajax_call(c,_CNTR_EVENTS_URL,function(l){try{if(!l){_MAP_WRAPPER.update_map(this.responseXML)}else{loading_message(false)}}catch(m){alert("process_ajax_call: "+m);loading_message(false)}})}catch(f){alert("Generic_GIS_Events_Manager.evt_but_zoomback(): "+f);loading_message(false)}};
