I'm getting coordinates from GPS tracker as "Lat:40 54.1434" "Lon:29 13.0226", i would like to convert this coordinates for google maps javascript api as "lat : 40.90239, lon : 29.21704". I've searched on google and found formulas+convert tool websites, i tried to understand how they converted using JavaScript but i didn't understand. Is it possible to convert using Delphi XE7 ?
Thanks for advance.
Your GPS tracker is giving you coordinates in degrees + decimal minutes.
These are quite easy to convert to plain decimal degrees, as your Google Maps API requires, by taking the first part of the coordinate and adding on the second part divided by 60.
For example, to convert 40 54.1434 to plain decimal degrees, you split up the string into degrees = 40 and minutes = 54.1434, and then decimalDegrees = degrees + minutes / 60, which is 40 + 54.1434 / 60 = 40.90239.
Related
Does anyone know how I could generate a random number in a range in iOS? I am currently working on a synthesizer in iOS (using SpriteKit and AudioKit) and I am trying to modify the loudness of the synth with changing its variability whenever a slider is being moved as well.
This is what my code looks like:
[Synth setAmplitude: 0.5 + (slider.currentValue * loudnessVar)];
where 0.5 is the default amplitude value and loudnessVar is a random number.
Since, the slider returns values from -170 to 170 , I would need a relatively low number in order to set a value between 0 and 1.
Is anyone able to help with this?
The way to generate a random number in a range is:
NSInteger random = min + arc4random() % (max - min);
So, you can generate a number between 1-20 and divide it by 1000, it's just an example.
I.
I am trying to parse a stanag 4609 klv stream from external camera.
For beginning, I am trying to figure the altitude value received in stream.
By stanag 4609 documentation, the value is 2 - bytes long, in feet, represented as float.
I know that the camera altitude is approximately 39.8 meters, but I can't interpret the 2 - bytes I receive to that value (in feet).
The 2 bytes I received are {12,23}.
How can I interpret it in the correct way?
In STANAG 4609 KLV, floating point values are encoded as integers. You can check MISB ST0601 for the particular data element you're interested in. It will give you the conversion formula to convert the 2-byte integer into the correct floating point value.
Assuming you're referring to the Sensor True Altitude (tag 15), the conversion formula is (19900/65535) * int_value - 900.
Applying this to your data:
Interpret the bytes [12, 23] ([0x0C, 0x17] in hexadecimal) as an integer. 0xC17 is equal to 3095.
Apply the formula. (19900/65535) * 3095 - 900 = 39.81 meters
I'm working on rasterisation of the GSHHS database basically converting shoreline polygons and river lines to raster.
http://www.soest.hawaii.edu/pwessel/gshhg/
The rivers and shores databases are two different files.
I noticed misalignment of hundreds of meters between rivers and shores at points where they are clearly should be aligned. One thing I noticed in the README is that the shorelines database uses WGS84 coordinates and river database was generated form other source using WGS 72. The difference should be in shift of prime meridian and difference in primary axis dimensions of the Earth.
I've searched over the internet about conversion between the two sets and couldn't found.
Answers I need:
How can I convert between them?
Or alternatively
How do I solve misalignment in GSHHS database?
Here are the formulas and parameters to transform WGS 72 coordinates to WGS 84 coordinates
FORMULAS
Δφ" = (4.5 cos φ) / (a sin 1") + (Δf sin 2φ) / (sin 1") (Unit = Arc Seconds)
Δλ" = 0.554 (Unit = Arc Seconds)
Δh = 4.5 sin φ + a Δf sin2 φ - Δa + Δr (Unit = Meters)
Δφ = Δφ" x 1" (Unit = radians)
Δλ = Δλ" x 1" (Unit = radians)
PARAMETERS
Δf = 0.3121057 x 10-7
a = 6378135 m
Δa = 2.0 m
Δr = 1.4 m
1" = pi / (3600.0 * 180.0) rad
To obtain WGS 84 coordinates, add the Δφ, Δλ, Δh changes calculated using WGS 72 coordinates to the WGS 72 coordinates (φ, λ, h, respectively). Latitude is positive north and longitude is positive east (0° to 180°).
RESULT
φ WGS84 = φ + Δφ
λ WGS84 = λ + Δλ
h WGS84 = h + Δh
Documentation [p105-106]
You can use proj4:https://trac.osgeo.org/proj/wiki/man_proj. There are many ellipsoid identifiers supported. You can get a list with the -le option switch. To convert from wgs74 you can use the "towgs84" option switch.
One authoritative source is the National Geospatial Intelligence Agency (NGA). They publish open source, the Geotrans program at http://earth-info.nga.mil/GandG/geotrans/. This gives GUI, batch processing. I expect internally there is an API you could call as a developer.
So I have an array of 500,000 elements:
float* arrayToBucketize=(float*) malloc(sizeof(float)*500000);
and an array that represents the buckets:
int buckets[5]={0,25,50,75,100};
What is the fastest way to go through the first array, look at each float value, compare it to the "buckets" array and replace that float value with the nearest bucket value. So if the float value was 11.25, it would be replaced with 0. On the other hand, 90.10 would be replaced with 100.
Also, I would need any values outside of that range (<0 and >100) to remain unchanged.
I know I can do this with for loops and if conditions; but in the bad habit of optimizing, I am trying to find a more efficient (faster) way of doing this. I am hoping that there is a C function(s) or an iOS function in the Accelerate framework that can do this. Or possibly a series of Accelerate framework matrix functions.
Thanks
For each value inside the bucket range, divide by the lowest common multiple of your bucket values. Round the results to the nearest integer, and then multiply again by the lowest common multiple.
Using the example numbers:
11.25 / 25 = 0.45
0.45 -> 0
0 * 25 = 0
90.10 / 25 = 3.604
3.604 -> 4
4 * 25 = 100
The accelerate framework has vectorized divide, round, and multiply functions, so these should run fairly quickly.
I have a series of Lat/Long coords. I need to transform it in X, Y coordinates. I've read about UTM, but the problem is that UTM coordinates are relatives to a single zone.
For example, this two coordinates UTM has the same Easting (x) and Northing (y) but different code zone, and so each coords point to a completly different location (one in spain and one in italy):
UTM: 33T 292625m E 4641696m N
UTM: 30U 292625m E 4641696m N
I need a method to automatically transform that relatives coord in absolute X, Y coordinates. Ideas?
Does it have to be UTM? If not, you can also use Mercator, which is a simpler projection that doesn't rely on zones.
See, for example, the Bing Maps system.
You should be able to use the ProjNET library.
What you need is to find the WKT (well known text) that defines your projections, and then you should be able to convert between them.
var utm33NCoordinateSystem = CoordinateSystemWktReader.Parse("WKT for correct utm zone") as IProjectedCoordinateSystem;
var wgs84CoordiateSystem = CoordinateSystemWktReader.Parse(MappingTransforms.WGS84) as IGeographicCoordinateSystem;
var ctfac = new CoordinateTransformationFactory();
_etrsToWgsTransformation = ctfac.CreateFromCoordinateSystems(etrs89CoordinateSystem,wgs84CoordiateSystem);
double[] transform = _etrsToWgsTransformation.MathTransform.Transform(new double[] { y,x });
Note: you have to find the correct WKTs, but that can be found on the project site.
Also you may have to flip the order of the inputs, depending on the transforms.
if we want to correct bearing & Distance in between two points than we use (Polar) method by using Scientific Calculator first of all Press The Button polar than started bracket first
For the Distance POL(N-N,E-E)
For the Bearing POL(N-N,E-E)RclTan-1
Now you have got a Correct bearing