diff --git a/NavigationSystem/Database-poi.txt b/NavigationSystem/Database-poi.txt new file mode 100644 index 0000000..4cfd9a9 --- /dev/null +++ b/NavigationSystem/Database-poi.txt @@ -0,0 +1,10 @@ +Gas station; Aral Tankst.; Refuel your vehicle; 49.871558; 8.639206 +Gas station; Aral Tankstelle; Refuel your vehicle; 49.868538; 8.645465 +Touristic; Church 7 Days; Adventist Chruch; 49.839096; 8.646294 +Touristic; Church Holy; Freie Christengemeinde; 49.865072; 8.647415 +Restaurant; El Quinto Vino; Spanish Restaurant ; 49.813422; 8.646246 +University; HDA BuildingC10; An awesome University; 49.86727; 8.638459 +Gas station; Ladestation; Electric vehicle charge; 49.811698; 8.646074 +Restaurant; Starbucks; A blissful coffee; 49.872409; 8.650744 +Restaurant; SushiRestaurant; Asian food today!; 49.869365; 8.645922 +Restaurant; Thessaloniki; Greek Restaurant ; 49.862869; 8.646691 diff --git a/NavigationSystem/Database-wp.txt b/NavigationSystem/Database-wp.txt new file mode 100644 index 0000000..531686e --- /dev/null +++ b/NavigationSystem/Database-wp.txt @@ -0,0 +1,8 @@ +Berliner Alle; 49.866851; 8.634864 +Bessunger; 49.846994; 8.646193 +FriedrichStrasse; 49.838545; 8.645571 +Katharinen Str.; 49.824827; 8.644529 +Landskronstrasse; 49.853308; 8.646835 +Neckarstrasse; 49.8717; 8.644417 +Rheinstrasse; 49.870267; 8.633266 +Wartehalle; 49.820845; 8.644222 diff --git a/NavigationSystem/Documents/NavigationSystem.pdf b/NavigationSystem/Documents/NavigationSystem.pdf index a22a1ba..9704926 100644 Binary files a/NavigationSystem/Documents/NavigationSystem.pdf and b/NavigationSystem/Documents/NavigationSystem.pdf differ diff --git a/NavigationSystem/Documents/NavigationSystem_updated.pdf b/NavigationSystem/Documents/NavigationSystem_updated.pdf deleted file mode 100644 index d5a61db..0000000 Binary files a/NavigationSystem/Documents/NavigationSystem_updated.pdf and /dev/null differ diff --git a/NavigationSystem/Release.zip b/NavigationSystem/Release.zip new file mode 100644 index 0000000..a2992df Binary files /dev/null and b/NavigationSystem/Release.zip differ diff --git a/NavigationSystem/Workspace/.cproject b/NavigationSystem/Workspace/.cproject deleted file mode 100644 index d8b0d0c..0000000 --- a/NavigationSystem/Workspace/.cproject +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/NavigationSystem/Workspace/.gdbinit b/NavigationSystem/Workspace/.gdbinit deleted file mode 100644 index aa7aaf4..0000000 --- a/NavigationSystem/Workspace/.gdbinit +++ /dev/null @@ -1,6 +0,0 @@ -python -import sys -sys.path.insert(0, sys.path[0] + '/../../gcc-6.3.0/python') -from libstdcxx.v6.printers import register_libstdcxx_printers -register_libstdcxx_printers (None) -end diff --git a/NavigationSystem/Workspace/.project b/NavigationSystem/Workspace/.project deleted file mode 100644 index 0002aa9..0000000 --- a/NavigationSystem/Workspace/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - Navigation System - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - full,incremental, - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - - diff --git a/NavigationSystem/Workspace/.settings/language.settings.xml b/NavigationSystem/Workspace/.settings/language.settings.xml deleted file mode 100644 index 77007bc..0000000 --- a/NavigationSystem/Workspace/.settings/language.settings.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/NavigationSystem/Workspace/.settings/org.eclipse.cdt.codan.core.prefs b/NavigationSystem/Workspace/.settings/org.eclipse.cdt.codan.core.prefs deleted file mode 100644 index 45484f3..0000000 --- a/NavigationSystem/Workspace/.settings/org.eclipse.cdt.codan.core.prefs +++ /dev/null @@ -1,3 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.codan.checkers.errnoreturn=Error -useParentScope=false diff --git a/NavigationSystem/Workspace/.settings/org.eclipse.cdt.core.prefs b/NavigationSystem/Workspace/.settings/org.eclipse.cdt.core.prefs deleted file mode 100644 index 31f1b65..0000000 --- a/NavigationSystem/Workspace/.settings/org.eclipse.cdt.core.prefs +++ /dev/null @@ -1,164 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.cdt.core.formatter.alignment_for_arguments_in_method_invocation=16 -org.eclipse.cdt.core.formatter.alignment_for_assignment=16 -org.eclipse.cdt.core.formatter.alignment_for_base_clause_in_type_declaration=80 -org.eclipse.cdt.core.formatter.alignment_for_binary_expression=16 -org.eclipse.cdt.core.formatter.alignment_for_compact_if=16 -org.eclipse.cdt.core.formatter.alignment_for_conditional_expression=34 -org.eclipse.cdt.core.formatter.alignment_for_conditional_expression_chain=18 -org.eclipse.cdt.core.formatter.alignment_for_constructor_initializer_list=0 -org.eclipse.cdt.core.formatter.alignment_for_declarator_list=16 -org.eclipse.cdt.core.formatter.alignment_for_enumerator_list=48 -org.eclipse.cdt.core.formatter.alignment_for_expression_list=0 -org.eclipse.cdt.core.formatter.alignment_for_expressions_in_array_initializer=16 -org.eclipse.cdt.core.formatter.alignment_for_member_access=0 -org.eclipse.cdt.core.formatter.alignment_for_overloaded_left_shift_chain=16 -org.eclipse.cdt.core.formatter.alignment_for_parameters_in_method_declaration=16 -org.eclipse.cdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 -org.eclipse.cdt.core.formatter.brace_position_for_array_initializer=next_line -org.eclipse.cdt.core.formatter.brace_position_for_block=next_line -org.eclipse.cdt.core.formatter.brace_position_for_block_in_case=next_line -org.eclipse.cdt.core.formatter.brace_position_for_method_declaration=next_line -org.eclipse.cdt.core.formatter.brace_position_for_namespace_declaration=next_line -org.eclipse.cdt.core.formatter.brace_position_for_switch=next_line -org.eclipse.cdt.core.formatter.brace_position_for_type_declaration=next_line -org.eclipse.cdt.core.formatter.comment.line_up_line_comment_in_blocks_on_first_column=false -org.eclipse.cdt.core.formatter.comment.min_distance_between_code_and_line_comment=1 -org.eclipse.cdt.core.formatter.comment.never_indent_line_comments_on_first_column=true -org.eclipse.cdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=true -org.eclipse.cdt.core.formatter.compact_else_if=true -org.eclipse.cdt.core.formatter.continuation_indentation=2 -org.eclipse.cdt.core.formatter.continuation_indentation_for_array_initializer=2 -org.eclipse.cdt.core.formatter.format_guardian_clause_on_one_line=false -org.eclipse.cdt.core.formatter.indent_access_specifier_compare_to_type_header=false -org.eclipse.cdt.core.formatter.indent_access_specifier_extra_spaces=0 -org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_access_specifier=true -org.eclipse.cdt.core.formatter.indent_body_declarations_compare_to_namespace_header=false -org.eclipse.cdt.core.formatter.indent_breaks_compare_to_cases=true -org.eclipse.cdt.core.formatter.indent_declaration_compare_to_template_header=false -org.eclipse.cdt.core.formatter.indent_empty_lines=false -org.eclipse.cdt.core.formatter.indent_statements_compare_to_block=true -org.eclipse.cdt.core.formatter.indent_statements_compare_to_body=true -org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_cases=true -org.eclipse.cdt.core.formatter.indent_switchstatements_compare_to_switch=false -org.eclipse.cdt.core.formatter.indentation.size=4 -org.eclipse.cdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_after_template_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_colon_in_constructor_initializer_list=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_else_in_if_statement=insert -org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.cdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.cdt.core.formatter.insert_space_after_assignment_operator=insert -org.eclipse.cdt.core.formatter.insert_space_after_binary_operator=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_arguments=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_angle_bracket_in_template_parameters=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_brace_in_block=insert -org.eclipse.cdt.core.formatter.insert_space_after_closing_paren_in_cast=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_base_clause=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_case=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_base_types=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_declarator_list=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_expression_list=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_arguments=insert -org.eclipse.cdt.core.formatter.insert_space_after_comma_in_template_parameters=insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_angle_bracket_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_bracket=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_exception_specification=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_postfix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_prefix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_after_question_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_after_semicolon_in_for=insert -org.eclipse.cdt.core.formatter.insert_space_after_unary_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_assignment_operator=insert -org.eclipse.cdt.core.formatter.insert_space_before_binary_operator=insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_angle_bracket_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_bracket=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_exception_specification=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_base_clause=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_case=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_default=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_base_types=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_declarator_list=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_expression_list=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_comma_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_arguments=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_angle_bracket_in_template_parameters=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_block=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_namespace_declaration=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_switch=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_bracket=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_catch=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_exception_specification=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_for=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_if=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_switch=insert -org.eclipse.cdt.core.formatter.insert_space_before_opening_paren_in_while=insert -org.eclipse.cdt.core.formatter.insert_space_before_postfix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_prefix_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_question_in_conditional=insert -org.eclipse.cdt.core.formatter.insert_space_before_semicolon=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_semicolon_in_for=do not insert -org.eclipse.cdt.core.formatter.insert_space_before_unary_operator=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_brackets=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_exception_specification=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert -org.eclipse.cdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert -org.eclipse.cdt.core.formatter.join_wrapped_lines=true -org.eclipse.cdt.core.formatter.keep_else_statement_on_same_line=false -org.eclipse.cdt.core.formatter.keep_empty_array_initializer_on_one_line=false -org.eclipse.cdt.core.formatter.keep_imple_if_on_one_line=false -org.eclipse.cdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.cdt.core.formatter.lineSplit=80 -org.eclipse.cdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.cdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.cdt.core.formatter.tabulation.char=tab -org.eclipse.cdt.core.formatter.tabulation.size=4 -org.eclipse.cdt.core.formatter.use_tabs_only_for_leading_indentations=false diff --git a/NavigationSystem/Workspace/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/NavigationSystem/Workspace/.settings/org.eclipse.cdt.managedbuilder.core.prefs deleted file mode 100644 index adf8dbd..0000000 --- a/NavigationSystem/Workspace/.settings/org.eclipse.cdt.managedbuilder.core.prefs +++ /dev/null @@ -1,13 +0,0 @@ -eclipse.preferences.version=1 -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/CPATH/delimiter=; -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/CPATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/CPLUS_INCLUDE_PATH/delimiter=; -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/CPLUS_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/C_INCLUDE_PATH/delimiter=; -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/C_INCLUDE_PATH/operation=remove -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/append=true -environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/appendContributed=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/LIBRARY_PATH/delimiter=; -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/LIBRARY_PATH/operation=remove -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/append=true -environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.mingw.debug.git.409683442/appendContributed=true diff --git a/NavigationSystem/Workspace/.settings/org.eclipse.core.resources.prefs b/NavigationSystem/Workspace/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index dc8aa4a..0000000 --- a/NavigationSystem/Workspace/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=iso-8859-1 diff --git a/NavigationSystem/Workspace/myCode/CNavigationSystem.cpp b/NavigationSystem/Workspace/myCode/CNavigationSystem.cpp deleted file mode 100644 index 303a787..0000000 --- a/NavigationSystem/Workspace/myCode/CNavigationSystem.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CNavigationSystem.cpp -* Author : Bharath Ramachandraiah -* Description : The file defines all the methods pertaining to the -* class type - class CNavigationSystem. -* The class CNavigationSystem is used for Navigation which -* has a GPS Sensor, Route and a Database. -* -****************************************************************************/ - -//System Include Files -#include - -//Own Include Files -#include "CNavigationSystem.h" - -//Namespaces -using namespace std; - - -//Method Implementations -/** - * Constructor - */ -CNavigationSystem::CNavigationSystem() : m_route(8, 8) -{ - // Do nothing -} - - -/** - * Navigation System functionaliy's entry function - * @returnval void - */ -void CNavigationSystem::run() -{ -#ifdef RUN_TEST_CASE_DEEP_COPY - testCaseDeepCopy(); -#endif - - // connect to the Database -#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE - this->testCaseDatabaseNotAvailable(); -#else - this->m_route.connectToPoiDatabase(&this->m_PoiDatabase); -#endif - - this->enterRoute(); - this->printRoute(); - this->printDistanceCurPosNextPoi(); -} - - -/** - * Add waypoints and POIs to create custom route - * @returnval void - */ -void CNavigationSystem::enterRoute() -{ - // add waypoints - this->m_route.addWaypoint(CWaypoint("Berliner Alle", 49.866851, 8.634864)); - this->m_route.addWaypoint(CWaypoint("Rheinstraße", 49.870267, 8.633266)); - this->m_route.addWaypoint(CWaypoint("Neckarstraße", 49.8717, 8.644417)); - this->m_route.addWaypoint(CWaypoint("Landskronstraße", 49.853308, 8.646835)); - this->m_route.addWaypoint(CWaypoint("Bessunger", 49.846994, 8.646193)); - this->m_route.addWaypoint(CWaypoint("FriedrichStraße", 49.838545, 8.645571)); - this->m_route.addWaypoint(CWaypoint("Katharinen Str.", 49.824827, 8.644529)); - this->m_route.addWaypoint(CWaypoint("Wartehalle", 49.820845, 8.644222)); - -#ifdef RUN_TEST_CASE_MORE_WAYPOINTS - testCaseAddMoreWaypoints(); -#endif - - // add POIs - this->m_route.addPoi("HDA BuildingC10" ); - this->m_route.addPoi("Aral Tankst." ); - this->m_route.addPoi("Starbucks" ); - this->m_route.addPoi("SushiRestaurant" ); - this->m_route.addPoi("Aral Tankstelle" ); - this->m_route.addPoi("Church Holy" ); - this->m_route.addPoi("Thessaloniki" ); - -#ifdef RUN_TEST_CASE_NON_EXIST_POI - testCaseNonExistingPOI(); -#endif - - this->m_route.addPoi("Church 7 Days" ); - -#ifdef RUN_TEST_CASE_MORE_POIS - testCaseAddMorePOIs(); -#endif - -} - - -/** - * Print all the waypoints and POIs of the custom route - * @returnval void - */ -void CNavigationSystem::printRoute() -{ - this->m_route.print(); -} - - -/** - * Print the Distance between current position and a closest POI - * @returnval void - */ -void CNavigationSystem::printDistanceCurPosNextPoi() -{ - CPOI poi; - CPOI::t_poi type = CPOI::DEFAULT_POI; - string name, description; - double distance = 0, latitude = 0, longitude = 0; - - CWaypoint currentPosition; - currentPosition = this->m_GPSSensor.getCurrentPosition(); - - // check if the GPS current location is valid - currentPosition.getAllDataByReference(name, latitude, longitude); - - if (!name.empty()) - { - distance = this->m_route.getDistanceNextPoi(currentPosition, poi); - - // check if the POI is valid - poi.getAllDataByReference(name, latitude, longitude, type, description); - - if (type != CPOI::DEFAULT_POI) - { - cout << "Distance to next POI = " << distance << " Kms (approx.)\n\n"; - poi.print(); - } - else - { - cout << "WARNING: Can not compute the distance.\n"; - } - } - else - { - cout << "WARNING: Invalid Sensor data.\n"; - } -} - - -/** - * TestCase to check if more waypoints are added when the memory is not available - * @returnval void - */ -#ifdef RUN_TEST_CASE_MORE_WAYPOINTS -void CNavigationSystem::testCaseAddMoreWaypoints() -{ - this->m_route.addWaypoint(CWaypoint("PfungstädterStr", 49.817379, 8.644088)); - this->m_route.addWaypoint(CWaypoint("Büschelstraße", 49.815069, 8.644614)); - this->m_route.addWaypoint(CWaypoint("Seeheimer Str.", 49.813681, 8.646337)); - this->m_route.addWaypoint(CWaypoint("Heidelberger Landstrasse", 49.80687 , 8.641321)); -} -#endif - - -/** - * TestCase to check if more POIs are added when the memory is not available - * @returnval void - */ -#ifdef RUN_TEST_CASE_MORE_POIS -void CNavigationSystem::testCaseAddMorePOIs() -{ - this->m_route.addPoi("Ladestation" ); - this->m_route.addPoi("El Quinto Vino" ); -} -#endif - - -/** - * TestCase to check if non existing POI is added to the route - * @returnval void - */ -#ifdef RUN_TEST_CASE_NON_EXIST_POI -void CNavigationSystem::testCaseNonExistingPOI() -{ - this->m_route.addPoi("My Chicken" ); -} -#endif - - -/** - * TestCase to check if deep copy is working - * @returnval void - */ -#ifdef RUN_TEST_CASE_DEEP_COPY -void CNavigationSystem::testCaseDeepCopy() -{ - CRoute testObj(8,8); - CRoute testCopyObj(testObj); -} -#endif - - -/** - * TestCase to check when database is not available - * @returnval void - */ -#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE -void CNavigationSystem::testCaseDatabaseNotAvailable() -{ - this->m_route.connectToPoiDatabase(0); -} -#endif diff --git a/NavigationSystem/Workspace/myCode/CNavigationSystem.h b/NavigationSystem/Workspace/myCode/CNavigationSystem.h deleted file mode 100644 index ce92073..0000000 --- a/NavigationSystem/Workspace/myCode/CNavigationSystem.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CNavigationSystem.h -* Author : Bharath Ramachandraiah -* Description : The file defines a class CNavigationSystem. -* The class CNavigationSystem is used for Navigation which -* has a GPS Sensor, Route and a Database. -* -****************************************************************************/ - -#ifndef CNAVIGATIONSYSTEM_H -#define CNAVIGATIONSYSTEM_H - -//System Include Files - -//Own Include Files -#include "CGPSSensor.h" -#include "CRoute.h" -#include "CPoiDatabase.h" - -//Macros -//#define RUN_TEST_CASE_DEEP_COPY -//#define RUN_TEST_CASE_MORE_POIS -//#define RUN_TEST_CASE_NON_EXIST_POI -//#define RUN_TEST_CASE_MORE_WAYPOINTS -//#define RUN_TEST_CASE_DATABASE_NOT_AVAILABLE - -class CNavigationSystem { -private: - - /** - * GPS sensor which feeds the current location - */ - CGPSSensor m_GPSSensor; - - /** - * Navigation System's current route - */ - CRoute m_route; - - /** - * The Database of points of interest - */ - CPoiDatabase m_PoiDatabase; - - /** - * Add waypoints and POIs to create custom route - * @returnval void - */ - void enterRoute(); - - /** - * Print all the waypoints and POIs of the custom route - * @returnval void - */ - void printRoute(); - - /** - * Print the Distance between current position and a closest POI - * @returnval void - */ - void printDistanceCurPosNextPoi(); - - /** - * TestCase to check if more waypoints are added when the memory is not available - * @returnval void - */ -#ifdef RUN_TEST_CASE_MORE_WAYPOINTS - void testCaseAddMoreWaypoints(); -#endif - - /** - * TestCase to check if more POIs are added when the memory is not available - * @returnval void - */ -#ifdef RUN_TEST_CASE_MORE_POIS - void testCaseAddMorePOIs(); -#endif - - /** - * TestCase to check if non existing POI is added to the route - * @returnval void - */ -#ifdef RUN_TEST_CASE_NON_EXIST_POI - void testCaseNonExistingPOI(); -#endif - - /** - * TestCase to check if deep copy is working - * @returnval void - */ -#ifdef RUN_TEST_CASE_DEEP_COPY - void testCaseDeepCopy(); -#endif - - /** - * TestCase to check when database is not available - * @returnval void - */ -#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE - void testCaseDatabaseNotAvailable(); -#endif - -public: - - /** - * Constructor - */ - CNavigationSystem(); - - /** - * Navigation System functionaliy's entry function - * @returnval void - */ - void run(); - -}; -/******************** -** CLASS END -*********************/ -#endif /* CNAVIGATIONSYSTEM_H */ diff --git a/NavigationSystem/Workspace/myCode/CPOI.cpp b/NavigationSystem/Workspace/myCode/CPOI.cpp deleted file mode 100644 index db254d1..0000000 --- a/NavigationSystem/Workspace/myCode/CPOI.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CPOI.cpp -* Author : Bharath Ramachandraiah -* Description : The file defines all the methods pertaining to the -* class type - class CPOI. -* The class CPOI is used to hold the information of a -* point of interest. -* -****************************************************************************/ - - -//System Include Files -#include -#include - -//Own Include Files -#include "CPOI.h" - -//Namespaces -using namespace std; - - -//Method Implementations -/** - * CPOI constructor: - * Sets the value of an object when created. - * param@ t_poi type - type of a Point of interest (IN) - * param@ string name - name of a Waypoint (IN) - * param@ double latitude - latitude of a Waypoint (IN) - * param@ double longitude - longitude of a Waypoint (IN) - */ -CPOI::CPOI(t_poi type, string name, string description, double latitude, double longitude) : CWaypoint(name, latitude, longitude) -{ - this->m_type = type; - this->m_description = description; -} - - -/* - * Return the current point of interest's values - * param@ string& name - name of a POI (OUT) - * param@ double& latitude - latitude of a POI's Waypoint (OUT) - * param@ double& longitude - longitude of a POI's Waypoint (OUT) - * param@ t_poi& type - point of interest type (OUT) - * param@ string&description- description of a POI (OUT) - * returnvalue@ void -*/ -void CPOI::getAllDataByReference(string& name, double& latitude, double& longitude, t_poi &type, string &description) -{ - type = this->m_type; - description = this->m_description; - - this->CWaypoint::getAllDataByReference(name, latitude, longitude); -} - - -/** - * Print all the information of a Point of Interest. - * returnvalue@ void - */ -void CPOI::print() -{ - string typeName; - - switch(this->m_type) - { - case RESTAURANT: - typeName = "Restaurant"; - break; - - case TOURISTIC: - typeName = "Touristic"; - break; - - case GASSTATION: - typeName = "Gas station"; - break; - - case UNIVERSITY: - typeName = "University"; - break; - - case DEFAULT_POI: - default: - typeName = "Default"; - break; - } - - cout << "Point of interest\n"; - cout << "===================\n"; - cout << " of type " << typeName << " : " << this->m_description << "\n"; - this->CWaypoint::print(MMSS); - cout << endl; -} diff --git a/NavigationSystem/Workspace/myCode/CPoiDatabase.cpp b/NavigationSystem/Workspace/myCode/CPoiDatabase.cpp deleted file mode 100644 index 9313f2d..0000000 --- a/NavigationSystem/Workspace/myCode/CPoiDatabase.cpp +++ /dev/null @@ -1,140 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CPoiDatabase.cpp -* Author : Bharath Ramachandraiah -* Description : The file defines all the methods pertaining to the -* class type - class CPoiDatabase. -* The class CPoiDatabase is used to hold the information -* of points of interest in an array. -* -****************************************************************************/ - - -//System Include Files -#include - -//Own Include Files -#include "CPoiDatabase.h" - -//Namespaces -using namespace std; - -//Method Implementations -/** - * CPoiDatabase constructor: - * When an object is created, this constructor gets called. - * Before this constructor is called, default constructor of CPOI class are invoked. - * - * Add all the POIs to the Database - */ -CPoiDatabase::CPoiDatabase() -{ - this->m_noPoi = 0; - - for (unsigned int Index = 0; Index m_POI)/sizeof(CPOI); Index++) - { - // Reset the Database elements - this->m_POI[Index] = CPOI(CPOI::DEFAULT_POI, "", "", 0, 0); - } - - // Add POIs to the Database - this->addPoi(CPOI::UNIVERSITY, "HDA BuildingC10" , "An awesome University", 49.86727, 8.638459); - this->addPoi(CPOI::GASSTATION, "Aral Tankst." , "Refuel your vehicle", 49.871558, 8.639206); - this->addPoi(CPOI::RESTAURANT, "Starbucks" , "A blissful coffee", 49.872409, 8.650744); - this->addPoi(CPOI::RESTAURANT, "SushiRestaurant" , "Asian food today!", 49.869365, 8.645922); - this->addPoi(CPOI::GASSTATION, "Aral Tankstelle" , "Refuel your vehicle", 49.868538, 8.645465); - this->addPoi(CPOI::TOURISTIC, "Church Holy" , "Freie Christengemeinde", 49.865072, 8.647415); - this->addPoi(CPOI::RESTAURANT, "Thessaloniki" , "Greek Restaurant ", 49.862869, 8.646691); - this->addPoi(CPOI::TOURISTIC, "Church 7 Days" , "Adventist Chruch", 49.839096, 8.646294); - this->addPoi(CPOI::GASSTATION, "Ladestation" , "Electric vehicle charge", 49.811698, 8.646074); - this->addPoi(CPOI::RESTAURANT, "El Quinto Vino" , "Spanish Restaurant ", 49.813422, 8.646246); - -#ifdef RUN_TEST_CASE_DATABASE_FULL - this->addPoi(CPOI::GASSTATION, "Ladestation" , "Electric vehicle charge", 49.811698, 8.646072); - this->addPoi(CPOI::RESTAURANT, "El Quinto Vino" , "Spanish Restaurant ", 49.813422, 8.646243); -#endif -} - - -/* - * Add a Point of interest to the database - * param@ t_poi type - point of interest type (IN) - * param@ string name - name of a POI (IN) - * param@ string description- description of a POI (IN) - * param@ double latitude - latitude of a POI's Waypoint (IN) - * param@ double longitude - longitude of a POI's Waypoint (IN) - * returnvalue@ void - */ -void CPoiDatabase::addPoi(CPOI::t_poi type, string name, string description, double latitude, double longitude) -{ - // check if the Database has free memory to store new POI - if (this->m_noPoi < sizeof(this->m_POI)/sizeof(CPOI)) - { - bool alreadyExist = false; - - // check if the POI already exists - for (int Index = 0; Index < this->m_noPoi; Index++) - { - CPOI::t_poi getTypeFromDB; - string getNameFromDB, getDescriptionFromDB; - double getLatitudeFromDB, getLongitudeFromDB; - - this->m_POI[Index].getAllDataByReference(getNameFromDB, getLatitudeFromDB, getLongitudeFromDB, getTypeFromDB, getDescriptionFromDB); - - if ((getTypeFromDB == type) && (getNameFromDB == name) && - (getLatitudeFromDB == latitude) && (getLongitudeFromDB == longitude)) - { - // POI already exists - alreadyExist = true; - break; - } - } - - if (!alreadyExist) - { - if ((CPOI::DEFAULT_POI != type) && - ((latitude >= LATITUDE_MIN) && (latitude <= LATITUDE_MAX)) && - ((longitude >= LONGITUDE_MIN) && (longitude <= LONGITUDE_MAX)) && - (!name.empty())) - { - this->m_POI[this->m_noPoi] = CPOI(type, name, description, latitude, longitude); - this->m_noPoi++; - } - else - { - cout << "WARNING: Invalid POI. Not added to the Database.\n"; - } - } - else - { - cout << "WARNING: POI already exists!\n"; - } - } - else - { - cout << "WARNING: Database full!\n"; - } -} - - -/** - * Get pointer to a POI from the Database which matches the name - * param@ string name - name of a POI (IN) - * returnvalue@ CPOI* - Pointer to a POI in the database - */ -CPOI* CPoiDatabase::getPointerToPoi(string name) -{ - CPOI *pPoi = 0; - - for (int Index = 0; Index < this->m_noPoi; Index++) - { - if (this->m_POI[Index].CWaypoint::getName() == name) - { - pPoi = &this->m_POI[Index]; - break; - } - } - - return pPoi; -} diff --git a/NavigationSystem/Workspace/myCode/CPoiDatabase.h b/NavigationSystem/Workspace/myCode/CPoiDatabase.h deleted file mode 100644 index 93e06fa..0000000 --- a/NavigationSystem/Workspace/myCode/CPoiDatabase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CPoiDatabase.h -* Author : Bharath Ramachandraiah -* Description : The file defines a class CPoiDatabase. -* The class CPoiDatabase is used to hold the information -* of points of interest in an array. -* -****************************************************************************/ - -#ifndef CPOIDATABASE_H -#define CPOIDATABASE_H - -//System Include Files -#include - -//Own Include Files -#include "CPOI.h" - -//Macros -#define DATBASE_SIZE 10 -//#define RUN_TEST_CASE_DATABASE_FULL - -class CPoiDatabase { -private: - /** - * An array to store different point of interests. - */ - CPOI m_POI[DATBASE_SIZE]; - - /** - * A counter to keep track of number of point of interests. - */ - int m_noPoi; -public: - - /** - * CPoiDatabase constructor: - * When an object is created, this constructor gets called. - * Before this constructor is called, default constructor of CPOI class are invoked. - * - * Add all the POIs to the Database - */ - CPoiDatabase(); - - /** - * Add a Point of interest to the database - * param@ t_poi type - point of interest type (IN) - * param@ string name - name of a POI (IN) - * param@ string description- description of a POI (IN) - * param@ double latitude - latitude of a POI's Waypoint (IN) - * param@ double longitude - longitude of a POI's Waypoint (IN) - * returnvalue@ void - */ - void addPoi(CPOI::t_poi type, std::string name, std::string description, double latitude, double longitude); - - /** - * Get pointer to a POI from the Database which matches the name - * param@ string name - name of a POI (IN) - * returnvalue@ CPOI* - Pointer to a POI in the database - */ - CPOI* getPointerToPoi(std::string name); -}; -/******************** -** CLASS END -*********************/ -#endif /* CPOIDATABASE_H */ diff --git a/NavigationSystem/Workspace/myCode/CRoute.cpp b/NavigationSystem/Workspace/myCode/CRoute.cpp deleted file mode 100644 index b429fa0..0000000 --- a/NavigationSystem/Workspace/myCode/CRoute.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CRoute.cpp -* Author : Bharath Ramachandraiah -* Description : The file defines all the methods pertaining to the -* class type - class CRoute. -* The class CRoute is used to hold the information -* of points of interest and waypoints of a Route. -* -****************************************************************************/ - -//System Include Files -#include - -//Own Include Files -#include "CRoute.h" - -//Namespace -using namespace std; - - -//Method Implementations -/** - * CRoute Constructor: - * Sets the value when an object is created. - * @param unsigned int maxWp - maximum waypoints (IN) - * @param unsigned int maxPoi - maximum POI (IN) - */ -CRoute::CRoute(unsigned int maxWp, unsigned int maxPoi) -{ - this->m_nextWp = 0; - this->m_maxWp = maxWp; - this->m_nextPoi = 0; - this->m_maxPoi = maxPoi; - this->m_pPoi = 0; - this->m_pWaypoint = 0; - this->m_pPoiDatabase = 0; - - if (this->m_maxWp) - { - this->m_pWaypoint = new (nothrow) CWaypoint[this->m_maxWp]; - - if (!this->m_pWaypoint) - { - cout << "WARNING: Memory allocation to store waypoints for the route failed.\n"; - } - } - - if (this->m_maxPoi) - { - this->m_pPoi = new (nothrow) CPOI*[this->m_maxPoi]; - - if (!this->m_pPoi) - { - cout << "WARNING: Memory allocation to store POIs for the route failed.\n"; - } - - // Initialise all the pointers to null - for (unsigned int Index = 0; (Index < this->m_maxPoi) && this->m_pPoi; Index++) - { - this->m_pPoi[Index] = 0; - } - } -} - - -/** - * CRoute Constructor: - * Sets the value when an object is created by deep copy. - * @param CRoute const &origin - CRoute const object (IN) - */ -CRoute::CRoute(CRoute const &origin) -{ - cout << "INFO: Performing deep copy.\n"; - - // Perform Deep copy - this->m_nextWp = origin.m_nextWp; - this->m_maxWp = origin.m_maxWp; - this->m_nextPoi = origin.m_nextPoi; - this->m_maxPoi = origin.m_maxPoi; - this->m_pPoi = 0; - this->m_pWaypoint = 0; - this->m_pPoiDatabase = origin.m_pPoiDatabase; - - if (this->m_maxWp) - { - this->m_pWaypoint = new (nothrow) CWaypoint[this->m_maxWp]; - - if (!this->m_pWaypoint) - { - cout << "WARNING: Memory allocation to store waypoints for the route failed.\n"; - } - - for (unsigned int Index = 0; (Index < this->m_maxWp) && this->m_pWaypoint && origin.m_pWaypoint; Index++) - { - this->m_pWaypoint[Index] = origin.m_pWaypoint[Index]; - } - } - - if (this->m_maxPoi) - { - this->m_pPoi = new (nothrow) CPOI*[this->m_maxPoi]; - - if (!this->m_pPoi) - { - cout << "WARNING: Memory allocation to store POIs for the route failed.\n"; - } - - for (unsigned int Index = 0; (Index < this->m_maxPoi) && this->m_pPoi && origin.m_pPoi; Index++) - { - this->m_pPoi[Index] = origin.m_pPoi[Index]; - } - } -} - - -/** - * CRoute Destructor: - * When an object is about to destroy this function will be invoked. - */ -CRoute::~CRoute() -{ - // cleanup dynamic memories - delete[] this->m_pWaypoint; - delete[] this->m_pPoi; - - // disconnect from the Database - this->m_pPoiDatabase = 0; -} - - -/** - * Get the address of the POI Database and connect it to the CRoute - * @param CPoiDatabase* pPoiDB - pointer to the POI Database (IN) - * @returnval void - */ -void CRoute::connectToPoiDatabase(CPoiDatabase* pPoiDB) -{ - // connect to the POI Database - if (pPoiDB) - { - this->m_pPoiDatabase = pPoiDB; - cout << "INFO: Database connected to the route.\n"; - } - else - { - cout << "WARNING: Database not connected to the route.\n"; - } -} - - -/** - * Add the waypoint to current route - * @param CWaypoint const &wp - waypoint (IN) - * @returnval void - */ -void CRoute::addWaypoint(CWaypoint const &wp) -{ - // check if the dynamic memory is allocated - if (this->m_pWaypoint) - { - if (this->m_nextWp < this->m_maxWp) - { - this->m_pWaypoint[this->m_nextWp] = wp; - this->m_nextWp++; - } - else - { - cout << "WARNING: memory full, waypoint can not be added to the route.\n"; - } - } - else - { - cout << "WARNING: Memory not created to add any waypoints to the route.\n"; - } -} - - -/** - * Add the POI to current route - * @param string namePoi - name of POI (IN) - * @returnval void - */ -void CRoute::addPoi(string namePoi) -{ - // check if the dynamic memory is allocated - if (this->m_pPoi) - { - if (this->m_nextPoi < this->m_maxPoi) - { - CPOI* pPoi = 0; - - // check if the Database is connected - if (this->m_pPoiDatabase) - { - pPoi = this->m_pPoiDatabase->getPointerToPoi(namePoi); - - if (pPoi) - { - // check if the POI is already added to the route - bool AlreadyExists = false; - - for (unsigned int Index = 0; Index < this->m_nextPoi; Index++) - { - if (pPoi == this->m_pPoi[this->m_nextPoi]) - { - AlreadyExists = true; - } - } - - if (!AlreadyExists) - { - if (!namePoi.empty()) - { - this->m_pPoi[this->m_nextPoi] = this->m_pPoiDatabase->getPointerToPoi(namePoi); - this->m_nextPoi++; - } - else - { - cout << "WARNING: Invalid POI can't be added to the route.\n"; - } - } - else - { - cout << "WARNING: POI already added to the route.\n"; - } - } - else - { - cout << "WARNING: The Point of interest is not available in the Database.\n"; - } - } - else - { - cout << "WARNING: The Database is not available.\n"; - } - } - else - { - cout << "WARNING: memory full, POI can not be added to the route.\n"; - } - } - else - { - cout << "WARNING: Memory not created to add any POIs to the route.\n"; - } -} - - -/** - * Calculates the distance between waypoint and POI - * @param CWaypoint const &wp - waypoint (IN) - * @param CPOI& poi - POI (IN) - * @return double - Distance in Kms - */ -double CRoute::getDistanceNextPoi(CWaypoint const &wp, CPOI& poi) -{ - double shortestDistance = 0, currentDistance = 0; - - if (this->m_pPoi) - { - if (this->m_nextPoi) - { - // assume 0th element has shortest distance - shortestDistance = this->m_pPoi[0]->CWaypoint::calculateDistance(wp); - - // perform linear comparison for shortest distance - for (unsigned int Index = 0; Index < this->m_nextPoi; Index++) - { - currentDistance = this->m_pPoi[Index]->CWaypoint::calculateDistance(wp); - - if (currentDistance <= shortestDistance) - { - shortestDistance = currentDistance; - poi = *this->m_pPoi[Index]; - } - } - } - else - { - cout << "WARNING: No POIs added to the current route.\n"; - } - } - else - { - cout << "WARNING: No POIs added to the current route.\n"; - } - - return shortestDistance; -} - - -/** - * prints the current waypoints and POIs - */ -void CRoute::print() -{ - cout << "=============================================" << endl << endl; - - // print all the waypoints in the route - cout << "The route has " << this->m_nextWp << " waypoints (maximum : " << this->m_maxWp << ")\n"; - - for (unsigned int Index = 0; (Index < this->m_nextWp) && this->m_pWaypoint; Index++) - { - this->m_pWaypoint[Index].print(MMSS); - } - - cout << "=============================================" << endl << endl; - - // print all the POIs in the route - cout << "The route has " << this->m_nextPoi << " POIs (maximum : " << this->m_maxPoi << ")\n"; - - for (unsigned int Index = 0; (Index < this->m_nextPoi) && this->m_pPoi; Index++) - { - this->m_pPoi[Index]->CWaypoint::print(MMSS); - } - - cout << "=============================================" << endl << endl; -} diff --git a/NavigationSystem/Workspace/myCode/CRoute.h b/NavigationSystem/Workspace/myCode/CRoute.h deleted file mode 100644 index bdd2adc..0000000 --- a/NavigationSystem/Workspace/myCode/CRoute.h +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : CRoute.h -* Author : Bharath Ramachandraiah -* Description : The file defines a class CRoute. -* The class CRoute is used to hold the information -* of points of interest and waypoints of a Route. -* -****************************************************************************/ - -#ifndef CROUTE_H -#define CROUTE_H - -//System Include Files -#include - -//Own Include Files -#include "CPoiDatabase.h" -#include "CWaypoint.h" -#include "CPOI.h" - -class CRoute { -private: - - /** - * Basepointer to an array of Waypoints in the route - */ - CWaypoint* m_pWaypoint; - - /** - * Maximum number of Waypoints that can be added to the route - */ - unsigned int m_maxWp; - - /** - * Number of Waypoints present in the current route - */ - unsigned int m_nextWp; - - /** - * A pointer to an array of pointers containing the POIs from Database of the current route - */ - CPOI* * m_pPoi; - - /** - * Maximum number of Points of interest that can be added to the route - */ - unsigned int m_maxPoi; - - /** - * Number of Points of interest present in the current route - */ - unsigned int m_nextPoi; - - /** - * A pointer the Point of interest Database - */ - CPoiDatabase* m_pPoiDatabase; -public: - - /** - * CRoute Constructor: - * Sets the value when an object is created. - * @param unsigned int maxWp - maximum waypoints (IN) - * @param unsigned int maxPoi - maximum POI (IN) - */ - CRoute(unsigned int maxWp, unsigned int maxPoi); - - /** - * CRoute Constructor: - * Sets the value when an object is created by deep copy. - * @param CRoute const &origin - CRoute const object (IN) - */ - CRoute(CRoute const &origin); - - /** - * CRoute Destructor: - * When an object is about to destroy this function will be invoked. - */ - ~CRoute(); - - /** - * Get the address of the POI Database and connect it to the CRoute - * @param CPoiDatabase* pPoiDB - pointer to the POI Database (IN) - * @returnval void - */ - void connectToPoiDatabase(CPoiDatabase* pPoiDB); - - /** - * Add the waypoint to current route - * @param CWaypoint const &wp - waypoint (IN) - * @returnval void - */ - void addWaypoint(CWaypoint const &wp); - - /** - * Add the POI to current route - * @param string namePoi - name of POI (IN) - * @returnval void - */ - void addPoi(std::string namePoi); - - /** - * Calculates the distance between waypoint and POI - * @param CWaypoint const &wp - waypoint (IN) - * @param CPOI& poi - POI (IN) - * @return double - Distance in Kms - */ - double getDistanceNextPoi(CWaypoint const &wp, CPOI& poi); - - /** - * prints the current waypoints and POIs - */ - void print(); -}; -/******************** -** CLASS END -*********************/ -#endif /* CROUTE_H */ diff --git a/NavigationSystem/Workspace/myCode/Model/Model.dfPackage b/NavigationSystem/Workspace/myCode/Model/Model.dfPackage deleted file mode 100644 index ba47639..0000000 --- a/NavigationSystem/Workspace/myCode/Model/Model.dfPackage +++ /dev/null @@ -1,29 +0,0 @@ -package id6blvljo18z0h7jo18z9e5; - -/** -@version 2.0 -@physicalPackage -@__modelType diagram -*/ -class diagram { -}/** -@__tags -@shapeType ClassDiagram -@changelog rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVz -aG9sZHhwP0AAAAAAAAx3CAAAABAAAAABc3IADmphdmEubGFuZy5Mb25nO4vkkMyPI98CAAFKAAV2 -YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAAWbW3ogAc3IAE2phdmEudXRp -bC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAApzcgAlZGUubW5sLmRvY2Jv -b2s0VEEuaW1wbC5DaGFuZ2VMb2dFbnRyeQeNjrX5qiSfAgADTAAIaG9zdG5hbWV0ABJMamF2YS9s -YW5nL1N0cmluZztMAARuYW1lcQB+AAhMAAR1c2VycQB+AAh4cHQAD0RFU0tUT1AtTU5MNDdGMnQA -BU1vZGVsdAAFcmJoYXJ4eA== -*/ -class __tags { -}/** -@__options -*/ -class __options { -}/** -@__positions -*/ -class __positions { -} \ No newline at end of file diff --git a/NavigationSystem/Workspace/myCode/NavigationSystem.tws b/NavigationSystem/Workspace/myCode/NavigationSystem.tws deleted file mode 100644 index 0a3f225..0000000 --- a/NavigationSystem/Workspace/myCode/NavigationSystem.tws +++ /dev/null @@ -1,6 +0,0 @@ -workspace.diagram.active = -workspace.diagram.open.0 = -workspace.editor.active = D:\HDA\1_sem\System Design (APT)\Lab\Assignment_1\Workspace\myCode\CPOI.h -workspace.editor.open.0 = D:\HDA\1_sem\System Design (APT)\Lab\Assignment_1\Workspace\myCode\CPOI.h -workspace.editor.open.1 = D:\HDA\1_sem\System Design (APT)\Lab\Assignment_1\Workspace\myCode\CGPSSensor.h -workspace.editor.open.2 = D:\HDA\1_sem\System Design (APT)\Lab\Assignment_1\Workspace\myCode\CWaypoint.h diff --git a/NavigationSystem/Workspace/myCode/default.dfPackage b/NavigationSystem/Workspace/myCode/default.dfPackage deleted file mode 100644 index d3ea883..0000000 --- a/NavigationSystem/Workspace/myCode/default.dfPackage +++ /dev/null @@ -1,139 +0,0 @@ -package idicshbjnvkfw4mjnvkfx7y; - -/** -@version 2.0 -@physicalPackage -@__modelType diagram -*/ -class diagram { -/** -@__ref -@__modelType reference -*/ -class reference1 { -} -/** -@__ref -@__modelType reference -@__fqn -*/ -class reference { -} -/** -@__ref -@__modelType reference */ -class reference2 { -} -/** -@__ref -@__modelType reference -*/ -class reference3 { -} -/** -@__ref -@__modelType reference -*/ -class reference4 { -} -/** -@__ref -@__modelType reference -*/ -class reference5 { -} -/** -@__ref -@__modelType reference -*/ -class reference6 { -} -/** -@__ref -@__modelType reference -*/ -class reference7 { -} -}/** -@__tags -@shapeType ClassDiagram -@changelog rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVz -aG9sZHhwP0AAAAAAAAx3CAAAABAAAAAEc3IADmphdmEubGFuZy5Mb25nO4vkkMyPI98CAAFKAAV2 -YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAAWbHa3QAc3IAE2phdmEudXRp -bC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAApzcgAlZGUubW5sLmRvY2Jv -b2s0VEEuaW1wbC5DaGFuZ2VMb2dFbnRyeQeNjrX5qiSfAgADTAAIaG9zdG5hbWV0ABJMamF2YS9s -YW5nL1N0cmluZztMAARuYW1lcQB+AAhMAAR1c2VycQB+AAh4cHQAD0RFU0tUT1AtTU5MNDdGMnQA -CTxkZWZhdWx0PnQABXJiaGFyeHNxAH4AAgAAAWbW3ogAc3EAfgAFAAAAAXcEAAAACnNxAH4AB3QA -D0RFU0tUT1AtTU5MNDdGMnQACTxkZWZhdWx0PnQABXJiaGFyeHNxAH4AAgAAAWbCRRgAc3EAfgAF -AAAAAXcEAAAACnNxAH4AB3QAD0RFU0tUT1AtTU5MNDdGMnQACTxkZWZhdWx0PnQABXJiaGFyeHNx -AH4AAgAAAWbmUZwAc3EAfgAFAAAAAXcEAAAACnNxAH4AB3QAD0RFU0tUT1AtTU5MNDdGMnQACTxk -ZWZhdWx0PnQABXJiaGFyeHg= -@elementChangelogs rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVz -aG9sZHhwP0AAAAAAAAx3CAAAABAAAAAGdAAcPG9pcmVmOmNwcCNDbGFzcyNDUE9JOm9pcmVmPnNx -AH4AAD9AAAAAAAAMdwgAAAAQAAAAAnNyAA5qYXZhLmxhbmcuTG9uZzuL5JDMjyPfAgABSgAFdmFs -dWV4cgAQamF2YS5sYW5nLk51bWJlcoaslR0LlOCLAgAAeHAAAAFm1t6IAHNyABNqYXZhLnV0aWwu -QXJyYXlMaXN0eIHSHZnHYZ0DAAFJAARzaXpleHAAAAABdwQAAAAKc3IAJWRlLm1ubC5kb2Nib29r -NFRBLmltcGwuQ2hhbmdlTG9nRW50cnkHjY61+aoknwIAA0wACGhvc3RuYW1ldAASTGphdmEvbGFu -Zy9TdHJpbmc7TAAEbmFtZXEAfgAKTAAEdXNlcnEAfgAKeHB0AA9ERVNLVE9QLU1OTDQ3RjJ0AARD -UE9JdAAFcmJoYXJ4c3EAfgAEAAABZuZRnABzcQB+AAcAAAABdwQAAAAKc3EAfgAJdAAPREVTS1RP -UC1NTkw0N0YydAAEQ1BPSXQABXJiaGFyeHh0AB08b2lyZWY6Y3BwI0NsYXNzI3RfcG9pOm9pcmVm -PnB0ACI8b2lyZWY6Y3BwI0NsYXNzI3BvaV90eXBlX3Q6b2lyZWY+cHQAKTxvaXJlZjpjcHAjQ2xh -c3MjQ05hdmlnYXRpb25TeXN0ZW06b2lyZWY+c3EAfgAAP0AAAAAAAAx3CAAAABAAAAACc3EAfgAE -AAABZtbeiABzcQB+AAcAAAABdwQAAAAKc3EAfgAJcQB+AAx0ABFDTmF2aWdhdGlvblN5c3RlbXEA -fgAOeHNxAH4ABAAAAWbmUZwAc3EAfgAHAAAAAXcEAAAACnNxAH4ACXEAfgASdAARQ05hdmlnYXRp -b25TeXN0ZW1xAH4AFHh4dAAkPG9pcmVmOmNwcCNDbGFzcyNDUG9pRGF0YWJhc2U6b2lyZWY+c3EA -fgAAP0AAAAAAAAx3CAAAABAAAAACc3EAfgAEAAABZtbeiABzcQB+AAcAAAABdwQAAAAKc3EAfgAJ -cQB+AAx0AAxDUG9pRGF0YWJhc2VxAH4ADnhzcQB+AAQAAAFm5lGcAHNxAH4ABwAAAAF3BAAAAApz -cQB+AAlxAH4AEnQADENQb2lEYXRhYmFzZXEAfgAUeHh0ACE8b2lyZWY6Y3BwI0NsYXNzI0NXYXlw -b2ludDpvaXJlZj5weA== -*/ -class __tags { -}/** -@__options -*/ -class __options { -}/** -@__positions =938,322,28,16,0:oigroup> -=170,40,267,270,0:oigroup> -=970,121,437,121:oigroup> -=50,40,83,95,1:oigroup> -=770,690,1175,414:oigroup> -=629,263,509,310:oigroup> -=970,362,588,362:oigroup> -=610,285,437,285:oigroup> -=620,690,200,190,1:oigroup> -=745,690,1027,224:oigroup> -=470,310,118,171,1:oigroup> -=653,690,350,310:oigroup> -=120,70,261,16,1:oigroup> -=620,730,356,730:oigroup> -=130,40,261,16,1:oigroup> -=120,60,261,16,1:oigroup> -=170,670,186,101,1:oigroup> -=1056,270,1056,224:oigroup> -=970,50,172,174,1:oigroup> -=686,690,529,481:oigroup> -=991,192,548,310:oigroup> -=550,540,194,16,1:oigroup> -=720,690,720,582:oigroup> -=910,790,153,84,0:oigroup> -=610,280,220,302,0:oigroup> -=970,270,410,144,0:oigroup> -=263,670,263,310:oigroup> -=571,140,116,123,1:oigroup> -=830,342,970,342:oigroup> -=970,166,687,166:oigroup> -=720,280,998,224:oigroup> -=441,265,28,16,0:oigroup> -=590,820,186,16,1:oigroup> -*/ -class __positions { -} -/** -@shapeType Note -@__modelType node -@name Note1 -@text A Navigation System having POI Database and a GPS Sensor -*/ -class nodeidb784jjo6yhs70jo6yj4ln { -} diff --git a/NavigationSystem/Workspace/myCode/main.cpp b/NavigationSystem/Workspace/myCode/main.cpp deleted file mode 100644 index 3ebd38d..0000000 --- a/NavigationSystem/Workspace/myCode/main.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/*************************************************************************** -*============= Copyright by Darmstadt University of Applied Sciences ======= -**************************************************************************** -* Filename : main.cpp -* Author : Bharath Ramachandraiah -* Description : The entry file for the Navigation System Application. -* -****************************************************************************/ - -//System Include Files -#include -#include - -//Own Include Files -#include "CWaypoint.h" -#include "CPOI.h" -#include "CPoiDatabase.h" -#include "CNavigationSystem.h" - -//Namespaces -using namespace std; - -//Macros -//#define RUN_TEST_CASE - -#define LATITUDE_AMSTERDAM 52.3680 -#define LONGITUDE_AMSTERDAM 4.9036 -#define LATITUDE_DARMSTADT 49.8728 -#define LONGITUDE_DARMSTADT 8.6512 -#define LATITUDE_BERLIN 52.5200 -#define LONGITUDE_BERLIN 13.4050 -#define LATITUDE_TOKYO 35.6895 -#define LONGITUDE_TOKYO 139.691 - -/** - * main function: - * An entry point to Navigation System Application. - */ -int main (void) -{ - cout << "Navigation System:" << endl << endl; - - // Set the precision to 6 decimal places - cout << std::fixed << std::setprecision(6); - - // Solution (Exercise 1.1; section d): - CWaypoint amsterdam("Amsterdam", LATITUDE_AMSTERDAM, LONGITUDE_AMSTERDAM); - CWaypoint darmstadt("Darmstadt", LATITUDE_DARMSTADT, LONGITUDE_DARMSTADT); - CWaypoint berlin("Berlin", LATITUDE_BERLIN, LONGITUDE_BERLIN); - CWaypoint tokio("Tokyo", LATITUDE_TOKYO, LONGITUDE_TOKYO); - CWaypoint newWaypoint; - - // Solution (Exercise 1.1; section f) - cout << "==================================================\n"; - cout << "Exercise 1.1; section f\n"; - berlin.print(DEGREE); - berlin.print(MMSS); - cout << "==================================================\n"; - - // Solution (Exercise 1.1; section g) -#ifdef RUN_TEST_CASE - { - cout << "==================================================\n"; - cout << "Exercise 1.1; section g\n"; - if ("Berlin" == berlin.getName()) - { - cout << "TEST CASE: Get name from CWaypoint\t: PASS\n"; - } - else - { - cout << "TEST CASE: Get name from CWaypoint\t: FAIL\n"; - } - - if (LATITUDE_BERLIN == berlin.getLatitude()) - { - cout << "TEST CASE: Get Latitude from CWaypoint\t: PASS\n"; - } - else - { - cout << "TEST CASE: Get Latitude from CWaypoint\t: FAIL\n"; - } - - if (LONGITUDE_BERLIN == berlin.getLongitude()) - { - cout << "TEST CASE: Get Longitude from CWaypoint\t: PASS\n"; - } - else - { - cout << "TEST CASE: Get Longitude from CWaypoint\t: FAIL\n"; - } - cout << "==================================================\n"; - } -#endif - - // Solution (Exercise 1.1; section h) -#ifdef RUN_TEST_CASE - { - string name; - double latitude, longitude; - - cout << "==================================================\n"; - cout << "Exercise 1.1; section h\n"; - - tokio.getAllDataByReference(name, latitude, longitude); - -#ifdef SHOWADRESS - cout << "Local variables at addresses : \n"; - cout << "Attribute Name \t" <<"Attribute Address \t"<< "Attribute Size \t" << "Attribute Value\n"; - cout << "name \t\t" << &name << "\t\t" << name.size() << "\t\t" << name << "\n"; - cout << "latitude \t" << &latitude << "\t\t" << sizeof(latitude) << "\t\t" << latitude << "\n"; - cout << "longitude \t" << &longitude << "\t\t" << sizeof(longitude) << "\t\t" << longitude << "\n"; - cout << "==================================================\n"; -#endif - } -#endif - - // Solution (Exercise 1.1; section i) -#ifdef RUN_TEST_CASE - { - double distance; - - cout << "==================================================\n"; - cout << "Exercise 1.1; section i\n"; - - distance = amsterdam.calculateDistance(berlin); - cout << "Distance between " << amsterdam.getName() << " and " << berlin.getName() << " : " << distance << " Kms (approx.)\n"; - - distance = berlin.calculateDistance(tokio); - cout << "Distance between " << berlin.getName() << " and " << tokio.getName() << " : " << distance << " Kms (approx.)\n"; - cout << "==================================================\n"; - } -#endif - -#ifdef RUN_TEST_CASE - { - struct Lookup_s - { - string name; - double latitude; - double longitude; - }; - - struct Lookup_s LookUpTable[][2] = { - {{"Berlin " , 52.520007 , 13.404954 } , {"Amsterdam " , 52.367984 , 4.903561 }}, - {{"Berlin " , 52.520007 , 13.404954 } , {"New York " , 40.712775 , -74.005973 }}, - {{"Berlin " , 52.520007 , 13.404954 } , {"Sydney(A) " , -33.86882 , 151.209296 }}, - {{"Berlin " , 52.520007 , 13.404954 } , {"Rio " , -22.906847 , -43.172896 }}, - {{"California " , 36.778261 , -119.417932} , {"Amsterdam " , 52.367984 , 4.903561 }}, - {{"California " , 36.778261 , -119.417932} , {"New York " , 40.712775 , -74.005973 }}, - {{"California " , 36.778261 , -119.417932} , {"Sydney(A) " , -33.86882 , 151.209296 }}, - {{"California " , 36.778261 , -119.417932} , {"Rio " , -22.906847 , -43.172896 }}, - {{"Melbourne " , -37.813628 , 144.963058} , {"Amsterdam " , 52.367984 , 4.903561 }}, - {{"Melbourne " , -37.813628 , 144.963058} , {"New York " , 40.712775 , -74.005973 }}, - {{"Melbourne " , -37.813628 , 144.963058} , {"Sydney(A) " , -33.86882 , 151.209296 }}, - {{"Melbourne " , -37.813628 , 144.963058} , {"Rio " , -22.906847 , -43.172896 }}, - {{"Argentina " , -38.416097 , -63.616672 } , {"Amsterdam " , 52.367984 , 4.903561 }}, - {{"Argentina " , -38.416097 , -63.616672 } , {"New York " , 40.712775 , -74.005973 }}, - {{"Argentina " , -38.416097 , -63.616672 } , {"Sydney(A) " , -33.86882 , 151.209296 }}, - {{"Argentina " , -38.416097 , -63.616672 } , {"Rio " , -22.906847 , -43.172896 }}, - }; - - cout << "Distance Test:" << endl; - for (unsigned int index = 0; index < sizeof(LookUpTable)/(2 * sizeof(Lookup_s)); index++) - { - CWaypoint place1(LookUpTable[index][0].name, LookUpTable[index][0].latitude, LookUpTable[index][0].longitude); - CWaypoint place2(LookUpTable[index][1].name, LookUpTable[index][1].latitude, LookUpTable[index][1].longitude); - - cout << place1.getName() << "\tto\t" << place2.getName() << ": " << place1.calculateDistance(place2) << " Kms (approx.)\n"; - } - } -#endif - - CNavigationSystem navigationSystem; - - navigationSystem.run(); - - return 0; -} diff --git a/NavigationSystem/myCode/CCSV.cpp b/NavigationSystem/myCode/CCSV.cpp new file mode 100644 index 0000000..27f91b5 --- /dev/null +++ b/NavigationSystem/myCode/CCSV.cpp @@ -0,0 +1,536 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CCSV.cpp +* Author : Bharath Ramachandraiah +* Description : The file defines all the methods pertaining to the +* class type - class CCSV. +* The class CCSV is implement the persistent feature using +* the CPersistanceStorage abstract class's interfaces. +* +****************************************************************************/ + +//System Include Files +#include +#include +#include +#include + +//Own Include Files +#include "CCSV.h" +#include "CPOI.h" + +//Namespaces +using namespace std; + +//Macros +//#define RUN_TEST_CASE + +//Class constant variables +const std::string CCSV::delimiters(",;"); + + +/** + * Constructor + */ +CCSV::CCSV() +{ + this->lineCounter = 0; +} + +/** + * Destructor + */ +CCSV::~CCSV() +{ + // do nothing +} + + + +/** +* Set the name of the media to be used for persistent storage. +* The exact interpretation of the name depends on the implementation +* of the component. +* +* @param name the media to be used +* @returnval void +*/ +void CCSV::setMediaName(string name) +{ + this->mediaName = name; +} + + +/** +* Write the data to the persistent storage. +* +* @param waypointDb the data base with way points +* @param poiDb the database with points of interest +* @return true if the data could be saved successfully +*/ +bool CCSV::writeData (const CWpDatabase& waypointDb, const CPoiDatabase& poiDb) +{ + bool ret = true; + ofstream fileStream; + string fileName; + + fileName = this->mediaName + "-wp.txt"; + fileStream.precision(10); + fileStream.clear(); + + // Write Waypoints + fileStream.open(fileName.c_str(), ofstream::out); + + cout << "=======================================================\n"; + cout << "INFO: Waypoint Database backup request\n"; + + // is the open successful? + if (!fileStream.fail()) + { + Wp_Map_t Waypoints; + Wp_Map_Itr_t itr; + string name; + double latitude, longitude; + + Waypoints = waypointDb.getWpsFromDatabase(); + + for (itr = Waypoints.begin(); itr != Waypoints.end(); ++(itr)) + { + // assuming all the elements in Database is valid + itr->second.getAllDataByReference(name, latitude, longitude); + + fileStream << name << "; "; + fileStream << latitude << "; "; + fileStream << longitude << "\n"; + + if (fileStream.fail()) + { + fileStream.clear(); + cout << "WARNING: Error writing a Waypoint into the file.\n" << itr->second << endl; + ret = false; + } + } + } + else + { + fileStream.clear(); + cout << "WARNING: Error opening the file to write - " << fileName << endl; + ret = false; + } + + fileStream.flush(); + fileStream.close(); + + cout << "=======================================================\n"; + + fileName = this->mediaName + "-poi.txt"; + fileStream.precision(10); + fileStream.clear(); + + // Write Point of Interests + fileStream.open(fileName.c_str(), ofstream::out); + + cout << "=======================================================\n"; + cout << "INFO: POI Database backup request\n"; + + // is the open successful? + if (!fileStream.fail()) + { + Poi_Map_t Pois; + Poi_Map_Itr_t itr; + CPOI::t_poi type; + string name, description, typeName; + double latitude, longitude; + + Pois = poiDb.getPoisFromDatabase(); + + for (itr = Pois.begin(); itr != Pois.end(); ++(itr)) + { + // assuming all the elements in Database is valid + itr->second.getAllDataByReference(name, latitude, longitude, type, description); + typeName = itr->second.getPoiTypeName(); + + fileStream << typeName << "; "; + fileStream << name << "; "; + fileStream << description << "; "; + fileStream << latitude << "; "; + fileStream << longitude << "\n"; + + if (fileStream.fail()) + { + fileStream.clear(); + cout << "WARNING: Error writing a POI into the file.\n" << itr->second << endl; + ret = false; + } + } + } + else + { + fileStream.clear(); + cout << "WARNING: Error opening the file to write - " << fileName << endl; + ret = false; + } + + fileStream.flush(); + fileStream.close(); + + cout << "=======================================================\n"; + + return ret; +} + + +/** +* Fill the databases with the data from persistent storage. If +* merge mode is MERGE, the content in the persistent storage +* will be merged with any content already existing in the data +* bases. If merge mode is REPLACE, already existing content +* will be removed before inserting the content from the persistent +* storage. +* +* @param waypointDb the the data base with way points +* @param poiDb the database with points of interest +* @param mode the merge mode +* @return true if the data could be read successfully +*/ +bool CCSV::readData (CWpDatabase& waypointDb, CPoiDatabase& poiDb, MergeMode mode) +{ + bool ret = true; + ifstream fileStream; + string fileName; + + fileName = this->mediaName + "-wp.txt"; + fileStream.precision(10); + fileStream.clear(); + + // Read Waypoints + fileStream.open(fileName.c_str(), ifstream::in); + + // is the open successful? + if (!fileStream.fail()) + { + string readLine; + + this->lineCounter = 0; + + cout << "=======================================================\n"; + if (mode == CCSV::MERGE) + { + cout << "INFO: Waypoint Database Merge Request.\n"; + } + else if (mode == CCSV::REPLACE) + { + waypointDb.resetWpsDatabase(); + cout << "INFO: Waypoint Database Replace Request.\n"; + } + else + { + cout << "ERROR: Waypoint Database Unknown MergeMode Request.\n"; + return false; + } + + cout << "=======================================================\n"; + + while (!fileStream.eof()) + { + getline(fileStream, readLine, '\n'); + this->lineCounter++; + + if (readLine.length() == 0) + { + // empty line - ignore them + cout << "ERROR: Empty line in line " << this->lineCounter << "\n"; + continue; + } + + if (fileStream.fail()) + { + fileStream.clear(); + cout << "ERROR: Reading a waypoint from the file - " << fileName << endl; + ret = false; + } + else + { + string name; + double latitude = (LATITUDE_MAX + 1), longitude = (LONGITUDE_MAX + 1); // set to invalid values + + if (!this->parserEachLine(readLine, name, latitude, longitude)) + { + continue; + } + + CWaypoint wp(name, latitude, longitude); + + if (!wp.getName().empty()) + { + waypointDb.addWaypoint(wp); + } + else + { + cout << "ERROR: Invalid Waypoint in line " << this->lineCounter << ": " << readLine << "\n"; + } + } + } + } + else + { + fileStream.clear(); + cout << "WARNING: Error opening the file to read - " << fileName << endl; + ret = false; + } + + fileStream.close(); + + fileName = this->mediaName + "-poi.txt"; + fileStream.precision(10); + fileStream.clear(); + + // Read POIs + fileStream.open(fileName.c_str(), ifstream::in); + + // is the open successful? + if (!fileStream.fail()) + { + string readLine; + + this->lineCounter = 0; + + cout << "=======================================================\n"; + + if (mode == CCSV::MERGE) + { + cout << "INFO: POI Database Merge Request.\n"; + } + else if (mode == CCSV::REPLACE) + { + poiDb.resetPoisDatabase(); + cout << "INFO: POI Database Replace Request.\n"; + } + else + { + cout << "ERROR: POI Database Unknown MergeMode Request.\n"; + return false; + } + + cout << "=======================================================\n"; + + while (!fileStream.eof()) + { + getline(fileStream, readLine, '\n'); + this->lineCounter++; + + if (readLine.length() == 0) + { + // empty line - ignore them + cout << "ERROR: Empty line in line " << this->lineCounter << "\n"; + continue; + } + + if (fileStream.fail()) + { + fileStream.clear(); + cout << "ERROR: Reading a POI from the file - " << fileName << endl; + ret = false; + } + else + { + CPOI::t_poi type; + string name, description; + double latitude = (LATITUDE_MAX + 1), longitude = (LONGITUDE_MAX + 1); // set to invalid values + + if (!this->parserEachLine(readLine, type, name, description, latitude, longitude)) + { + continue; + } + + CPOI poi(type, name, description, latitude, longitude); + + if (!poi.getName().empty()) + { + poiDb.addPoi(poi); + } + else + { + cout << "ERROR: Invalid Waypoint in line " << this->lineCounter << ": " << readLine << "\n"; + } + } + } + } + else + { + fileStream.clear(); + cout << "WARNING: Error opening the file to read - " << fileName << endl; + ret = false; + } + + fileStream.close(); + + return ret; +} + + +/** + * Extract number from the string + * @param const string &str - string (IN) + * @param double &number - Number to return (OUT) + * @returnval bool - Success - true or Failure - false + */ +bool CCSV::extractNumberFromString(const std::string &str, double &number) +{ + bool isNumber = false; + + if (!str.empty()) + { + unsigned int index = 0; + + // remove all the leading spaces and tabs + while ((str[index] == ' ') || (str[index] == '\t')) + { + index++; + } + + for (unsigned int decPointCount = 0; index < str.length(); ++index) + { + // check if the string contains only numbers and maybe a . + if (!((str[index] >= '0' && str[index] <= '9') || (str[index] == '.' && !decPointCount++))) + { + isNumber = false; + break; + } + else + { + isNumber = true; + } + } + + if (isNumber) + { + stringstream ss(str); + + // extract the number + ss >> number; + } + } + + return isNumber; +} + + +/** + * Parse a line to get waypoint information such as name, latitude and longitude in order + * @param const string &readLine - Each Line (IN) + * @param const string &name - name of waypoint (OUT) + * @param const double &latitude - latitude of waypoint (OUT) + * @param const double &longitude - longitude of waypoint (OUT) + * @returnval bool - Success - true or Failure - false + */ +bool CCSV::parserEachLine(const string &readLine, std::string &name, double &latitude, double &longitude) +{ + bool ret = true; + + // check if the one of the delimiters exists + if (readLine.find_first_of(this->delimiters) != string::npos) + { + stringstream ss(readLine); + string nameParsed, latitudeParsed, longitudeParsed; + + for (unsigned int index = 0; index < this->delimiters.length(); index++) + { + if (readLine.find_first_of(this->delimiters[index]) != string::npos) + { + getline(ss, nameParsed, this->delimiters[index]); + getline(ss, latitudeParsed, this->delimiters[index]); + getline(ss, longitudeParsed, '\n'); + + // remove leading spaces and tables + nameParsed.erase(0, nameParsed.find_first_not_of(' ')); + nameParsed.erase(0, nameParsed.find_first_not_of('\t')); + name = nameParsed; + break; + } + } + + if ((!this->extractNumberFromString(latitudeParsed, latitude)) || + (!this->extractNumberFromString(longitudeParsed, longitude)) || + (nameParsed.empty())) + { + cout << "ERROR: Invalid or too few fields in line " << this->lineCounter << ": " << readLine << "\n"; + ret = false; + } + } + else + { + cout << "ERROR: Could not find the delimiters in line " << this->lineCounter << ": " << readLine << "\n"; + ret = false; + } + + return ret; +} + + +/** + * Parse a line to get POI information such as type, name, description, latitude and longitude in order + * @param const string &readLine - Each Line (IN) + * @param const t_poi &type - name of POI (OUT) + * @param const string &name - name of POI (OUT) + * @param const string &description - description of POI (OUT) + * @param const double &latitude - latitude of POI (OUT) + * @param const double &longitude - longitude of POI (OUT) + * @returnval bool - Success - true or Failure - false + */ +bool CCSV::parserEachLine(const string &readLine, CPOI::t_poi &type, string &name, std::string &description, double &latitude, double &longitude) +{ + bool ret = true; + + // check if the one of the delimiters exists + if (readLine.find_first_of(this->delimiters) != string::npos) + { + stringstream ss(readLine); + string typeParsed, nameParsed, descriptionParsed, latitudeParsed, longitudeParsed; + + for (unsigned int index = 0; index < this->delimiters.length(); index++) + { + if (readLine.find_first_of(this->delimiters[index]) != string::npos) + { + getline(ss, typeParsed, this->delimiters[index]); + getline(ss, nameParsed, this->delimiters[index]); + getline(ss, descriptionParsed, this->delimiters[index]); + getline(ss, latitudeParsed, this->delimiters[index]); + getline(ss, longitudeParsed, '\n'); + + // remove leading spaces and tables + nameParsed.erase(0, nameParsed.find_first_not_of(' ')); + nameParsed.erase(0, nameParsed.find_first_not_of('\t')); + name = nameParsed; + + // remove leading spaces and tables + descriptionParsed.erase(0, descriptionParsed.find_first_not_of(' ')); + descriptionParsed.erase(0, descriptionParsed.find_first_not_of('\t')); + description = descriptionParsed; + + // remove leading spaces and tables + typeParsed.erase(0, typeParsed.find_first_not_of(' ')); + typeParsed.erase(0, typeParsed.find_first_not_of('\t')); + type = CPOI::getPoiType(typeParsed); + break; + } + } + + if ((!this->extractNumberFromString(latitudeParsed, latitude)) || + (!this->extractNumberFromString(longitudeParsed, longitude)) || + (CPOI::DEFAULT_POI == type) || + (nameParsed.empty())) + { + cout << "ERROR: Invalid or too few fields in line " << this->lineCounter << ": " << readLine << "\n"; + ret = false; + } + } + else + { + cout << "ERROR: Could not find the delimiters in line " << this->lineCounter << ": " << readLine << "\n"; + ret = false; + } + + return ret; +} diff --git a/NavigationSystem/myCode/CCSV.h b/NavigationSystem/myCode/CCSV.h new file mode 100644 index 0000000..0bb68bb --- /dev/null +++ b/NavigationSystem/myCode/CCSV.h @@ -0,0 +1,116 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CCSV.h +* Author : Bharath Ramachandraiah +* Description : The file defines a class CCSV. +* The class CCSV is used to implement the Persistence feature. +* +****************************************************************************/ + +#ifndef CCSV_H +#define CCSV_H + +//System Include Files +#include + +//Own Include Files +#include "CPersistentStorage.h" + +class CCSV : public CPersistentStorage { +private: + + /** + * The Possible delimiters are stored here + */ + static const std::string delimiters; + + /** + * Media Name of the Storage + */ + std::string mediaName; + + /** + * Line number of Database which is currently Parsing + */ + unsigned int lineCounter; + + /** + * Extract number from the string + * @param const string &str - string (IN) + * @param double &number - Number to return (OUT) + * @returnval bool - Success - true or Failure - false + */ + bool extractNumberFromString(const std::string &str, double &number); + + /** + * Parse a line to get waypoint information such as name, latitude and longitude in order + * @param const string &readLine - Each Line (IN) + * @param const string &name - name of waypoint (OUT) + * @param const double &latitude - latitude of waypoint (OUT) + * @param const double &longitude - longitude of waypoint (OUT) + * @returnval bool - Success - true or Failure - false + */ + bool parserEachLine(const std::string &readLine, std::string &name, double &latitude, double &longitude); + + /** + * Parse a line to get POI information such as type, name, description, latitude and longitude in order + * @param const string &readLine - Each Line (IN) + * @param const t_poi &type - name of POI (OUT) + * @param const string &name - name of POI (OUT) + * @param const string &description - description of POI (OUT) + * @param const double &latitude - latitude of POI (OUT) + * @param const double &longitude - longitude of POI (OUT) + * @returnval bool - Success - true or Failure - false + */ + bool parserEachLine(const std::string &readLine, CPOI::t_poi &type, std::string &name, std::string &description, double &latitude, double &longitude); + +public: + /** + * Constructor + */ + CCSV(); + + /** + * Destructor + */ + ~CCSV(); + + /** + * Set the name of the media to be used for persistent storage. + * The exact interpretation of the name depends on the implementation + * of the component. + * + * @param name the media to be used + * @returnval void + */ + void setMediaName(std::string name); + + /** + * Write the data to the persistent storage. + * + * @param waypointDb the data base with way points + * @param poiDb the database with points of interest + * @return true if the data could be saved successfully + */ + bool writeData (const CWpDatabase& waypointDb, const CPoiDatabase& poiDb); + + /** + * Fill the databases with the data from persistent storage. If + * merge mode is MERGE, the content in the persistent storage + * will be merged with any content already existing in the data + * bases. If merge mode is REPLACE, already existing content + * will be removed before inserting the content from the persistent + * storage. + * + * @param waypointDb the the data base with way points + * @param poiDb the database with points of interest + * @param mode the merge mode + * @return true if the data could be read successfully + */ + bool readData (CWpDatabase& waypointDb, CPoiDatabase& poiDb, MergeMode mode); +}; +/******************** +** CLASS END +*********************/ +#endif /* CCSV_H */ diff --git a/NavigationSystem/Workspace/myCode/CGPSSensor.cpp b/NavigationSystem/myCode/CGPSSensor.cpp similarity index 94% rename from NavigationSystem/Workspace/myCode/CGPSSensor.cpp rename to NavigationSystem/myCode/CGPSSensor.cpp index 05bb422..f479a93 100644 --- a/NavigationSystem/Workspace/myCode/CGPSSensor.cpp +++ b/NavigationSystem/myCode/CGPSSensor.cpp @@ -38,7 +38,6 @@ CGPSSensor::CGPSSensor() CWaypoint CGPSSensor::getCurrentPosition() { double latitude = 0, longitude = 0; - CWaypoint gpsSensorValue; cout << "GPS Sensor\n"; @@ -70,7 +69,7 @@ CWaypoint CGPSSensor::getCurrentPosition() } while (1); - gpsSensorValue.set("Current Position", latitude, longitude); + CWaypoint gpsSensorValue("Current Position", latitude, longitude, CWaypoint::WAYPOINT); return gpsSensorValue; } diff --git a/NavigationSystem/Workspace/myCode/CGPSSensor.h b/NavigationSystem/myCode/CGPSSensor.h similarity index 84% rename from NavigationSystem/Workspace/myCode/CGPSSensor.h rename to NavigationSystem/myCode/CGPSSensor.h index 8be91e2..f535c7e 100644 --- a/NavigationSystem/Workspace/myCode/CGPSSensor.h +++ b/NavigationSystem/myCode/CGPSSensor.h @@ -23,15 +23,14 @@ class CGPSSensor { /** * CGPSSensor constructor */ - CGPSSensor(); + CGPSSensor(); - /** - * Get the current position from the sensor - * @returnval CWaypoint - */ - CWaypoint getCurrentPosition(); + /** + * Get the current position from the sensor + * @returnval CWaypoint + */ + CWaypoint getCurrentPosition(); }; - /******************** ** CLASS END *********************/ diff --git a/NavigationSystem/myCode/CNavigationSystem.cpp b/NavigationSystem/myCode/CNavigationSystem.cpp new file mode 100644 index 0000000..35e4771 --- /dev/null +++ b/NavigationSystem/myCode/CNavigationSystem.cpp @@ -0,0 +1,309 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CNavigationSystem.cpp +* Author : Bharath Ramachandraiah +* Description : The file defines all the methods pertaining to the +* class type - class CNavigationSystem. +* The class CNavigationSystem is used for Navigation which +* has a GPS Sensor, Route and a Database. +* +****************************************************************************/ + +//System Include Files +#include + +//Own Include Files +#include "CNavigationSystem.h" +#include "CCSV.h" + +//Namespaces +using namespace std; + +//Method Implementations +/** + * Constructor + */ +CNavigationSystem::CNavigationSystem() +{ + // Do nothing +} + + +/** + * Get the Poi Database + * returnval@ CPoiDatabase& - Reference to the POI Database + */ +CPoiDatabase& CNavigationSystem::getPoiDatabase() +{ + return this->m_PoiDatabase; +} + +/** + * Get the Waypoint Database + * returnval@ CWpDatabase& - Reference to the Waypoint Database + */ +CWpDatabase& CNavigationSystem::getWpDatabase() +{ + return this->m_WpDatabase; +} + + +/** + * Add waypoints and POIs to create custom route + * @returnval void + */ +void CNavigationSystem::enterRoute() +{ + cout << "=======================================================\n"; + cout << "INFO: Add Waypoints and POI to the Route\n"; + cout << "=======================================================\n"; + +#ifdef RUN_TEST_ROUTE_OPERATOR_ASSIGNMENT + CRoute testRoute; + testRoute = this->m_route; + this->m_route = testRoute; +#endif + + // add waypoints + this->m_route.addWaypoint("Berliner Alle" ); + this->m_route.addWaypoint("Rheinstrasse" ); + this->m_route.addWaypoint("Neckarstrasse" ); + + // add POIs + this->m_route.addPoi("HDA BuildingC10" , "Berliner Alle" ); + this->m_route.addPoi("Aral Tankst." , "Rheinstrasse" ); + this->m_route.addPoi("Starbucks" , "Neckarstrasse" ); + +// this->m_route += "Landskronstrasse"; +// this->m_route += "SushiRestaurant"; + +#ifdef RUN_TEST_CASE_NON_EXIST_WAYPOINT + testCaseNonExistingWaypoint(); +#endif + +#ifdef RUN_TEST_CASE_NON_EXIST_POI + testCaseNonExistingPOI(); + this->m_route += ""; +#endif + +#ifdef RUN_TEST_ROUTE_OPERATOR_ADDITION + CRoute testRoute_extended; + + // connect the database + testRoute_extended.connectToPoiDatabase(&this->m_PoiDatabase); + testRoute_extended.connectToWpDatabase(&this->m_WpDatabase); + + testRoute_extended.addWaypoint("Bessunger" ); + testRoute_extended.addWaypoint("FriedrichStrasse"); + testRoute_extended.addWaypoint("Katharinen Str."); + testRoute_extended.addWaypoint("Wartehalle" ); + + testRoute_extended.addPoi("Aral Tankstelle" , "Bessunger" ); + testRoute_extended.addPoi("Church Holy" , "FriedrichStrasse" ); + testRoute_extended.addPoi("Thessaloniki" , "Wartehalle"); + + cout << "Route1: \n"; + this->m_route.print(); + + cout << "Route2: \n"; + testRoute_extended.print(); + + // combine the routes + this->m_route = this->m_route + testRoute_extended; + + cout << "Combined Route: \n"; + this->m_route.print(); + +#endif +} + + +/** + * Print all the waypoints and POIs of the custom route + * @returnval void + */ +void CNavigationSystem::printRoute() +{ + this->m_route.print(); +} + + +/** + * Print the Distance between current position and a closest POI + * @returnval void + */ +void CNavigationSystem::printDistanceCurPosNextPoi() +{ + CPOI poi; + CPOI::t_poi type = CPOI::DEFAULT_POI; + string name, description; + double distance = 0, latitude = 0, longitude = 0; + + CWaypoint currentPosition; + currentPosition = this->m_GPSSensor.getCurrentPosition(); + + // check if the GPS current location is valid + currentPosition.getAllDataByReference(name, latitude, longitude); + + if (!name.empty()) + { + distance = this->m_route.getDistanceNextPoi(currentPosition, poi); + + // check if the POI is valid + poi.getAllDataByReference(name, latitude, longitude, type, description); + + if (type != CPOI::DEFAULT_POI) + { + cout << "Distance to next POI = " << distance << " Kms (approx.)\n\n" << poi << endl; + } + else + { + cout << "WARNING: Can not compute the distance.\n"; + } + } + else + { + cout << "WARNING: Invalid Sensor data.\n"; + } +} + + +/** + * Creates Waypoint Database and Poi Database + * @returnval void + */ +void CNavigationSystem::createDatabases() +{ + // add a waypoint + this->m_WpDatabase.addWaypoint(CWaypoint("Berliner Alle", 49.866851, 8.634864)); + + // add a POI + this->m_PoiDatabase.addPoi(CPOI(CPOI::UNIVERSITY, "HDA BuildingC10" , "An awesome University", 49.86727, 8.638459)); +} + + +/** + * Write the current content of Databases to files + * @returnval void + */ +bool CNavigationSystem::writeToFile() +{ + bool ret = false; + CCSV csvDatabase; + + // set the media name + csvDatabase.setMediaName("Database"); + + // write the current Databases' contents to files + ret = csvDatabase.writeData(this->getWpDatabase(), this->getPoiDatabase()); + + return ret; +} + + +/** + * Read the Database content from file to Databases + * @returnval void + */ +bool CNavigationSystem::readFromFile() +{ + bool ret = false; + CCSV csvDatabase; + + // set the media name + csvDatabase.setMediaName("Database"); + + // write the current Databases' contents to files + ret = csvDatabase.readData(this->getWpDatabase(), this->getPoiDatabase(), CCSV::REPLACE); + + return ret; +} + + +/** + * Navigation System functionaliy's entry function + * @returnval void + */ +void CNavigationSystem::run() +{ + // connect to the Database +#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_POI + this->testCaseDatabaseNotAvailablePoi(); +#else + this->m_route.connectToPoiDatabase(&this->m_PoiDatabase); +#endif + +#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_WAYPOINT + this->testCaseDatabaseNotAvailableWaypoint(); +#else + this->m_route.connectToWpDatabase(&this->m_WpDatabase); +#endif + + // create the databases + this->createDatabases(); + + // read the database files + if (!this->readFromFile()) + { + cout << "WARNING: Reading from the Database files was unsuccessful.\n"; + } + + // write to the file + if (!this->writeToFile()) + { + cout << "WARNING: Writing to the Database files was unsuccessful.\n"; + } + + this->enterRoute(); + this->printRoute(); + this->printDistanceCurPosNextPoi(); +} + + +/** + * TestCase to check if non existing POI is added to the route + * @returnval void + */ +#ifdef RUN_TEST_CASE_NON_EXIST_POI +void CNavigationSystem::testCaseNonExistingPOI() +{ + this->m_route.addPoi("HDA Mensa", "Berliner Alle"); +} +#endif + + +/** + * TestCase to check if non existing Waypoint is added to the route + * @returnval void + */ +#ifdef RUN_TEST_CASE_NON_EXIST_WAYPOINT +void CNavigationSystem::testCaseNonExistingWaypoint() +{ + this->m_route.addWaypoint("My Chicken"); +} +#endif + + +/** + * TestCase to check when POI database is not available + * @returnval void + */ +#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_POI +void CNavigationSystem::testCaseDatabaseNotAvailablePoi() +{ + this->m_route.connectToPoiDatabase(0); +} +#endif + + +/** + * TestCase to check when Waypoint database is not available + * @returnval void + */ +#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_WAYPOINT +void CNavigationSystem::testCaseDatabaseNotAvailableWaypoint() +{ + this->m_route.connectToWpDatabase(0); +} +#endif diff --git a/NavigationSystem/myCode/CNavigationSystem.h b/NavigationSystem/myCode/CNavigationSystem.h new file mode 100644 index 0000000..6dec873 --- /dev/null +++ b/NavigationSystem/myCode/CNavigationSystem.h @@ -0,0 +1,150 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CNavigationSystem.h +* Author : Bharath Ramachandraiah +* Description : The file defines a class CNavigationSystem. +* The class CNavigationSystem is used for Navigation which +* has a GPS Sensor, Route and a Database. +* +****************************************************************************/ + +#ifndef CNAVIGATIONSYSTEM_H +#define CNAVIGATIONSYSTEM_H + +//System Include Files + +//Own Include Files +#include "CGPSSensor.h" +#include "CRoute.h" +#include "CPoiDatabase.h" + +//Macros +//#define RUN_TEST_ROUTE_OPERATOR_ASSIGNMENT +//#define RUN_TEST_ROUTE_OPERATOR_ADDITION +//#define RUN_TEST_CASE_NON_EXIST_POI +//#define RUN_TEST_CASE_NON_EXIST_WAYPOINT +//#define RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_POI +//#define RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_WAYPOINT + +class CNavigationSystem { +private: + + /** + * GPS sensor which feeds the current location + */ + CGPSSensor m_GPSSensor; + + /** + * Navigation System's current route + */ + CRoute m_route; + + /** + * The Database of points of interest + */ + CPoiDatabase m_PoiDatabase; + + /** + * The Database of waypoint + */ + CWpDatabase m_WpDatabase; + + /** + * Get the Poi Database + * returnval@ CPoiDatabase& - Reference to the POI Database + */ + CPoiDatabase& getPoiDatabase(); + + /** + * Get the Waypoint Database + * returnval@ CWpDatabase& - Reference to the Waypoint Database + */ + CWpDatabase& getWpDatabase(); + + /** + * Add waypoints and POIs to create custom route + * @returnval void + */ + void enterRoute(); + + /** + * Print all the waypoints and POIs of the custom route + * @returnval void + */ + void printRoute(); + + /** + * Print the Distance between current position and a closest POI + * @returnval void + */ + void printDistanceCurPosNextPoi(); + + /** + * Creates Waypoint Database and Poi Database + * @returnval void + */ + void createDatabases(); + + /** + * Write the current content of Databases to files + * @returnval void + */ + bool writeToFile(); + + /** + * Read the Database content from file to Databases + * @returnval void + */ + bool readFromFile(); + + /** + * TestCase to check if non existing POI is added to the route + * @returnval void + */ +#ifdef RUN_TEST_CASE_NON_EXIST_POI + void testCaseNonExistingPOI(); +#endif + + /** + * TestCase to check if non existing Waypoint is added to the route + * @returnval void + */ +#ifdef RUN_TEST_CASE_NON_EXIST_WAYPOINT + void testCaseNonExistingWaypoint(); +#endif + + /** + * TestCase to check when POI database is not available + * @returnval void + */ +#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_POI + void testCaseDatabaseNotAvailablePoi(); +#endif + + /** + * TestCase to check when Waypoint database is not available + * @returnval void + */ +#ifdef RUN_TEST_CASE_DATABASE_NOT_AVAILABLE_WAYPOINT + void testCaseDatabaseNotAvailableWaypoint(); +#endif + +public: + + /** + * Constructor + */ + CNavigationSystem(); + + /** + * Navigation System functionaliy's entry function + * @returnval void + */ + void run(); + +}; +/******************** +** CLASS END +*********************/ +#endif /* CNAVIGATIONSYSTEM_H */ diff --git a/NavigationSystem/myCode/CPOI.cpp b/NavigationSystem/myCode/CPOI.cpp new file mode 100644 index 0000000..3b6209e --- /dev/null +++ b/NavigationSystem/myCode/CPOI.cpp @@ -0,0 +1,167 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CPOI.cpp +* Author : Bharath Ramachandraiah +* Description : The file defines all the methods pertaining to the +* class type - class CPOI. +* The class CPOI is used to hold the information of a +* point of interest. +* +****************************************************************************/ + +//System Include Files +#include +#include + +//Own Include Files +#include "CPOI.h" + +//Namespaces +using namespace std; + +struct POITypeName +{ + string poiTypeName; + CPOI::t_poi poiType; +}; + + +static const POITypeName POI_names[CPOI::DEFAULT_POI + 1] = +{ + {"Restaurant", CPOI::RESTAURANT}, + {"Touristic", CPOI::TOURISTIC}, + {"Gas station", CPOI::GASSTATION}, + {"University", CPOI::UNIVERSITY}, + {"Default", CPOI::DEFAULT_POI}, +}; + + +//Method Implementations + +/** + * CPOI constructor: + * Sets the value of an object when created. + * param@ t_poi type - type of a Point of interest (IN) + * param@ string name - name of a Waypoint (IN) + * param@ double latitude - latitude of a Waypoint (IN) + * param@ double longitude - longitude of a Waypoint (IN) + */ +CPOI::CPOI(t_poi type, string name, string description, double latitude, double longitude) : CWaypoint(name, latitude, longitude, CWaypoint::POI) +{ + this->m_type = type; + this->m_description = description; +} + + +/** + * CPOI Destructor: + * Called when the object is destroyed + */ +CPOI::~CPOI() +{ + // Do nothing +} + + +/* + * Return the current point of interest's values + * param@ string& name - name of a POI (OUT) + * param@ double& latitude - latitude of a POI's Waypoint (OUT) + * param@ double& longitude - longitude of a POI's Waypoint (OUT) + * param@ t_poi& type - point of interest type (OUT) + * param@ string&description- description of a POI (OUT) + * returnvalue@ void +*/ +void CPOI::getAllDataByReference(string& name, double& latitude, double& longitude, t_poi &type, string &description) +{ + type = this->m_type; + description = this->m_description; + + this->CWaypoint::getAllDataByReference(name, latitude, longitude); +} + + +/** + * Gets the type name in the string + * returnvalue@ string - name of the POI type + */ +string CPOI::getPoiTypeName() +{ + return POI_names[this->m_type].poiTypeName; +} + + +/** + * Gets the type + * param@ const string &poiTypeName - POI name (IN) + * returnvalue@ CPOI::t_poi - POI type + */ +CPOI::t_poi CPOI::getPoiType(const std::string &poiTypeName) +{ + CPOI::t_poi ret = CPOI::DEFAULT_POI; + + for (unsigned index = 0; index <= CPOI::DEFAULT_POI; index++) + { + if(!POI_names[index].poiTypeName.compare(poiTypeName)) + { + // equal + ret = POI_names[index].poiType; + break; + } + } + return ret; +} + + +/** + * Prints the POI values in Degree-Mins-secs format or Decimal format + * param@ int format - Decimal or Deg-min-ss (OUT) + * returnvalue@ void + */ +void CPOI::print(int format) +{ + string typeName; + + typeName = this->getPoiTypeName(); + + cout << "Point of interest\n"; + cout << "===================\n"; + cout << " of type " << typeName << " : " << this->m_description << "\n"; + this->CWaypoint::print(format); + cout << endl; +} + + +/** + * An operator overloaded friend function which prints the POI information + * param@ ostream &stream - output stream (IN/OUT) + * param@ CPOI const &poi - A POI (IN) + * returnvalue@ output stream with the POI information + */ +ostream& operator<< (ostream &stream, CPOI const &poi) +{ + CPOI outPoi = poi; + CPOI::t_poi type; + string name, description, typeName; + double latitude, longitude; + + outPoi.getAllDataByReference(name, latitude, longitude, type, description); + + typeName = outPoi.getPoiTypeName(); + + stream << "POI : " << name << "\n"; + stream << "POI type : " << typeName << "\n"; + stream << "Descript : " << description << "\n"; + + int deg, mm; + double ss; + + outPoi.transformLatitude2degmmss(deg, mm, ss); + stream << "Latitude : " << deg << "deg " << mm << "min " << ss << "s\n"; + + outPoi.transformLongitude2degmmss(deg, mm, ss); + stream << "Longitude : " << deg << "deg " << mm << "min " << ss << "s \n"; + + return stream; +} diff --git a/NavigationSystem/Workspace/myCode/CPOI.h b/NavigationSystem/myCode/CPOI.h similarity index 51% rename from NavigationSystem/Workspace/myCode/CPOI.h rename to NavigationSystem/myCode/CPOI.h index 25afcf6..b400c05 100644 --- a/NavigationSystem/Workspace/myCode/CPOI.h +++ b/NavigationSystem/myCode/CPOI.h @@ -23,11 +23,11 @@ class CPOI : public CWaypoint { enum t_poi { - RESTAURANT, - TOURISTIC, - GASSTATION, - UNIVERSITY, - DEFAULT_POI, + RESTAURANT = 0, + TOURISTIC, + GASSTATION, + UNIVERSITY, + DEFAULT_POI, }; /** @@ -38,36 +38,64 @@ class CPOI : public CWaypoint { * param@ double latitude - latitude of a Waypoint (IN) * param@ double longitude - longitude of a Waypoint (IN) */ - CPOI(t_poi type = DEFAULT_POI, std::string name = "", std::string description = "", double latitude = 0, double longitude = 0); + CPOI(t_poi type = DEFAULT_POI, std::string name = "", std::string description = "", double latitude = 0, double longitude = 0); + + /** + * CPOI Destructor: + * Called when the object is destroyed + */ + ~CPOI(); /* - * Return the current point of interest's values + * Return the current point of interest's values * param@ string& name - name of a POI (OUT) * param@ double& latitude - latitude of a POI's Waypoint (OUT) * param@ double& longitude - longitude of a POI's Waypoint (OUT) * param@ t_poi& type - point of interest type (OUT) * param@ string&description- description of a POI (OUT) * returnvalue@ void - */ - void getAllDataByReference(std::string& name, double& latitude, double& longitude, t_poi &type, std::string &description); + */ + void getAllDataByReference(std::string& name, double& latitude, double& longitude, t_poi &type, std::string &description); + + /** + * Gets the type name in the string + * returnvalue@ string - name of the POI type + */ + std::string getPoiTypeName(); + + /** + * Gets the type - Global function + * param@ const string &poiTypeName - POI name (IN) + * returnvalue@ CPOI::t_poi - POI type + */ + static CPOI::t_poi getPoiType(const std::string &poiTypeName); + + /** + * Prints the POI values in Degree-Mins-secs format or Decimal format + * param@ int format - Decimal or Deg-min-ss (IN) + * returnvalue@ void + */ + void print(int format); + + /** + * An operator overloaded friend function which prints the POI information + * param@ ostream &stream - output stream (IN/OUT) + * param@ CPOI const &poi - A POI (IN) + * returnvalue@ output stream with the POI information + */ + friend std::ostream& operator<< (std::ostream &stream, CPOI const &poi); - /** - * Print all the information of a Point of Interest. - * returnvalue@ void - */ - void print(); private: /** * To identify the type of point of interest. */ - t_poi m_type; - - /** - * A description about the point of interest. - */ - std::string m_description; + t_poi m_type; + /** + * A description about the point of interest. + */ + std::string m_description; }; /******************** ** CLASS END diff --git a/NavigationSystem/myCode/CPersistentStorage.h b/NavigationSystem/myCode/CPersistentStorage.h new file mode 100644 index 0000000..82228de --- /dev/null +++ b/NavigationSystem/myCode/CPersistentStorage.h @@ -0,0 +1,70 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CPersistentStorage.h +* Author : Bharath Ramachandraiah +* Description : The file defines a class CPersistentStorage. +* The class CPersistentStorage is an abstract class which +* provide interfaces to the derived class. +* +****************************************************************************/ + +#ifndef CPERSISTENTSTORAGE_H +#define CPERSISTENTSTORAGE_H + +//System Include Files +#include + +//Own Include Files +#include "CPoiDatabase.h" +#include "CWpDatabase.h" + +class CPersistentStorage { +public: + /** + * Set the name of the media to be used for persistent storage. + * The exact interpretation of the name depends on the implementation + * of the component. + * + * @param name the media to be used + */ + virtual void setMediaName(std::string name) = 0; + + /** + * Write the data to the persistent storage. + * + * @param waypointDb the data base with way points + * @param poiDb the database with points of interest + * @return true if the data could be saved successfully + */ + virtual bool writeData (const CWpDatabase& waypointDb, const CPoiDatabase& poiDb) = 0; + + /** + * The mode to be used when reading the data bases (see readData). + */ + enum MergeMode { MERGE, REPLACE }; + + /** + * Fill the databases with the data from persistent storage. If + * merge mode is MERGE, the content in the persistent storage + * will be merged with any content already existing in the data + * bases. If merge mode is REPLACE, already existing content + * will be removed before inserting the content from the persistent + * storage. + * + * @param waypointDb the the data base with way points + * @param poiDb the database with points of interest + * @param mode the merge mode + * @return true if the data could be read successfully + */ + virtual bool readData (CWpDatabase& waypointDb, CPoiDatabase& poiDb, MergeMode mode) = 0; + + /** + * A Virtual Destructor for an abstract class + */ + virtual ~CPersistentStorage() {} +}; +/******************** +** CLASS END +*********************/ +#endif /* CPERSISTENTSTORAGE_H */ diff --git a/NavigationSystem/myCode/CPoiDatabase.cpp b/NavigationSystem/myCode/CPoiDatabase.cpp new file mode 100644 index 0000000..cd81fad --- /dev/null +++ b/NavigationSystem/myCode/CPoiDatabase.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CPoiDatabase.cpp +* Author : Bharath Ramachandraiah +* Description : The file defines all the methods pertaining to the +* class type - class CPoiDatabase. +* The class CPoiDatabase is used to hold the information +* of all the points of interest in a container. +* +****************************************************************************/ + +//System Include Files +#include + +//Own Include Files +#include "CPoiDatabase.h" + +//Namespaces +using namespace std; + +//Method Implementations +/** + * CPoiDatabase constructor + */ +CPoiDatabase::CPoiDatabase() +{ + // do nothing +} + + +/* + * Add a Point of interest to the database + * param@ CPOI const &poi - point of interest (IN) + * returnvalue@ void + */ +void CPoiDatabase::addPoi(CPOI const &poi) +{ + CPOI inPoi = poi; + pair ret; + + if (!inPoi.getName().empty()) + { + ret = this->m_Poi.insert(pair(inPoi.getName(), poi)); + + if (ret.second == false) + { + cout << "WARNING: POI already exists in the Database.\n" << poi << endl; + } + } + else + { + cout << "WARNING: Trying to add invalid POI to the Database.\n" << poi << endl; + } +} + + +/** + * Get pointer to a POI from the Database which matches the name + * param@ string name - name of a POI (IN) + * returnvalue@ CPOI* - Pointer to a POI in the database + */ +CPOI* CPoiDatabase::getPointerToPoi(string name) +{ + CPOI *pPoi = 0; + + if (!this->m_Poi.empty()) + { + Poi_Map_Itr_t poiItr = this->m_Poi.find(name); + + if (poiItr != this->m_Poi.end()) + { + // element found + pPoi = &poiItr->second; + } + } + + return pPoi; +} + + +/** + * Get POIs from the Database + * returnvalue@ Poi_Map_t - POIs in the Database (OUT) + */ +const Poi_Map_t CPoiDatabase::getPoisFromDatabase() const +{ + return (this->m_Poi); +} + + +/** + * Reset the Database + * returnvalue@ void + */ +void CPoiDatabase::resetPoisDatabase() +{ + this->m_Poi.clear(); +} + + +/** + * Print all the POIs in the database + * returnvalue@ void + */ +void CPoiDatabase::print() +{ + for (Poi_Map_Itr_t poiItr = this->m_Poi.begin(); poiItr != this->m_Poi.end(); ++poiItr) + { + cout << poiItr->second << endl; + } +} diff --git a/NavigationSystem/myCode/CPoiDatabase.h b/NavigationSystem/myCode/CPoiDatabase.h new file mode 100644 index 0000000..e694347 --- /dev/null +++ b/NavigationSystem/myCode/CPoiDatabase.h @@ -0,0 +1,79 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CPoiDatabase.h +* Author : Bharath Ramachandraiah +* Description : The file defines a class CPoiDatabase. +* The class CPoiDatabase is used to hold the information +* of points of interest in a container. +* +****************************************************************************/ + +#ifndef CPOIDATABASE_H +#define CPOIDATABASE_H + +//System Include Files +#include +#include + +//Own Include Files +#include "CPOI.h" + + +typedef std::map Poi_Map_t; +typedef std::map::iterator Poi_Map_Itr_t; + +class CPoiDatabase { +private: + + /** + * An Associative container to store point of interests. + * key - name + * value - POI + */ + Poi_Map_t m_Poi; + +public: + + /** + * CPoiDatabase constructor + */ + CPoiDatabase(); + + /** + * Add a Point of interest to the database + * param@ CPOI const &poi - point of interest (IN) + * returnvalue@ void + */ + void addPoi(CPOI const &poi); + + /** + * Get pointer to a POI from the Database which matches the name + * param@ string name - name of a POI (IN) + * returnvalue@ CPOI* - Pointer to a POI in the database + */ + CPOI* getPointerToPoi(std::string name); + + /** + * Get POIs from the Database + * returnvalue@ Poi_Map_t - POIs in the Database (OUT) + */ + const Poi_Map_t getPoisFromDatabase() const; + + /** + * Resets the Database + * returnvalue@ void + */ + void resetPoisDatabase(); + + /** + * Print all the POIs in the database + * returnvalue@ void + */ + void print(); + +}; +/******************** +** CLASS END +*********************/ +#endif /* CPOIDATABASE_H */ diff --git a/NavigationSystem/myCode/CRoute.cpp b/NavigationSystem/myCode/CRoute.cpp new file mode 100644 index 0000000..ec8f57c --- /dev/null +++ b/NavigationSystem/myCode/CRoute.cpp @@ -0,0 +1,376 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CRoute.cpp +* Author : Bharath Ramachandraiah +* Description : The file defines all the methods pertaining to the +* class type - class CRoute. +* The class CRoute is used to hold the information +* of points of interest and waypoints of a Route. +* +****************************************************************************/ + +//System Include Files +#include +#include + +//Own Include Files +#include "CRoute.h" + +//Namespace +using namespace std; + +//Method Implementations +/** + * CRoute Constructor: + * Sets the value when an object is created. + */ +CRoute::CRoute() +{ + this->m_Course.clear(); + this->m_pPoiDatabase = 0; + this->m_pWpDatabase = 0; +} + + +/** + * CRoute Constructor: + * Sets the value when an object is created by performing deep copy. + * @param CRoute const &origin - CRoute const object (IN) + */ +CRoute::CRoute(CRoute const &origin) +{ + cout << "INFO: Performing deep copy.\n"; + + this->m_Course = origin.m_Course; + this->m_pPoiDatabase= origin.m_pPoiDatabase; + this->m_pWpDatabase = origin.m_pWpDatabase; +} + + +/** + * CRoute Destructor + */ +CRoute::~CRoute() +{ + // clear all the elements + this->m_Course.clear(); + + // disconnect from the Database + this->m_pPoiDatabase = 0; + this->m_pWpDatabase = 0; +} + + +/** + * Get the address of the POI Database and connect it to the CRoute + * @param CPoiDatabase* pPoiDB - pointer to the POI Database (IN) + * @returnval void + */ +void CRoute::connectToPoiDatabase(CPoiDatabase *pPoiDB) +{ + // connect to the POI Database + if (pPoiDB) + { + this->m_pPoiDatabase = pPoiDB; + cout << "INFO: POI Database connected to the route.\n"; + } + else + { + cout << "WARNING: POI Database not connected to the route.\n"; + } +} + + +/** + * Get the address of the Waypoint Database and connect it to the CRoute + * @param CWpDatabase *pWpDB - pointer to the Waypoint Database (IN) + * @returnval void + */ +void CRoute::connectToWpDatabase(CWpDatabase *pWpDB) +{ + // connect to the Waypoint Database + if (pWpDB) + { + this->m_pWpDatabase = pWpDB; + cout << "INFO: Waypoint Database connected to the route.\n"; + } + else + { + cout << "WARNING: Waypoint Database not connected to the route.\n"; + } +} + + +/** + * Search the waypoint in the waypoint-database by the name; Add the waypoint to current route + * @param string name - name of a waypoint (IN) + * @returnval void + */ +void CRoute::addWaypoint(string name) +{ + CWaypoint *pWp; + + // check if the database is connected + if (this->m_pWpDatabase) + { + pWp = this->m_pWpDatabase->getPointerToWaypoint(name); + + if (pWp) + { + // save the pointer to the waypoint in the current route + this->m_Course.push_back(static_cast(pWp)); + } + else + { + cout << "WARNING: The Requested Waypoint -\"" << name << "\" is not available in the Database.\n"; + } + } + else + { + cout << "WARNING: The Waypoint Database is not available.\n"; + } +} + + +/** + * Search the POI in the POI-database by the name; Add the POI to current route after "afterWp" + * if -> + * namePoi is empty and afterWp is empty -> don't add + * namePoi is empty and afterWp is not empty -> POI will not be in the DB + * namePoi is not empty and afterWp is empty -> Add POI to Route at the end + * namePoi is not empty and afterWp is not empty -> Add POI afterWp where afterWP is already added + * + * @param string namePoi - name of a POI (IN) + * @param string afterWp - name of a waypoint(IN) + * @returnval void + */ +void CRoute::addPoi(string namePoi, string afterWp) +{ + bool isAfterWp = false; + CPOI *pPoi = 0; + CWaypoint *pWp = 0; + + if (!namePoi.empty() || !afterWp.empty()) + { + // check if the database is connected + if (this->m_pPoiDatabase) + { + pPoi = this->m_pPoiDatabase->getPointerToPoi(namePoi); + + if (pPoi) + { + for (Route_Collection_RevItr revItr = this->m_Course.rbegin(); revItr != this->m_Course.rend(); ++revItr) + { + pWp = dynamic_cast(*revItr); + + // is this a Waypoint ? + if (pWp) + { + // are the names matching ? + if (!afterWp.compare(pWp->getName())) + { + this->m_Course.insert(revItr.base(), pPoi); + isAfterWp = true; + break; + } + } + } + + if (!isAfterWp) + { + this->m_Course.push_back(static_cast(pPoi)); + + cout << "WARNING: The Requested Waypoint - \"" << afterWp << "\" is not available in the Route.\n"; + } + } + else + { + cout << "WARNING: The Requested POI - \"" << namePoi << "\" is not available in the Database.\n"; + } + } + else + { + cout << "WARNING: The POI Database is not available.\n"; + } + } + else + { + cout << "WARNING: The Waypoint and POI are invalid.\n"; + } +} + + +/** + * Calculates the distance between waypoint and POI + * @param CWaypoint const &wp - waypoint (IN) + * @param CPOI& poi - POI (IN) + * @return double - Distance in Kms + */ +double CRoute::getDistanceNextPoi(CWaypoint const &wp, CPOI& poi) +{ + CPOI *pPoi = 0; + double shortestDistance = numeric_limits::max(), currentDistance = 0; + + if (!this->m_Course.empty()) + { + for (Route_Collection_FwdItr fwdItr = this->m_Course.begin(); fwdItr != this->m_Course.end(); ++fwdItr) + { + pPoi = dynamic_cast(*fwdItr); + + if (pPoi) + { + currentDistance = pPoi->CWaypoint::calculateDistance(wp); + + if (currentDistance <= shortestDistance) + { + shortestDistance = currentDistance; + poi = *pPoi; + } + } + } + } + + return shortestDistance; +} + + +/** + * prints all the waypoints and POIs in the route + */ +void CRoute::print() +{ + CPOI *pPoi = 0; + CWaypoint *pWp = 0; + + cout << "=======================================================\n"; + cout << "The Route Information:\n"; + cout << "=======================================================\n"; + + for (Route_Collection_FwdItr fwdItr = this->m_Course.begin(); fwdItr != this->m_Course.end(); ++fwdItr) + { + pPoi = dynamic_cast(*fwdItr); + +#ifdef RUN_TEST_PRINT + // The iterator can point to + // 1. Address of a CWaypoint -> CWaypoint::print() will be invoked. + // 2. Address of a CPOI -> CPOI::print() will be invoked. + // The respective print function will be called due to polymorphic virtual function + (*this->m_ForwardItr)->print(2); + + // Since the container used is of type CWaypoint, even the POI will be treated as + // a Waypoint data(since there is not explict dynamic casting) and the + // CWaypointer's operator<< will be invoked. + cout << (**this->m_ForwardItr) << endl; +#endif + + if (pPoi) + { + cout << *pPoi << endl; + } + else + { + pWp = dynamic_cast(*fwdItr); + + if (pWp) + { + cout << *pWp << endl; + } + else + { + cout << "WARNING: Unknown type of Data in the Route.\n" << endl; + } + } + } +} + + +/** + * The function is an extension of addPoi which searches the Databases and add the + * Waypoint and/or the POI which matches the name. + */ +void CRoute::operator += (string const &name) +{ + CPOI *pPoi = 0; + CWaypoint *pWp = 0; + string namePoi, nameWp; + + if (!name.empty()) + { + if (this->m_pWpDatabase) + { + pWp = this->m_pWpDatabase->getPointerToWaypoint(name); + + if (pWp) + { + this->addWaypoint(name); + nameWp = name; + } + } + + if (this->m_pPoiDatabase) + { + pPoi = this->m_pPoiDatabase->getPointerToPoi(name); + + if (pPoi) + { + namePoi = name; + } + } + this->addPoi(namePoi, nameWp); + } + else + { + cout << "WARNING: Invalid POI / Waypoint addition to the route request.\n"; + } +} + + +/** + * A copy assignment operator + * @param CRoute const & rhs - CRoute const object (IN) + * @returnval CRoute& + */ +CRoute& CRoute::operator=(CRoute const & rhs) +{ + this->m_Course.clear(); + this->m_pPoiDatabase= 0; + this->m_pWpDatabase = 0; + + this->m_Course = rhs.m_Course; + this->m_pPoiDatabase= rhs.m_pPoiDatabase; + this->m_pWpDatabase = rhs.m_pWpDatabase; + + return *this; +} + + +/** + * An addition operator + * @param CRoute const & rhs - CRoute const object (IN) + * @returnval CRoute + */ +CRoute CRoute::operator+(CRoute const & rhs) +{ + CRoute result; + + // check if the Databases are same + if ((this->m_pPoiDatabase == rhs.m_pPoiDatabase) && + (this->m_pWpDatabase == rhs.m_pWpDatabase)) + { + Route_Collection_t rhs1 = this->m_Course; + Route_Collection_t rhs2 = rhs.m_Course; + Route_Collection_FwdItr fwdItr = result.m_Course.begin(); + + result.m_Course.splice(fwdItr, rhs1); + result.m_Course.splice(fwdItr, rhs2); + result.m_pPoiDatabase = rhs.m_pPoiDatabase; + result.m_pWpDatabase = rhs.m_pWpDatabase; + } + else + { + cout << "WARNING: The Databases are different and can not be concatenated.\n"; + } + + return result; +} diff --git a/NavigationSystem/myCode/CRoute.h b/NavigationSystem/myCode/CRoute.h new file mode 100644 index 0000000..1a48a20 --- /dev/null +++ b/NavigationSystem/myCode/CRoute.h @@ -0,0 +1,132 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CRoute.h +* Author : Bharath Ramachandraiah +* Description : The file defines a class CRoute. +* The class CRoute is used to hold the information +* of points of interest and waypoints of a Route. +* +****************************************************************************/ + +#ifndef CROUTE_H +#define CROUTE_H + +//System Include Files +#include +#include + +//Own Include Files +#include "CPoiDatabase.h" +#include "CWpDatabase.h" + +typedef std::list Route_Collection_t; +typedef std::list::iterator Route_Collection_FwdItr; +typedef std::list::reverse_iterator Route_Collection_RevItr; + +class CRoute { +private: + + /** + * An list container to store the waypoints and POI of the route + */ + std::list m_Course; + + /** + * A pointer to the Point of interest Database + */ + CPoiDatabase *m_pPoiDatabase; + + /** + * A pointer the Waypoint Database + */ + CWpDatabase *m_pWpDatabase; + +public: + + /** + * CRoute Constructor: + * Sets the value when an object is created. + */ + CRoute(); + + /** + * CRoute Constructor: + * Sets the value when an object is created by performing deep copy. + * @param CRoute const &origin - CRoute const object (IN) + */ + CRoute(CRoute const &origin); + + /** + * CRoute Destructor: + * Called when the object is destroyed + */ + ~CRoute(); + + /** + * Get the address of the POI Database and connect it to the CRoute + * @param CPoiDatabase* pPoiDB - pointer to the POI Database (IN) + * @returnval void + */ + void connectToPoiDatabase(CPoiDatabase *pPoiDB); + + /** + * Get the address of the Waypoint Database and connect it to the CRoute + * @param CWpDatabase *pWpDB - pointer to the Waypoint Database (IN) + * @returnval void + */ + void connectToWpDatabase(CWpDatabase *pWpDB); + + /** + * Search the waypoint in the waypoint-database by the name; Add the waypoint to current route + * @param string name - name of a waypoint (IN) + * @returnval void + */ + void addWaypoint(std::string name); + + /** + * Search the POI in the POI-database by the name; Add the POI to current route after "afterWp" + * @param string namePoi - name of a POI (IN) + * @param string afterWp - name of a waypoint(IN) + * @returnval void + */ + void addPoi(std::string namePoi, std::string afterWp); + + /** + * Calculates the distance between waypoint and POI + * @param CWaypoint const &wp - waypoint (IN) + * @param CPOI& poi - POI (IN) + * @return double - Distance in Kms + */ + double getDistanceNextPoi(CWaypoint const &wp, CPOI& poi); + + /** + * prints all the waypoints and POIs in the route + */ + void print(); + + /** + * The function is an extension of addPoi which searches the Databases and add the + * Waypoint or the POI which matches the name. + */ + void operator += (std::string const &name); + + /** + * A copy assignment operator + * @param CRoute const & rhs - CRoute const object (IN) + * @returnval CRoute& + */ + CRoute& operator=(CRoute const & rhs); + + /** + * An addition operator + * @param CRoute const & rhs - CRoute const object (IN) + * @returnval CRoute + */ + CRoute operator+(CRoute const & rhs); + +}; +/******************** +** CLASS END +*********************/ +#endif /* CROUTE_H */ diff --git a/NavigationSystem/Workspace/myCode/CWaypoint.cpp b/NavigationSystem/myCode/CWaypoint.cpp similarity index 64% rename from NavigationSystem/Workspace/myCode/CWaypoint.cpp rename to NavigationSystem/myCode/CWaypoint.cpp index c0115d1..d421434 100644 --- a/NavigationSystem/Workspace/myCode/CWaypoint.cpp +++ b/NavigationSystem/myCode/CWaypoint.cpp @@ -8,6 +8,7 @@ * * ****************************************************************************/ + //System Include Files #include #include @@ -17,8 +18,8 @@ //Macros #define PI_VALUE (atan(1) * 4) -#define degToRad(angleInDegrees) ((angleInDegrees) * PI_VALUE / 180.0) -#define radToDeg(angleInRadians) ((angleInRadians) * 180.0 / PI_VALUE) +#define degToRad(angleInDegrees) ((angleInDegrees) * PI_VALUE / 180.0) +#define radToDeg(angleInRadians) ((angleInRadians) * 180.0 / PI_VALUE) //Namespaces using namespace std; @@ -30,51 +31,20 @@ using namespace std; * param@ string name - name of a Waypoint (IN) * param@ double latitude - latitude of a Waypoint (IN) * param@ double longitude - longitude of a Waypoint (IN) + * param@ wp_type type - type of data the object represents: + * POI / Waypoint / Invalid(IN) */ -CWaypoint::CWaypoint(string name, double latitude, double longitude) -{ - // Solution (Exercise 1.1; section c): - // set the class data members with the parameters values passed during an object creation. - this->set(name, latitude, longitude); - -#ifdef SHOWADRESS - - cout << "A CWaypoint Object has be created at address : " << this << endl; - cout << "Attribute Name \t" <<"Attribute Address \t"<< "Attribute Size \t" << "Attribute Value\n"; - - /* - * Solution (Exercise 1.1; section c): - * Data occupied by different attributes are as follows: - * Data occupied by "m_name" = depends on the number of character in a string - * Data occupied by "m_latitude" = 8 bytes since it is of type double - * Data occupied by "m_longitude" = 8 bytes since it is of type double - */ - cout << "m_name \t\t" << &this->m_name << "\t\t" << this->m_name.size() << "\t\t" << this->m_name << "\n"; - cout << "m_latitude \t" << &this->m_latitude << "\t\t" << sizeof(this->m_latitude) << "\t\t" << this->m_latitude << "\n"; - cout << "m_longitude \t" << &this->m_longitude << "\t\t" << sizeof(this->m_longitude) << "\t\t" << this->m_longitude << "\n\n"; - -#endif -} - - -/** - * Sets the current waypoint co-ordinate values - * param@ string name - name of a Waypoint (IN) - * param@ double latitude - latitude of a Waypoint (IN) - * param@ double longitude - longitude of a Waypoint (IN) - * returnvalue@ void - */ -void CWaypoint::set(string name, double latitude, double longitude) +CWaypoint::CWaypoint(string name, double latitude, double longitude, wp_type type) { - // Solution (Exercise 1.1; section b): if (((latitude >= LATITUDE_MIN) && (latitude <= LATITUDE_MAX)) && - ((longitude >= LONGITUDE_MIN) && (longitude <= LONGITUDE_MAX)) && - (!name.empty())) + ((longitude >= LONGITUDE_MIN) && (longitude <= LONGITUDE_MAX)) && + (!name.empty())) { // All the parameters values are valid; we can assign these values to the respective data members of the class this->m_name = name; this->m_latitude = latitude; this->m_longitude = longitude; + this->m_type = type; } else { @@ -82,10 +52,20 @@ void CWaypoint::set(string name, double latitude, double longitude) this->m_name = ""; this->m_latitude = 0; this->m_longitude = 0; + this->m_type = CWaypoint::INVALID; } } +/** + * Destructor + */ +CWaypoint::~CWaypoint() +{ + // do nothing +} + + /** * Return the current waypoint co-ordinate name * retuvalue@ string name - name of a Waypoint @@ -128,22 +108,60 @@ void CWaypoint::getAllDataByReference(string& name, double& latitude, double& lo name = this->getName(); latitude = this->getLatitude(); longitude = this->getLongitude(); +} + + +/** + * Converts the Latitude in decimal to deg-min-sec format + * param@ int& deg - latitude in degrees (OUT) + * param@ int& deg - latitude in minutes (OUT) + * param@ double& ss - latitude in seconds (OUT) + * returnvalue@ void + */ +void CWaypoint::transformLatitude2degmmss(int& deg, int& mm, double& ss) +{ + // Solution (Exercise 1.1; section e) + deg = this->m_latitude; + mm = (this->m_latitude - deg) * 60; + ss = (((this->m_latitude - deg) * 60) - mm) * 60; - /* - * Solution (Exercise 1.1; section h): - * The address of the variables of a calling function is same as the address of this function parameters. - * This is due to "&" in the parameter, which implies that the function call is pass-by-reference. - * Since the address is same, the value inside them are same as well, but the function member or method - * "getAllDataByReference" overrides the value with the data members value. Thus, once the method is returned, - * the local variables used during function call will have this object's data members value. - */ -#ifdef SHOWADRESS - cout << "Parameters variables at addresses : \n"; - cout << "Attribute Name \t" <<"Attribute Address \t"<< "Attribute Size \t" << "Attribute Value\n"; - cout << "name \t\t" << &name << "\t\t" << name.size() << "\t\t" << name << "\n"; - cout << "latitude \t" << &latitude << "\t\t" << sizeof(latitude) << "\t\t" << latitude << "\n"; - cout << "longitude \t" << &longitude << "\t\t" << sizeof(longitude) << "\t\t" << longitude << "\n"; -#endif + // check if the latitude is negative; if so change the sign of minute and second + if (this->m_latitude < 0) + { + mm = -mm; + ss = -ss; + } + else + { + // Do nothing + } +} + + +/** + * Converts the Longitude in decimal to deg-min-sec format + * param@ int& deg - longitude in degrees (OUT) + * param@ int& deg - longitude in minutes (OUT) + * param@ double& ss - longitude in seconds (OUT) + * returnvalue@ void + */ +void CWaypoint::transformLongitude2degmmss(int& deg, int& mm, double& ss) +{ + // Solution (Exercise 1.1; section e) + deg = this->m_longitude; + mm = (this->m_longitude - deg) * 60; + ss = (((this->m_longitude - deg) * 60) - mm) * 60; + + // check if the longitude is negative; if so change the sign of minute and second + if (this->m_longitude < 0) + { + mm = -mm; + ss = -ss; + } + else + { + // Do nothing + } } @@ -170,7 +188,6 @@ double CWaypoint::calculateDistance(const CWaypoint& wp) */ void CWaypoint::print(int format) { - // Solution (Exercise 1.1; section e) if (format == DEGREE) { // Latitude and Longitude in decimal format @@ -196,54 +213,30 @@ void CWaypoint::print(int format) /** - * Converts the Latitude in decimal to deg-min-sec format - * param@ int& deg - latitude in degrees (OUT) - * param@ int& deg - latitude in minutes (OUT) - * param@ double& ss - latitude in seconds (OUT) - * returnvalue@ void + * An operator overloaded friend function which prints the waypoint information + * param@ ostream &stream - output stream (IN/OUT) + * param@ CWaypoint const &wp - A Waypoint (IN) + * returnvalue@ output stream with the waypoint information */ -void CWaypoint::transformLatitude2degmmss(int& deg, int& mm, double& ss) +ostream& operator<< (ostream &stream, CWaypoint const &wp) { - // Solution (Exercise 1.1; section e) - deg = this->m_latitude; - mm = (this->m_latitude - deg) * 60; - ss = (((this->m_latitude - deg) * 60) - mm) * 60; + CWaypoint outWp = wp; - // check if the latitude is negative; if so change the sign of minute and second - if (this->m_latitude < 0) - { - mm = -mm; - ss = -ss; - } - else - { - // Do nothing - } -} + string name; + double latitude, longitude; + outWp.getAllDataByReference(name, latitude, longitude); -/** - * Converts the Longitude in decimal to deg-min-sec format - * param@ int& deg - longitude in degrees (OUT) - * param@ int& deg - longitude in minutes (OUT) - * param@ double& ss - longitude in seconds (OUT) - * returnvalue@ void - */ -void CWaypoint::transformLongitude2degmmss(int& deg, int& mm, double& ss) -{ - // Solution (Exercise 1.1; section e) - deg = this->m_longitude; - mm = (this->m_longitude - deg) * 60; - ss = (((this->m_longitude - deg) * 60) - mm) * 60; + int deg, mm; + double ss; - // check if the longitude is negative; if so change the sign of minute and second - if (this->m_longitude < 0) - { - mm = -mm; - ss = -ss; - } - else - { - // Do nothing - } + stream << "Waypoint : " << name << "\n"; + + outWp.transformLatitude2degmmss(deg, mm, ss); + stream << "Latitude : " << deg << "deg " << mm << "min " << ss << "s\n"; + + outWp.transformLongitude2degmmss(deg, mm, ss); + stream << "Longitude : " << deg << "deg " << mm << "min " << ss << "s \n"; + + return stream; } diff --git a/NavigationSystem/Workspace/myCode/CWaypoint.h b/NavigationSystem/myCode/CWaypoint.h similarity index 55% rename from NavigationSystem/Workspace/myCode/CWaypoint.h rename to NavigationSystem/myCode/CWaypoint.h index 123fce0..0bc819f 100644 --- a/NavigationSystem/Workspace/myCode/CWaypoint.h +++ b/NavigationSystem/myCode/CWaypoint.h @@ -15,18 +15,11 @@ //System Include Files #include +#include //Own Include Files - //Macros -/** - * Solution (Exercise 1.1; section f): - * - * Macros should be defined here (CWaypoint.h) so that it can be accessed by - * both print method and calling function in main.cpp or *.cpp which includes - * this header file. - */ #define DEGREE 1 #define MMSS 2 @@ -35,107 +28,121 @@ #define LONGITUDE_MIN (-180) #define LONGITUDE_MAX (+180) -//#define SHOWADRESS class CWaypoint { -private: +public: + + enum wp_type + { + WAYPOINT, + POI, + INVALID, + }; /** - * Converts the Latitude in decimal to deg-min-sec format - * param@ int& deg - latitude in degrees (OUT) - * param@ int& deg - latitude in minutes (OUT) - * param@ double& ss - latitude in seconds (OUT) - * returnvalue@ void + * CWaypoint constructor: + * Sets the value of an object when created. + * param@ string name - name of a Waypoint, default value "" (IN) + * param@ double latitude - latitude of a Waypoint, default value 0 (IN) + * param@ double longitude - longitude of a Waypoint,default value 0 (IN) + * param@ wp_type type - Type of data - POI / Waypoint, default invalid (IN) */ - void transformLatitude2degmmss(int& deg, int& mm, double& ss); + CWaypoint(std::string name = "", double latitude = 0, double longitude = 0, wp_type type = WAYPOINT); /** - * Converts the Longitude in decimal to deg-min-sec format - * param@ int& deg - longitude in degrees (OUT) - * param@ int& deg - longitude in minutes (OUT) - * param@ double& ss - longitude in seconds (OUT) - * returnvalue@ void + * Destructor */ - void transformLongitude2degmmss(int& deg, int& mm, double& ss); - -protected: + virtual ~CWaypoint(); - /* - * A name for the waypoint. - * eg: Berlin, California, Rio, Sydney etc - */ - std::string m_name; - - /** - * The latitude value of a co-ordinate - */ - double m_latitude; - - /** - * The longitude value of a co-ordinate - */ - double m_longitude; - -public: - - /** - * CWaypoint constructor: - * Sets the value of an object when created. - * param@ string name - name of a Waypoint, default value "" (IN) - * param@ double latitude - latitude of a Waypoint, default value 0 (IN) - * param@ double longitude - longitude of a Waypoint,default value 0 (IN) - */ - CWaypoint(std::string name = "", double latitude = 0, double longitude = 0); // Solution (Exercise 1.1; section c): - - /** - * Sets the current waypoint co-ordinate values - * param@ string name - name of a Waypoint (IN) - * param@ double latitude - latitude of a Waypoint (IN) - * param@ double longitude - longitude of a Waypoint (IN) - * returnvalue@ void - */ - void set(std::string name, double latitude, double longitude); - - /** + /** * Return the current waypoint co-ordinate name * retuvalue@ string name - name of a Waypoint */ - std::string getName(); + std::string getName(); - /** + /** * Return the current waypoint latitude * returnvalue@ double latitude - latitude of a Waypoint */ - double getLatitude(); + double getLatitude(); - /** + /** * Return the current waypoint longitude * returnvalue@ double longitude- longitude of a Waypoint */ - double getLongitude(); + double getLongitude(); - /** + /** * Return the current waypoint co-ordinate values * param@ string& name - name of a Waypoint (OUT) * param@ double& latitude - latitude of a Waypoint (OUT) * param@ double& longitude - longitude of a Waypoint (OUT) * returnvalue@ void */ - void getAllDataByReference(std::string& name, double& latitude, double& longitude); + void getAllDataByReference(std::string& name, double& latitude, double& longitude); - /** + /** + * Converts the Latitude in decimal to deg-min-sec format + * param@ int& deg - latitude in degrees (OUT) + * param@ int& deg - latitude in minutes (OUT) + * param@ double& ss - latitude in seconds (OUT) + * returnvalue@ void + */ + void transformLatitude2degmmss(int& deg, int& mm, double& ss); + + /** + * Converts the Longitude in decimal to deg-min-sec format + * param@ int& deg - longitude in degrees (OUT) + * param@ int& deg - longitude in minutes (OUT) + * param@ double& ss - longitude in seconds (OUT) + * returnvalue@ void + */ + void transformLongitude2degmmss(int& deg, int& mm, double& ss); + + /** * Return the distance between 2 waypoint co-ordinates * param@ const CWaypoint& wp - Waypoint co-ordinate (IN) * returnvalue@ double - Distance in KMs */ - double calculateDistance(const CWaypoint& wp); + double calculateDistance(const CWaypoint& wp); + + /** + * Prints the waypoint values in Degree-Mins-secs format or Decimal format + * param@ int format - Decimal or Deg-min-ss (OUT) + * returnvalue@ void + */ + virtual void print(int format); + + /** + * An operator overloaded friend function which prints the waypoint information + * param@ ostream &stream - output stream (IN/OUT) + * param@ CWaypoint const &wp - A Waypoint (IN) + * returnvalue@ output stream with the waypoint information + */ + friend std::ostream& operator<< (std::ostream &stream, CWaypoint const &wp); - /** - * Prints the waypoint values in Degree-Mins-secs format or Decimal format - * returnvalue@ void - */ - void print(int format); +private: + + /* + * A name for the waypoint. + * eg: Berlin, California, Rio, Sydney etc + */ + std::string m_name; + /** + * The latitude value of a co-ordinate + */ + double m_latitude; + + /** + * The longitude value of a co-ordinate + */ + double m_longitude; + + /** + * The type of data - POI or Waypoint + */ + wp_type m_type; }; /******************** ** CLASS END diff --git a/NavigationSystem/myCode/CWpDatabase.cpp b/NavigationSystem/myCode/CWpDatabase.cpp new file mode 100644 index 0000000..2e8fdac --- /dev/null +++ b/NavigationSystem/myCode/CWpDatabase.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CWpDatabase.cpp +* Author : Bharath Ramachandraiah +* Description : The file defines all the methods pertaining to the +* class type - class CWpDatabase. +* The class CWpDatabase is used to hold the information +* of all the waypoints in a container. +* +****************************************************************************/ + +//System Include Files +#include + +//Own Include Files +#include "CWpDatabase.h" + +//Namespaces +using namespace std; + +//Method Implementations +/** + * CWpDatabase constructor + */ +CWpDatabase::CWpDatabase() +{ + // do nothing +} + + +/** + * Add a Waypoint to the database + * param@ CWaypoint const &wp - Waypoint (IN) + * returnvalue@ void + */ +void CWpDatabase::addWaypoint(CWaypoint const &wp) +{ + CWaypoint inWp = wp; + pair ret; + + if (!inWp.getName().empty()) + { + ret = this->m_Wp.insert(pair(inWp.getName(), wp)); + + if (ret.second == false) + { + cout << "WARNING: Waypoint already exists in the Database.\n" << wp << endl; + } + } + else + { + cout << "WARNING: Trying to add invalid Waypoint to the Database.\n" << wp << endl; + } +} + + +/** + * Get pointer to a Waypoint from the Database which matches the name + * param@ string name - name of a Waypoint (IN) + * returnvalue@ CPOI* - Pointer to a Waypoint in the database + */ +CWaypoint* CWpDatabase::getPointerToWaypoint(string name) +{ + CWaypoint *pWp = 0; + + if (!this->m_Wp.empty()) + { + Wp_Map_Itr_t wpItr = this->m_Wp.find(name); + + if (wpItr != this->m_Wp.end()) + { + // element found + pWp = &wpItr->second; + } + } + + return pWp; +} + + +/** + * Get Waypoints from the Database + * returnvalue@ Wp_Map_t - Waypoints in the Database (OUT) + */ +const Wp_Map_t CWpDatabase::getWpsFromDatabase() const +{ + return (this->m_Wp); +} + + +/** + * Reset the Database + * returnvalue@ void + */ +void CWpDatabase::resetWpsDatabase() +{ + this->m_Wp.clear(); +} + + +/** + * Print all the Waypoints in the database + * returnvalue@ void + */ +void CWpDatabase::print() +{ + for (Wp_Map_Itr_t wpItr = this->m_Wp.begin(); wpItr != this->m_Wp.end(); ++wpItr) + { + cout << wpItr->second << endl; + } +} diff --git a/NavigationSystem/myCode/CWpDatabase.h b/NavigationSystem/myCode/CWpDatabase.h new file mode 100644 index 0000000..6aef02f --- /dev/null +++ b/NavigationSystem/myCode/CWpDatabase.h @@ -0,0 +1,78 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : CWpDatabase.h +* Author : Bharath Ramachandraiah +* Description : The file defines a class CWpDatabase. +* The class CWpDatabase is used to hold the information +* of all the waypoints in a container. +* +****************************************************************************/ + +#ifndef CWPDATABASE_H +#define CWPDATABASE_H + +//System Include Files +#include +#include + +//Own Include Files +#include "CWaypoint.h" + +//typedefs +typedef std::map Wp_Map_t; +typedef std::map::iterator Wp_Map_Itr_t; + +class CWpDatabase { +private: + + /** + * An Associative container to store waypoints. + * key - name + * value - waypoint + */ + Wp_Map_t m_Wp; + +public: + + /** + * CWpDatabase constructor + */ + CWpDatabase(); + + /** + * Add a Waypoint to the database + * param@ CWaypoint const &wp - Waypoint (IN) + * returnvalue@ void + */ + void addWaypoint(CWaypoint const &wp); + + /** + * Get pointer to a Waypoint from the Database which matches the name + * param@ string name - name of a Waypoint (IN) + * returnvalue@ CWaypoint* - Pointer to a Waypoint in the database + */ + CWaypoint* getPointerToWaypoint(std::string name); + + /** + * Get Waypoints from the Database + * returnvalue@ Wp_Map_t - Waypoints in the Database (OUT) + */ + const Wp_Map_t getWpsFromDatabase() const; + + /** + * Resets the Database + * returnvalue@ void + */ + void resetWpsDatabase(); + + /** + * Print all the Waypoints in the database + * returnvalue@ void + */ + void print(); +}; +/******************** +** CLASS END +*********************/ +#endif /* CWPDATABASE_H */ diff --git a/NavigationSystem/myCode/Database-poi.txt b/NavigationSystem/myCode/Database-poi.txt new file mode 100644 index 0000000..4cfd9a9 --- /dev/null +++ b/NavigationSystem/myCode/Database-poi.txt @@ -0,0 +1,10 @@ +Gas station; Aral Tankst.; Refuel your vehicle; 49.871558; 8.639206 +Gas station; Aral Tankstelle; Refuel your vehicle; 49.868538; 8.645465 +Touristic; Church 7 Days; Adventist Chruch; 49.839096; 8.646294 +Touristic; Church Holy; Freie Christengemeinde; 49.865072; 8.647415 +Restaurant; El Quinto Vino; Spanish Restaurant ; 49.813422; 8.646246 +University; HDA BuildingC10; An awesome University; 49.86727; 8.638459 +Gas station; Ladestation; Electric vehicle charge; 49.811698; 8.646074 +Restaurant; Starbucks; A blissful coffee; 49.872409; 8.650744 +Restaurant; SushiRestaurant; Asian food today!; 49.869365; 8.645922 +Restaurant; Thessaloniki; Greek Restaurant ; 49.862869; 8.646691 diff --git a/NavigationSystem/myCode/Database-wp.txt b/NavigationSystem/myCode/Database-wp.txt new file mode 100644 index 0000000..531686e --- /dev/null +++ b/NavigationSystem/myCode/Database-wp.txt @@ -0,0 +1,8 @@ +Berliner Alle; 49.866851; 8.634864 +Bessunger; 49.846994; 8.646193 +FriedrichStrasse; 49.838545; 8.645571 +Katharinen Str.; 49.824827; 8.644529 +Landskronstrasse; 49.853308; 8.646835 +Neckarstrasse; 49.8717; 8.644417 +Rheinstrasse; 49.870267; 8.633266 +Wartehalle; 49.820845; 8.644222 diff --git a/NavigationSystem/Workspace/myCode/NavigationSystem.tpr b/NavigationSystem/myCode/NavigationSystem.tpr similarity index 71% rename from NavigationSystem/Workspace/myCode/NavigationSystem.tpr rename to NavigationSystem/myCode/NavigationSystem.tpr index 66bc88f..742309d 100644 --- a/NavigationSystem/Workspace/myCode/NavigationSystem.tpr +++ b/NavigationSystem/myCode/NavigationSystem.tpr @@ -1,6 +1,5 @@ [Project] Language=cpp -Project.JDK=D:\\Installations\\TogetherArchitect\\jdk Root.0=$TGH$/lib/javax.jar Root.0.access=import Root.1=$TGH$/jdk/jre/lib/rt.jar @@ -14,24 +13,24 @@ Root.2.srcControlEnabled=false Root.2.srcControlProject= Version=3.0 projectfile.encoding=Cp1252 +[editor] +recent.file.0=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CPersistentStorage.h +recent.file.1=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CCSV.h +recent.file.2=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\Class1.h +recent.file.3=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CNavigationSystem.h +recent.file.4=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CRoute.h +recent.file.5=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CGPSSensor.h +recent.file.6=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CWpDatabase.h +recent.file.7=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CPoiDatabase.h +recent.file.8=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CPOI.h +recent.file.9=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_2\\Workspace\\NavigationSystem\\myCode\\CWaypoint.h [workspace] Developer.CodingWorkspace={{0,2,-1,0,0,0,0,0,0,1,0,50,75,25,-1,-1,-1,-1}${0,1,-1,0,0,0,0,1,0,1,0,50,75,25,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,66,50,25,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,66,50,25,-1,-1,-1,-1}${0,-1,-1,0,0,0,0,0,0,1,0,5,5,5,-1,-1,-1,-1}${0,5,-1,0,0,0,0,0,0,1,0,50,50,25,-1,-1,-1,-1}${0,4,-1,0,0,0,0,1,0,1,1,66,50,25,-1,-1,-1,-1}${0,7,-1,0,0,0,0,0,0,1,0,50,50,75,-1,-1,-1,-1}} Developer.DebugWorkspace={{0,2,-1,0,0,0,0,0,0,1,0,50,75,25,-1,-1,-1,-1}${0,1,-1,0,0,0,0,1,0,1,1,50,75,25,-1,-1,-1,-1}${0,3,-1,0,0,0,0,0,0,1,0,50,50,25,-1,-1,-1,-1}${0,3,-1,0,0,0,0,0,0,1,0,50,50,25,-1,-1,-1,-1}${0,-1,-1,0,0,0,0,0,0,1,0,5,5,5,-1,-1,-1,-1}${0,4,-1,0,0,0,0,0,0,1,0,50,50,25,-1,-1,-1,-1}${0,0,-1,0,0,0,0,1,0,1,0,75,5,5,-1,-1,-1,-1}${0,7,-1,0,0,0,0,0,0,1,0,50,50,75,-1,-1,-1,-1}} Developer.DesignWorkspace={{0,2,-1,0,0,0,0,1,0,1,0,50,75,22,-1,-1,-1,-1}${0,1,-1,0,0,0,0,0,0,1,0,50,75,22,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,50,50,22,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,50,50,22,-1,-1,-1,-1}${0,-1,-1,0,0,0,0,0,0,1,0,5,5,5,-1,-1,-1,-1}${0,4,-1,0,0,0,0,1,0,1,1,50,50,22,-1,-1,-1,-1}${0,0,-1,0,0,0,0,0,0,1,0,75,5,5,-1,-1,-1,-1}${0,7,-1,0,0,0,0,0,0,1,0,50,50,75,-1,-1,-1,-1}} -Developer.NavigationSystem={{0,2,-1,0,0,0,0,1,0,1,1,87,75,0,-1,-1,-1,-1}${0,1,-1,0,0,0,0,1,0,1,0,87,75,0,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,50,50,0,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,50,50,0,-1,-1,-1,-1}${0,-1,-1,0,0,0,0,0,0,1,0,5,5,5,-1,-1,-1,-1}${0,4,-1,0,0,0,0,1,0,1,0,50,50,0,-1,-1,-1,-1}${0,0,-1,0,0,0,0,0,0,1,0,75,5,5,-1,-1,-1,-1}${0,7,-1,0,0,0,0,0,0,1,0,50,50,75,-1,-1,-1,-1}} +Developer.NavigationSystem={{0,2,-1,0,0,0,0,1,0,1,1,63,75,25,-1,-1,-1,-1}${0,1,-1,0,0,0,0,1,0,1,0,63,75,25,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,50,50,25,-1,-1,-1,-1}${0,3,-1,0,0,0,0,1,0,1,0,50,50,25,-1,-1,-1,-1}${0,-1,-1,0,0,0,0,0,0,1,0,5,5,5,-1,-1,-1,-1}${0,4,-1,0,0,0,0,0,0,1,0,50,50,25,-1,-1,-1,-1}${0,0,-1,0,0,0,0,1,0,1,0,87,5,5,-1,-1,-1,-1}${0,7,-1,0,0,0,0,0,0,1,0,50,50,75,-1,-1,-1,-1}} names.Developer={NavigationSystem,DesignWorkspace,CodingWorkspace,DebugWorkspace} [vcs] provider.class=CVS LAN [lastOpenProjectName] Developer=NavigationSystem -[editor] -recent.file.0=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CWaypoint.h -recent.file.1=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CGPSSensor.h -recent.file.2=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CPOI.h -recent.file.3=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CPOI.cpp -recent.file.4=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CNavigationSystem.h -recent.file.5=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CRoute.h -recent.file.6=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\CPoiDatabase.h -recent.file.7=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\Class1.h -recent.file.8=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\Model\\CWaypoint.h -recent.file.9=D:\\HDA\\1_sem\\System Design (APT)\\Lab\\Assignment_1\\Workspace\\myCode\\Model\\Class1.h diff --git a/NavigationSystem/myCode/NavigationSystem.tws b/NavigationSystem/myCode/NavigationSystem.tws new file mode 100644 index 0000000..8ea9543 --- /dev/null +++ b/NavigationSystem/myCode/NavigationSystem.tws @@ -0,0 +1,4 @@ +workspace.diagram.active = +workspace.diagram.open.0 = +workspace.editor.active = D:\HDA\1_sem\System Design (APT)\Lab\Assignment_2\Workspace\NavigationSystem\myCode\CPersistentStorage.h +workspace.editor.open.0 = D:\HDA\1_sem\System Design (APT)\Lab\Assignment_2\Workspace\NavigationSystem\myCode\CPersistentStorage.h diff --git a/NavigationSystem/myCode/default.dfPackage b/NavigationSystem/myCode/default.dfPackage new file mode 100644 index 0000000..199a06d --- /dev/null +++ b/NavigationSystem/myCode/default.dfPackage @@ -0,0 +1,140 @@ +package idhb7u7jp39d4tnjp39di4r; + +/** +@version 2.0 +@physicalPackage +@__modelType diagram +*/ +class diagram { +/** +@__ref +@__modelType reference +*/ +class reference { +} +/** +@__ref +@__modelType reference +*/ +class reference1 { +} +/** +@__ref +@__modelType reference +*/ +class reference2 { +} +/** +@__ref +@__modelType reference +*/ +class reference3 { +} +/** +@__ref +@__modelType reference +*/ +class reference4 { +} +/** +@__ref +@__modelType reference +*/ +class reference5 { +} +/** +@__ref +@__modelType reference +*/ +class reference6 { +} +/** +@__ref +@__modelType reference +*/ +class reference7 { +} +/** +@__ref +@__modelType reference +*/ +class reference8 { +} +/** +@__ref +@__modelType reference +*/ +class reference9 { +} +}/** +@__tags +@shapeType ClassDiagram +@changelog rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVz +aG9sZHhwP0AAAAAAAAx3CAAAABAAAAACc3IADmphdmEubGFuZy5Mb25nO4vkkMyPI98CAAFKAAV2 +YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyVHQuU4IsCAAB4cAAAAWdh6jwAc3IAE2phdmEudXRp +bC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNpemV4cAAAAAF3BAAAAApzcgAlZGUubW5sLmRvY2Jv +b2s0VEEuaW1wbC5DaGFuZ2VMb2dFbnRyeQeNjrX5qiSfAgADTAAIaG9zdG5hbWV0ABJMamF2YS9s +YW5nL1N0cmluZztMAARuYW1lcQB+AAhMAAR1c2VycQB+AAh4cHQAD0RFU0tUT1AtTU5MNDdGMnQA +CTxkZWZhdWx0PnQABXJiaGFyeHNxAH4AAgAAAWdsNvQAc3EAfgAFAAAAAXcEAAAACnNxAH4AB3QA +D0RFU0tUT1AtTU5MNDdGMnQACTxkZWZhdWx0PnQABXJiaGFyeHg= +@elementChangelogs rO0ABXNyABFqYXZhLnV0aWwuSGFzaE1hcAUH2sHDFmDRAwACRgAKbG9hZEZhY3RvckkACXRocmVz +aG9sZHhwP0AAAAAAAAx3CAAAABAAAAAIdAAcPG9pcmVmOmNwcCNDbGFzcyNDUE9JOm9pcmVmPnB0 +ABw8b2lyZWY6Y3BwI0NsYXNzI0NDU1Y6b2lyZWY+c3EAfgAAP0AAAAAAAAx3CAAAABAAAAABc3IA +DmphdmEubGFuZy5Mb25nO4vkkMyPI98CAAFKAAV2YWx1ZXhyABBqYXZhLmxhbmcuTnVtYmVyhqyV +HQuU4IsCAAB4cAAAAWdsNvQAc3IAE2phdmEudXRpbC5BcnJheUxpc3R4gdIdmcdhnQMAAUkABHNp +emV4cAAAAAF3BAAAAApzcgAlZGUubW5sLmRvY2Jvb2s0VEEuaW1wbC5DaGFuZ2VMb2dFbnRyeQeN +jrX5qiSfAgADTAAIaG9zdG5hbWV0ABJMamF2YS9sYW5nL1N0cmluZztMAARuYW1lcQB+AAtMAAR1 +c2VycQB+AAt4cHQAD0RFU0tUT1AtTU5MNDdGMnQABENDU1Z0AAVyYmhhcnh4dAAiPG9pcmVmOmNw +cCNDbGFzcyNDR1BTU2Vuc29yOm9pcmVmPnB0ACk8b2lyZWY6Y3BwI0NsYXNzI0NOYXZpZ2F0aW9u +U3lzdGVtOm9pcmVmPnB0ACM8b2lyZWY6Y3BwI0NsYXNzI0NXcERhdGFiYXNlOm9pcmVmPnB0ACQ8 +b2lyZWY6Y3BwI0NsYXNzI0NQb2lEYXRhYmFzZTpvaXJlZj5wdAAhPG9pcmVmOmNwcCNDbGFzcyND +V2F5cG9pbnQ6b2lyZWY+cHQAHjxvaXJlZjpjcHAjQ2xhc3MjQ1JvdXRlOm9pcmVmPnB4 +*/ +class __tags { +}/** +@__options +*/ +class __options { +}/** +@__positions =849,570,340,386:oigroup> +=655,331,313,740:oigroup> +=430,750,200,174,1:oigroup> +=880,636,880,801:oigroup> +=830,636,590,750:oigroup> +=281,740,281,692:oigroup> +=939,390,295,470:oigroup> +=413,791,28,16,0:oigroup> +=749,706,395,765:oigroup> +=444,79,132,123,1:oigroup> +=893,303,372,303:oigroup> +=1032,390,550,750:oigroup> +=237,470,237,386:oigroup> +=172,68,200,318,1:oigroup> +=700,331,510,750:oigroup> +=310,386,26,16,0:oigroup> +=730,525,353,525:oigroup> +=749,570,200,302,1:oigroup> +=730,360,372,360:oigroup> +=930,370,1079,370:oigroup> +=749,716,630,778:oigroup> +=813,801,304,386:oigroup> +=610,166,136,165,1:oigroup> +=730,350,200,286,1:oigroup> +=749,631,353,631:oigroup> +=930,603,949,603:oigroup> +=746,801,186,101,1:oigroup> +=749,811,409,811:oigroup> +=819,570,326,370:oigroup> +=634,807,28,16,0:oigroup> +=784,570,290,370:oigroup> +=209,740,200,174,1:oigroup> +=749,827,630,827:oigroup> +=470,750,270,386:oigroup> +=180,470,173,222,1:oigroup> +=780,636,377,740:oigroup> +=893,152,186,238,1:oigroup> +=985,390,345,740:oigroup> +=893,221,746,221:oigroup> +*/ +class __positions { +} \ No newline at end of file diff --git a/NavigationSystem/myCode/main.cpp b/NavigationSystem/myCode/main.cpp new file mode 100644 index 0000000..4d6e2ac --- /dev/null +++ b/NavigationSystem/myCode/main.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** +*============= Copyright by Darmstadt University of Applied Sciences ======= +**************************************************************************** +* Filename : main.cpp +* Author : Bharath Ramachandraiah +* Description : The entry file for the Navigation System Application. +* +****************************************************************************/ + +//System Include Files +#include +#include + +//Own Include Files +#include "CNavigationSystem.h" + +//Namespaces +using namespace std; + +//Macros +/** + * main function: + * An entry point to Navigation System Application. + */ +int main (void) +{ + cout << "Navigation System:" << endl << endl; + + // Set the precision to 6 decimal places + cout << std::fixed << std::setprecision(6); + + CNavigationSystem navigationSystem; + + navigationSystem.run(); + + return 0; +} diff --git a/README.md b/README.md index 217b639..a58aa70 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Advanced_Programming_Technique ## Change Branch for different projects +### Assignment 2