|
Does anyone happen to have an equation to calculate the distance between two lat and long points? My calculation is apparently wrong and with all the sines and cosines and the fact I've been up all night I'm a little confused. That and I specialize in databases and not geography. Also, are latitudes in the NW hemisphere supposed to be positive?
"I was bored last week and a thought occured to me: Why is it that there is a government bureau which oversees alcohol, tobacco, and firearms? I was bored enough to call up the regional office of said bureau... I asked the man who answered the phone "What wine goes best with an M-16?" He did his best to be helpful, "That depends. What are you smoking?"
-Dennis Leary
|
|
|
|
|
NAUTICAL_MILES CNavUtils::FindDistance(
LAT_DEGREES FROM_LATITUDE,
LON_DEGREES FROM_LONGITUDE,
LAT_DEGREES TO_LATITUDE,
LON_DEGREES TO_LONGITUDE)
{
double DELTA_NORTH;
double DELTA_EAST;
double DELTA_LON;
NAUTICAL_MILES RETURN_VALUE;
DELTA_NORTH = TO_LATITUDE - FROM_LATITUDE;
DELTA_LON = TO_LONGITUDE - FROM_LONGITUDE;
if (DELTA_LON > 180.0)
DELTA_LON -= 360.0;
else if (DELTA_LON < -180.0)
DELTA_LON += 360.0;
DELTA_EAST = DELTA_LON *
cos( ((FROM_LATITUDE + TO_LATITUDE) / 2.0) * DEG_TO_RAD );
RETURN_VALUE = (float)(DEG2MIN * (sqrt(pow(DELTA_NORTH,2) + pow(DELTA_EAST,2))));
return (RETURN_VALUE);
}
NORTH and EAST are positive. SOUTH and WEST negative.
|
|
|
|
|
Thanks for the quick response
"I was bored last week and a thought occured to me: Why is it that there is a government bureau which oversees alcohol, tobacco, and firearms? I was bored enough to call up the regional office of said bureau... I asked the man who answered the phone "What wine goes best with an M-16?" He did his best to be helpful, "That depends. What are you smoking?"
-Dennis Leary
|
|
|
|
|
Hi there,
I have a strange problem in my program about releasing allocated DC memory !!!
struct Container
{
CBitmap* bmp_ShapeMask;
CBitmap* bmp_DegreeMask;
CDC* dc_Shape;
CDC* dc_Degree;
.
.
.
Container()
{
bmp_ShapeMask = new CBitmap;
bmp_DegreeMask = new CBitmap;
dc_Shape = new CDC;
dc_Degree = new CDC;
}
};
ok, then i loaded images and also i allocated memory for dc_Shape and dc_Degree:
m_Con.dc_Shape->CreateCompatibleDC(.........);
m_Con.dc_Degree->CreateCompatibleDC(.........);
m_Con.bmp_ShapeMask.LoadBitmap(......);
m_Con.bmp_DegreeMask.LoadBitmap(......);
and in one of my program part, i want to release all of the allocated memories ...
i wrote:
m_Con.dc_Shape->DeleteDC();
m_Con.dc_Degree->DeleteDC();
m_Con.bmp_ShapeMask.DeleteObject();
m_Con.bmp_DegreeMask.DeleteObject();
delete m_Con.dc_Shape;
delete m_Con.dc_Degree;
delete m_Con.bmp_ShapeMask;
delete m_Con.bmp_DegreeMask;
But when i got report from system memory, i saw that my program doesn't release the memory
What's the problem ???????
Please help me !!!!!
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
You may be leaking other resources like when you do a SelectObject on the dc you must re-select the old object when you are finished.
CBitmap *pOldBitmap = dc.SelectObject(m_Con.bmp_ShapeMask);
dc.SelectObject(pOldBitmap);
Jason Henderson quasi-homepage articles "Like it or not, I'm right!"
|
|
|
|
|
He deletes DC's before bitmaps, so bitmaps are released. Besides, he gets the leak reports from C runtime, not from GDI. CBitmap can be deleted from heap even if underlying GDI object is selected in some device context.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
Hello Tomasz,
What do you think about my problem ???
What's your advice for me for finding the problem ?
Regards,
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi !
I am a OOP-newbie and I have programmed a console-app which shows a "o" moving through the console and if hitting a site getting reflected...
Here is the NON-OOP code which works:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void func_clear()
{
system("cls");
}
void main(void)
{
int r;
int x;
int y;
int xc= 80;
int yc= 25;
int zaehler;
cout <<"Mit der LEERTASTE koennen Sie die Garfikausgabe beenden.\n\n";
cout << "Bitte geben Sie eine Richtung an (1-4): ";
cin >> r;
cout << "\nBitte geben Sie eine x-Koordinate an (1-80): ";
cin >> x;
cout << "\nBitte geben sie eine y-Koordinate an (1-25): ";
cin >> y;
for (int t=1 ;t<10000; t++)
{
switch (r)
{
case 1:
if (x==1 && y==1)
{
r=4;
break;
}
if (x>1)
{
x--;
}
else
{
r=2;
}
if (y>1)
{
y--;
}
else
{
r=3;
}
break;
case 2:
if (x==xc && y==1)
{
r=3;
break;
}
if (x<xc)
{
x++;
}
else
{
r=1;
}
if (y>1)
{
y--;
}
else
{
r=4;
}
break;
case 3:
if (x==1 && y==yc)
{
r=2;
break;
}
if (x>1)
{
x--;
}
else
{
r=4;
}
if (y<yc)
{
y++;
}
else
{
r=1;
}
break;
case 4:
if (x==xc && y==yc)
{
r=1;
break;
}
if (x<xc)
{
x++;
}
else
{
r=3;
}
if (y<yc)
{
y++;
}
else
{
r=2;
}
break;
}
func_clear();
for (int iy=1; iy<y; iy++)
{
cout<<"\n"<<flush;
}
for (int ix=1; ix<x; ix++)
{
cout<<" "<<flush;
}
cout<<"0"<<flush;
zaehler = 0;
while ( zaehler < 10000000 )
{
zaehler = zaehler +1;
}
}
}
___________________________________________________
Here is the OOP code which doesn´t work:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
class bewegung
{
private:
public:
int r;
int x;
int y;
int xc;
int yc;
bewegung (){int xc=25;int yc=80;}
~bewegung () {};
void richtung (int x,int y,int r)
{
switch (r)
{
case 1:
if (x==1 && y==1)
{
r=4;
break;
}
if (x>1)
{
x--;
}
else
{
r=2;
}
if (y>1)
{
y--;
}
else
{
r=3;
}
break;
case 2:
if (x==xc && y==1)
{
r=3;
break;
}
if (x<xc)
{
x++;
}
else
{
r=1;
}
if (y>1)
{
y--;
}
else
{
r=4;
}
break;
case 3:
if (x==1 && y==yc)
{
r=2;
break;
}
if (x>1)
{
x--;
}
else
{
r=4;
}
if (y<yc)
{
y++;
}
else
{
r=1;
}
break;
case 4:
if (x==xc && y==yc)
{
r=1;
break;
}
if (x<xc)
{
x++;
}
else
{
r=3;
}
if (y<yc)
{
y++;
}
else
{
r=2;
}
break;
}
}
};
class ausgabe
{
private:
int i;
public:
ausgabe(){int iy=0;int ix=0;}
~ausgabe() {};
void bildschirm(int ax,int ay)
{
system("cls");
for (int iy=1; iy<ay; iy++)
{
cout<<"\n"<<flush;
}
for (int ix=1; ix<ax; ix++)
{
cout<<" "<<flush;
}
cout<<"0"<<flush;
}
};
void main(void)
{
int r;
int x;
int y;
int zaehler;
cout <<"Mit der LEERTASTE koennen Sie die Garfikausgabe beenden.\n\n";
cout << "Bitte geben Sie eine Richtung an: ";
cin >> r;
cout << "\nBitte geben Sie eine x-Koordinate an: ";
cin >> x;
cout << "\nBitte geben sie eine y-Koordinate an: ";
cin >> y;
for (int t=1 ;t<10000; t++)
{
bewegung b1;
b1.richtung(x,y,r);
ausgabe a1;
a1.bildschirm(x,y);
zaehler = 0;
while ( zaehler < 10000000 )
{
zaehler = zaehler +1;
}
}
}
______________________________________________
Please help me ! I am sitting in front of the code for 5 hours now and I don´t know a answer... I am getting insane ...
Thanx very much !!!
|
|
|
|
|
Please bracket your code within <pre> and </pre> tags. Also remember that your variable and function names mean little to a non German speaking audience.
/ravi
Let's put "civil" back into "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Your code is a little long ... Could you extract essence of this (I mean isolate the bug)... Is your compilation OK (no error, no warning)?
if not, what's your error/warning report?
Thanks...
Hello World!!!
from Raphaël
|
|
|
|
|
Hi,
Is there a CTextFile class in Visual C++ that allows us to read text files line by line (ReadLine and WriteLine) ? or we have to use the CFile class, read then parse the buffer for CR and LF ?
Any method to read/write text files ?
Thanks
|
|
|
|
|
CStdioFile has ReadString and WriteString methods.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
|
You may try with TerminateThread, but it's quite dangerous. Check the MSDN for list of thing which may go wrong.
Tomasz Sowinski -- http://www.shooltz.com
What is "scratch" and why can everything be made from it?
|
|
|
|
|
|
To "force" a thread to end, you have to use TerminateProcess, and as has been mentioned, it can be dangerous.
However, you can be more diplomatic than that. You could send your thread a Windows message, or set a shared variable (flag), to let the thread know it should quit. You will need to code up the thread so that it periodically checks to see if it should quit or not.
Even if you win the rat race, you're still a rat.
|
|
|
|
|
|
Sorry, but seems that you are a bit out of luck here
The problem is certainly the poor CFtpConnection implementation. If it blocks and never returns you just can't do a clean termination of the thread. You never now what exactly has been allocated and how to destroy these resources.
IMHO there are only two options:
1) Get rid of the damned CFtpConnection thing and choose a class that deals better. (I don't know any alternative, though I'm quite sure they exist!)
2) Kill your thread with TerminateThread(). Of course it will cause leaks. If this happens only in very rare conditions this might be acceptable. If your process is "long-running" it would be a good idea to count the number of killed threads and restart the whole process if it reaches a defined number (e.g. 10 or 20).
Yes, it's crappy - but it works and has no real harm to the system. All resources are cleaned up automatically on process termination.
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
1) Get rid of the damned CFtpConnection thing and choose a class that deals better. (I don't know any alternative, though I'm quite sure they exist!)
You need to use asynchronous sockets. They do not block and allow you to exit the thread when the socket timesout.
Todd Smith
|
|
|
|
|
You can do one of a couple things:
1. Look at the CInternetSession documentation. i think there is a way to get it so that calls can be made asynchronously - then the calls won't block completely, you'll be able to do other stuff.
2. Write your own FTP routines that don't block.
Good luck.
Even if you win the rat race, you're still a rat.
|
|
|
|
|
The wininet support asynchrnous processing , so it's perhaps your best bet ...
You should never terminate a thread by the wicked TerminateProcess() and TerminateThread !!!!!!! Period !!!! It's doesn't clean up nicely ...
You have 2 ways of stopping a threading , one is waiting the thread for finnishing , duh , the other is to signal a kernel object Event,Mutex to the thread that you want to terminate, this thread is waiting on it with a WaitForSingleObject and alike functions ...
Or you only program with Win"k or XP, you can use jobs to safely terminate a thread or a bunch of threads ... check the api CreateJobObject ... I think that VC6++ compiler if I'm not mistaken uses this technique to stop the threads ... on Win2k
Cheers,
Joao Vaz
And if your dream is to care for your family, to put food on the table, to provide them with an education and a good home, then maybe suffering through an endless, pointless, boring job will seem to have purpose. And you will realize how even a rock can change the world, simply by remaining obstinately stationary. - Shog9
|
|
|
|
|
Hi everybody,
I've implemented QueryStatus of the IOleCommandTarget interface. It looks like this:
interface IOleCommandTarget : IUnknown
{
[helpstring("method Exec")]
HRESULT Exec(
[in] const GUID *pguidCmdGroup,
[in] DWORD nCmdID, [in] DWORD nCmdExecOpt,
[in] VARIANTARG *pvaIn,
[in,out] VARIANTARG *pvaOut);
[helpstring("method QueryStatus")]
HRESULT QueryStatus(
[in] const GUID *pguidCmdGroup,
[in] ULONG cCmds,
[in,out] OLECMD *prgCmds,
[in,out] OLECMDTEXT *pCmdText);
};
But, when I try to compile the idl file I receive this error;
Creating Type Library...
Microsoft (R) MIDL Compiler Version 5.01.0164
Copyright (c) Microsoft Corp 1991-1997. All rights reserved.
Processing E:\development\COM experiments\ProxyObj\ProxyObj.idl
ProxyObj.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\oaidl.idl
oaidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\objidl.idl
objidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\unknwn.idl
unknwn.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\wtypes.idl
wtypes.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\ocidl.idl
ocidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\oleidl.idl
oleidl.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\servprov.idl
servprov.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\urlmon.idl
urlmon.idl
Processing D:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\msxml.idl
msxml.idl
E:\development\COM experiments\ProxyObj\ProxyObj.idl(59) : error MIDL2025 : syntax error : expecting a type specification near "OLECMD"
E:\development\COM experiments\ProxyObj\ProxyObj.idl(59) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
Error executing midl.exe.
ProxyObj.tlb - 2 error(s), 0 warning(s)
Any idea why? Should I include something special?
Thx,
/Tommy
|
|
|
|
|
this is code of gotoxy, i have made in c++ using assembly, but it is not working and giving an error of invalid operand.
plz help!!!!
void _gotoxy(int row,int cols)
{ asm MOV AH,0x2
asm MOV DH,row// problem is here,if we use
asm MOV DL,cols//constant here, it works
asm MOV BH,0x0
asm INT 0x10
}
void main()
{ clrscr();
_gotoxy(15,15);
printf("x");
getch();
}
|
|
|
|
|
Just a guess (it's been a long time ), but aren't DH and DL only 8 bits?
Try this:
void _gotoxy(int row, int col)
{
asm
{
mov ah, 2
mov bh, 0
mov dh, row & 0xff
mov dl, col & 0xff
int 0x10
}
}
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
i have checked that but it is not working, suggest any thing else, plz help!!!!
|
|
|
|