into a data structure that will be able to compare against 4 other set coordinates that I have (a box).
Upper-Left (-124.626080,48.987386)
Upper-Right (-62.361014,48.987386)
Lower-Left (-124.626080,18.005611)
Lower-Right ( -62.361014,18.005611)
I will then need to count the number of coordinates are inside the box. Please advise in any way you can!
//let's use a simple struct to hold your data
struct location_data
{
double latitude;
double longitude;
}
///let's say your file is called loc.txt
ifstream in ("loc.txt");
if (! in)
{
cout <<"couldn't open your file"; exit (1);
}
stringstream ss;
string temp, discard;
location_data local;
while (in)
{
ss.str (""); ss.clear (); /// clear stream before using
getline (in, temp,'\n');
ss <<temp;
ss>> discard>> discard; /// discard the first two values
ss>> local.latitude>> local.longitude; // thr rest will be discarded by clear
///use object local variables to compare to your reference
/// this can only work if the format of you loc.txt remains the same
}