|
|
Home » Extra libraries, Code snippets, applications etc. » Applications created with U++ » Distance - geodesic - Vincenty - very accurate
Re: Distance - geodesic - Vincenty - very accurate [message #25981 is a reply to message #25979] |
Tue, 23 March 2010 02:49 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
Strange error.
I download the Linux Distance from the above link (1499004 bytes) and try and run it:
Could not display "/home/neil/Downloads/Distance".
There is no application installed for executable files
It runs fine from /upp.out/GCC.Force_size.Gui.Shared/
I copied it (1499004 bytes) from upp.out/... to another dir and it works fine.
I replaced the file in upp.out/... with the downloaded file, same error.
I deleted it from the website and uploaded it 3 times, same error.
This is with Ubuntu 10.04b on the same computer used with theIDE to compile it.
[Updated on: Tue, 23 March 2010 03:04] Report message to a moderator
|
|
|
|
|
|
Re: Distance - geodesic - Vincenty - very accurate [message #26020 is a reply to message #26007] |
Fri, 26 March 2010 11:09 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
I found where the glitch was. It had nothing to do with Ubuntu 10.04b (although I will drop that until the 10.04 release for other problems).
I ran some tests with the Linux version and found a problem.
The copy and paste from a web site for a location in deg,min,sec was not parsed correctly.
In another Java app, Location.jar, I spent a considerable amount of time parsing the different ways the location in lat,lon format is specified on the web.
http://www.nlneilson.com/nww.html
For the Distance app, Java or C++, unless the latlon is in decimal degrees, the lat and lon should be comma delimited, this eliminated many problems with odd ball formats.
The format that was a problem in the C++ Linux version is also a problem in the Win .exe version, I just did not catch that. I will go back into the parsing code and correct that.
The Java version worked but there were two function there:
.replaceAll("\\s+", " "); // This replaces several spaces with a single space
.trim(); // this removes leading and trailing spaces
I did not know the corresponding functions in C++, my error as usual.
[Updated on: Fri, 26 March 2010 11:27] Report message to a moderator
|
|
|
|
Re: Distance - geodesic - Vincenty - very accurate [message #26022 is a reply to message #26021] |
Fri, 26 March 2010 13:08 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
TrimBoth(); I will try that.
One thing I noticed that seemed odd in upp:
The character for the degree symbol ° as int = -80
I thought that should be 176
I am handling it in upp with:
// if (ic>122 || ch=='°' || ch==''' || ch=='"') ic = 32;
if (ic>122 || ic==-80 || ic==39 || ic==34) ic = 32;
That could have something to do with the problem.
Sometimes for ° ic = -62 AND ch = -62 rather than ch = '°'
With my code the ° should be replaced with a space.
To take care of some strange stuff I have:
if (ic < 0) continue;
I could change that to:
if (ic < 0) ic = 32;
and then a few lines of code in C++ to check/remove the consecutive space/s similar to .replaceAll("\\s+", " "); in Java.
[Updated on: Fri, 26 March 2010 14:09] Report message to a moderator
|
|
|
|
|
Re: Distance - geodesic - Vincenty - very accurate [message #26056 is a reply to message #26055] |
Sat, 27 March 2010 05:31 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
That glitch is fixed, not yet for all instances.
if (ic < 0) ic = 32;
And for the multiple spaces:
changed if (j==1) to if (j==1 && Dms!="")
I tried this and several others:
12°34'56"N,12°34'56"W
12° 34' 56" N , 12° 34' 56" W
http://nlneilson.com/apps/Distance.exe
It still seems strange the integer representation of
any character would be less than 0.
edit: Still have a glitch, works fine in theIDE and then
when it is copied to a directory with other apps.
When I upload and then download the .exe has problems with the extra spaces.
With Build->clean, Build->Clean UPPOUT I could get the error re extra spaces
using Debug->Execute but Debug->Run(in debugger) only the break points in the main would work.
Downloaded 2272 and the break points work OK.
This is with Vista, I think I will try with XP, Vista has been a real pain.
I found the problem with the break points (it had nothing to do with theIDE)
and only some times with extra spaces.
It checks the latlon for decimal degrees first and I have a comment:
// with ',' ' ' '~' but only one
I will add a count for spaces and if >1 get out of that loop.
The code will also work with the input of a GGA GPS sentence so it gets a bit complicated.
[Updated on: Sat, 27 March 2010 07:42] Report message to a moderator
|
|
|
Re: Distance - geodesic - Vincenty - very accurate [message #26057 is a reply to message #26056] |
Sat, 27 March 2010 08:05 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
Dumb mistake, I really mess up sometimes.
When I port from one language to another I copy and paste and if
several lines are nearly the same I paste that in more than once
and then change what is necessary.
In Java I used dLat for a double and sLat for a String.
In Upp I used lat for a double and Lat for a String.
In the parse decimal degrees loop:
if (lon<=180 && lat>=-180)
should be lon
if (lon<=180 && lon>=-180)
This catches most error that would be caused by more than one space.
If I ever get an error caused by multiple spaces, or a report of one
I will count the spaces in the code and kick it out.
In Java this took care of it: .replaceAll("\\s+", " ");
I uploaded the file with FileZilla, downloaded and tried it, works OK.
[Updated on: Sat, 27 March 2010 08:22] Report message to a moderator
|
|
|
Re: Distance - geodesic - Vincenty - very accurate [message #26058 is a reply to message #26056] |
Sat, 27 March 2010 10:23 |
|
Hi nlneilson
Quote: | The character for the degree symbol ° as int = -80
I thought that should be 176
|
Quote: | It still seems strange the integer representation of
any character would be less than 0.
|
It is not that strange as it looks. Internally, only last byte of int is considered, that is like if you performed modulo 256 operation. In your case, -80+255=176, so it is the same char, '°' But I agree, it is kind of obfuscating, maybe it should be changed.
Regards,
Honza
|
|
|
Re: Distance - geodesic - Vincenty - very accurate [message #26065 is a reply to message #26058] |
Sun, 28 March 2010 14:25 |
nlneilson
Messages: 644 Registered: January 2010 Location: U.S. California. Mojave &...
|
Contributor |
|
|
dolik.rce wrote on Sat, 27 March 2010 10:23 | In your case, -80+255=176, so it is the same char, '°' But I agree, it is kind of obfuscating, maybe it should be changed.
|
Thanks for the explanation, usually anything strange is from my code. A change for this in upp would be good.
Koldo: "Probably there is not only one option for º"
Usually it is -80, only with Vista, and then rarely but enough to cause errors has it been -62, maybe the format of the character.
if (ic < 0) ic = 32; takes care of it.
[Updated on: Sun, 28 March 2010 14:27] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Jun 13 06:05:36 CEST 2024
Total time taken to generate the page: 0.01550 seconds
|
|
|