Question
C++ QUESTION - PLEASE DO NOT HARD CODE THE FILENAME - PLEASE DO NOT HARD CODE THE GRID RANGE Task Requirement: - Read in config.txt
C++ QUESTION
- PLEASE DO NOT HARD CODE THE FILENAME
- PLEASE DO NOT HARD CODE THE GRID RANGE
Task Requirement:
- Read in config.txt and process
- Display City Map
===================================================================
config.txt content is below:
// The range of 'horizontal' indices, inclusive // E.g. if the range is 0-4, then the indices are 0, 1, 2, 3, 4 GridX_IdxRange=0-8
// The range of 'vertical' indices, inclusive // E.g. if the range is 0-3, then the indices are 0, 1, 2, 3 GridY_IdxRange=0-8
// [x,y] grid-areas which are occupied by cities citylocation.txt
// "next day" forecasted cloud coverage (%) for // each [x,y] grid-area cloudcover.txt
// "next day" forecasted atmospheric pressure intensity (%) for // each [x,y] grid-area pressure.txt
===============================================================
citylocation.txt content is below:
[1, 1]-3-Big_City [1, 2]-3-Big_City [1, 3]-3-Big_City [2, 1]-3-Big_City [2, 2]-3-Big_City [2, 3]-3-Big_City [2, 7]-2-Mid_City [2, 8]-2-Mid_City [3, 1]-3-Big_City [3, 2]-3-Big_City [3, 3]-3-Big_City [3, 7]-2-Mid_City [3, 8]-2-Mid_City [7, 7]-1-Small_City
Background Your software company, Virtual Solutions, has just won a $1m contract to design a build a prototype Weather Information Processing System (WIPS). For this assignment, you take on the role of a software architect. You are supplied with sample input weather data (kindly provided by the meteorological station), and you need to develop a program that does the following: 1) read in and process a configuration file 2) display city map Task Requirements A) Upon startup, the program should prompt user to enter a 'configuration' filename. The program then proceeds to read the contents of the entered filename) to further initialize its own program parameters / data structures. Please refer to Appendix A, which provides details on the configuration file and its usage. B) The meteorological station has adopted a map-grid coordinate system upon which it overlays all other weather data. With regards to display city map option, please refer to Appendix B, which elaborates on this coordinate system, the unit representation, the relative positioning of different cities and its display requirements. APPENDIX A Processing Configuration File Info Upon startup, program should prompt user for the following Please enter config filename: config.txt When user presses 'Enter', the program should perform File I/O to read in the contents in the stated filename (e.g. in this case 'config.txt') The config.txt contains data like size of grid-map area (indicated by index-ranges), as well as a series of filenames, which your program should further access, in order to read in the various relevant weather data provided by the Meteorological Station. Figure A-1 below provides a sample of the actual contents within this configuration file. // The range of 'horizontal' indices, inclusive // E.g. if the range is 0-4, then the indices are 0, 1, 2, 3, GridX_IdxRange=0-8 SM // The range of 'vertical' indices, inclusive // E.g. if the range is 0-3, then the indices are 0, 1, 2, 3 Grid IdxRange=0-8 // [x,yl grid-areas which are occupied by cities citylocation.txt // "next day" forecasted cloud coverage (8) for // each [x, y] grid-area cloudcover.txt // "next day" forecasted atmospheric pressure intensity (8) for // each [x, y] grid-area pressure.txt Fig. A-1 Note : The ranges for both 'Gridx_IdxRange' and 'GridY_IdxRange' will determine the size of the display map. The ranges' values are editable! Regarding the interpretation of each input files' data format, please refer to subsequent Appendices. APPENDIX B Map-Grid Coordinate System (used by Meteorological Station) City Map Input Data & Output Requirements Figure B-1 below provides a sample of the actual contents within the input file (e.g. citylocation.txt), storing city-occupied grid areas. Interpretation of each line: Data item #1 : [x, y] => the grid indices of the "lower-left" corner of a grid area [1, 1]-3-Big_City [1, 2]-3-Big_City [1, 3)-3-Big_City [2, 1]-3-Big_City [2, 2]-3-Big_City [2, 3] -3-Big_City [2, 71-2-Mid_City [2, 81-2-Mid_City [3, 1]-3-Big_City [3, 2]-3-Big_City [3, 3]-3-Big_City [3, 7]-2-Mid_City [3, 8] -2-Mid City [7, 71-1-Small_City Delimiter char between data items #1 and #2 => '-' Data item #2: 3 => the city id (to be displayed later on map) Delimiter char between data items #2 and #3 => '-' Data item #3 : Big_City => the name of the city (to be shown later on weather forecast summary report) Fig. B-1 To aid in the visualization and understanding of how the city location input data will look like, in a 2D graphical format, please refer to the figure B-2 below. Student's INPUT Datalin graphical form) [ Highlighted in Bright Yellow ]-Grid Areals)occupied by each city [ Highlighted in Light Yellow ]-Grid Areals) surrounding each city Each [x, y] read in from the input file (see earlier Fig. B-1) describes the indices of the LOWER LEFT corner of a grid area E.g. 13, 8] refers to the Lower Left corner of this grid area 8 2- 2- Mid_City Mid_City 1 1 1 7 2- 2- Mid_City Mid_City 1- Small 6 5 [0,0] origin refers to the Lower Left corner of this grid area 4 3 3- 2 The range of (horizontal) indices to be shown on the map ranges from 0-8 (inclusive) 3- 3- 3- Big City Big City Big City 3- 3- 3- Big City BigCity Big City 3- 3- 3- Big City Big City Big_City 1 2 3 5 6 7 8 Fig. B-2 This info is retrieved from the value stored in the configuration file (see Appendix A. Fig. A-1), assigned to the variable 'GridX_IdxRange' The same treatment applies for the variable 'GridY_IdxRange', for the range of vertical indices Note : a) Bright Yellow grid areas indicate the ACTUAL Grid Area occupied by a particular city. For example, in the fig. B-2 above, the city named "Mid_City" occupies the following grid areas : [2, 7), 12. 8), (3, 7. [3, 8] b) Light Yellow grid areas indicate the grid areas surrounding the perimeter of EACH city. For example, in fig. B-2 above, the city named "Mid_City" has the following grid areas surrounding its perimeter : [1, 6), [1, 7], [1, 8), (2,6), (3,6), [4, 6), [4, 7], [4,8] The grid areas [1,9), [2.9), [3,9), [4,9) are not shown as they are BEYOND the upper limits of the vertical Gridy_IdxRange! Processing requirements - Display City Map Realistically, there is limited graphical display capabilities available when you are constrained to displaying output on Ubuntu shell's terminal. Figure B-3 below illustrates the actual display formatting requirements when user selects the "Display City Map" option from your program's menu. vmw_ubuntu@vmwubuntu: -/TEMP/CSC1251/Assn1 Note : # # # # # # 8 7 6 NN # 2 2 1 (i) The city id is displayed on the relevant grid areas, instead of city names! 4 3 2 ########### 3 3 3 3 ### Refer to Fig. B-1, which describes how each city's id value is stored in the input file # # # # # # # # # 0 1 2 3 4 5 6 7 8 Vmw_ubuntu@vmwubuntu:-/TEMP/CSCI251/Assn1$ Fig. B-3 The entire extent of the map is bounded by the '#' char! a) As discussed in earlier Appendix A, Fig. A-1, the range values for variables 'GridY_IdxRange' and 'GridY_IdxRange' can vary This implies the size and shape of your map display can change as well (e.g. it is possible to have a large 'rectangular' shaped grid-area map!). Therefore, please do not assume / "hard code" any constant values for your array sizes to store your map data! You must make use of basic C++ array, and dynamic memory allocation ( research on how to use 'new' ) to initialize the size of your arrays during program runtime, to store all relevant weather map data. The type of the array (e.g. int, double, struct, etc) is up to you, and there is no restriction on how many arrays you think is necessary to store all the relevant weather data. b) d) Before your program exit, you must deallocate all memory that was dynamically allocated by you during runtime research on how to use 'delete'). Failure to do so results in memory leak... and marks deduction! Background Your software company, Virtual Solutions, has just won a $1m contract to design a build a prototype Weather Information Processing System (WIPS). For this assignment, you take on the role of a software architect. You are supplied with sample input weather data (kindly provided by the meteorological station), and you need to develop a program that does the following: 1) read in and process a configuration file 2) display city map Task Requirements A) Upon startup, the program should prompt user to enter a 'configuration' filename. The program then proceeds to read the contents of the entered filename) to further initialize its own program parameters / data structures. Please refer to Appendix A, which provides details on the configuration file and its usage. B) The meteorological station has adopted a map-grid coordinate system upon which it overlays all other weather data. With regards to display city map option, please refer to Appendix B, which elaborates on this coordinate system, the unit representation, the relative positioning of different cities and its display requirements. APPENDIX A Processing Configuration File Info Upon startup, program should prompt user for the following Please enter config filename: config.txt When user presses 'Enter', the program should perform File I/O to read in the contents in the stated filename (e.g. in this case 'config.txt') The config.txt contains data like size of grid-map area (indicated by index-ranges), as well as a series of filenames, which your program should further access, in order to read in the various relevant weather data provided by the Meteorological Station. Figure A-1 below provides a sample of the actual contents within this configuration file. // The range of 'horizontal' indices, inclusive // E.g. if the range is 0-4, then the indices are 0, 1, 2, 3, GridX_IdxRange=0-8 SM // The range of 'vertical' indices, inclusive // E.g. if the range is 0-3, then the indices are 0, 1, 2, 3 Grid IdxRange=0-8 // [x,yl grid-areas which are occupied by cities citylocation.txt // "next day" forecasted cloud coverage (8) for // each [x, y] grid-area cloudcover.txt // "next day" forecasted atmospheric pressure intensity (8) for // each [x, y] grid-area pressure.txt Fig. A-1 Note : The ranges for both 'Gridx_IdxRange' and 'GridY_IdxRange' will determine the size of the display map. The ranges' values are editable! Regarding the interpretation of each input files' data format, please refer to subsequent Appendices. APPENDIX B Map-Grid Coordinate System (used by Meteorological Station) City Map Input Data & Output Requirements Figure B-1 below provides a sample of the actual contents within the input file (e.g. citylocation.txt), storing city-occupied grid areas. Interpretation of each line: Data item #1 : [x, y] => the grid indices of the "lower-left" corner of a grid area [1, 1]-3-Big_City [1, 2]-3-Big_City [1, 3)-3-Big_City [2, 1]-3-Big_City [2, 2]-3-Big_City [2, 3] -3-Big_City [2, 71-2-Mid_City [2, 81-2-Mid_City [3, 1]-3-Big_City [3, 2]-3-Big_City [3, 3]-3-Big_City [3, 7]-2-Mid_City [3, 8] -2-Mid City [7, 71-1-Small_City Delimiter char between data items #1 and #2 => '-' Data item #2: 3 => the city id (to be displayed later on map) Delimiter char between data items #2 and #3 => '-' Data item #3 : Big_City => the name of the city (to be shown later on weather forecast summary report) Fig. B-1 To aid in the visualization and understanding of how the city location input data will look like, in a 2D graphical format, please refer to the figure B-2 below. Student's INPUT Datalin graphical form) [ Highlighted in Bright Yellow ]-Grid Areals)occupied by each city [ Highlighted in Light Yellow ]-Grid Areals) surrounding each city Each [x, y] read in from the input file (see earlier Fig. B-1) describes the indices of the LOWER LEFT corner of a grid area E.g. 13, 8] refers to the Lower Left corner of this grid area 8 2- 2- Mid_City Mid_City 1 1 1 7 2- 2- Mid_City Mid_City 1- Small 6 5 [0,0] origin refers to the Lower Left corner of this grid area 4 3 3- 2 The range of (horizontal) indices to be shown on the map ranges from 0-8 (inclusive) 3- 3- 3- Big City Big City Big City 3- 3- 3- Big City BigCity Big City 3- 3- 3- Big City Big City Big_City 1 2 3 5 6 7 8 Fig. B-2 This info is retrieved from the value stored in the configuration file (see Appendix A. Fig. A-1), assigned to the variable 'GridX_IdxRange' The same treatment applies for the variable 'GridY_IdxRange', for the range of vertical indices Note : a) Bright Yellow grid areas indicate the ACTUAL Grid Area occupied by a particular city. For example, in the fig. B-2 above, the city named "Mid_City" occupies the following grid areas : [2, 7), 12. 8), (3, 7. [3, 8] b) Light Yellow grid areas indicate the grid areas surrounding the perimeter of EACH city. For example, in fig. B-2 above, the city named "Mid_City" has the following grid areas surrounding its perimeter : [1, 6), [1, 7], [1, 8), (2,6), (3,6), [4, 6), [4, 7], [4,8] The grid areas [1,9), [2.9), [3,9), [4,9) are not shown as they are BEYOND the upper limits of the vertical Gridy_IdxRange! Processing requirements - Display City Map Realistically, there is limited graphical display capabilities available when you are constrained to displaying output on Ubuntu shell's terminal. Figure B-3 below illustrates the actual display formatting requirements when user selects the "Display City Map" option from your program's menu. vmw_ubuntu@vmwubuntu: -/TEMP/CSC1251/Assn1 Note : # # # # # # 8 7 6 NN # 2 2 1 (i) The city id is displayed on the relevant grid areas, instead of city names! 4 3 2 ########### 3 3 3 3 ### Refer to Fig. B-1, which describes how each city's id value is stored in the input file # # # # # # # # # 0 1 2 3 4 5 6 7 8 Vmw_ubuntu@vmwubuntu:-/TEMP/CSCI251/Assn1$ Fig. B-3 The entire extent of the map is bounded by the '#' char! a) As discussed in earlier Appendix A, Fig. A-1, the range values for variables 'GridY_IdxRange' and 'GridY_IdxRange' can vary This implies the size and shape of your map display can change as well (e.g. it is possible to have a large 'rectangular' shaped grid-area map!). Therefore, please do not assume / "hard code" any constant values for your array sizes to store your map data! You must make use of basic C++ array, and dynamic memory allocation ( research on how to use 'new' ) to initialize the size of your arrays during program runtime, to store all relevant weather map data. The type of the array (e.g. int, double, struct, etc) is up to you, and there is no restriction on how many arrays you think is necessary to store all the relevant weather data. b) d) Before your program exit, you must deallocate all memory that was dynamically allocated by you during runtime research on how to use 'delete'). Failure to do so results in memory leak... and marks deductionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started