I am working on indexing for multidimensional objects (location based services: long/lat/time for eg.) and experimenting with hilbert curve. The problem is, the java code i have works good upto 64 bits. For example:
value ( long, lat, time ) = H(bits)
if the number of bits > 64 , the algo fails.
So i just need to know what is the feasible range of long and lat values should i consider for real world applications?? Is it : -180 to 180 for longitude and 90 to -90 for latitude??
Thanks
Yeah, it is typical to define longitude to be between -180 and 180 and latitude between -90 and 90 as you said. I have seen the range 0 to 360 for longitude, but no where near as often.
What's important is that you define latitude across a range of 360 degrees and latitude across a range of 180, since that lets you find any point on the earth.
Although I am completely ignorant of hilbert curves and don't know what's involved in your task, I would recommend making sure that you understand that the values of latitude and longitude typically used are geodetic. Latitude is thus the angle that a line normal to the surface of the earth makes against the equatorial plane. This line will not go through the center of the earth unless you are on the equator.
Related
I have a 4096*4096 image of the Sun.I want to track its latitude and longitude using MATLAB. I have tried the below code. Though it works fine on the axes(latitude=0/90 longitude=0/90), it fails at the edges(for example latitude=30 longitude=90)
x=round((b*s*cos((l*pi)/180))+xC)
y=round((-l*s)+yC)
where x=horizontal displacement
y=vertical displacement
l=latitude
b=longitude
(xC,yC)=center coordinates of the Sun
s=scaling factor.
Thanks in advance
AU
I am plotting all the longitude points for a given latitude. figure 1 is for latitude=0 while figure 2 and 3 are for latitude=45 and -45 respectively.As I increase the latitude the lines become more skew(see figure 4 for latitude = 70).
Please refer the below link for the images: https://drive.google.com/drive/folders/0B2X4xzsGcarCbGM5aVM1UXBRX2M?usp=sharing
I also tried plotting the latitudes for a constant longitude and a similar trend(skewness with increasing longitude) was found.
I'm trying to parse latitude and longitude from a json object with precision, and I picked float64 for the job. However float64 is somehow rounding the number and I'm not sure what to do in order to avoid rounding.
I've created a quick snippet so you can execute the problem:
http://play.golang.org/p/9g6Imn-7GK
package main
import (
"encoding/json"
"fmt"
"reflect"
)
type Position struct {
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
}
func main() {
s := `{"lat":13.519004709972312,"lon": -13.519004709972312}`
pos := Position{}
json.Unmarshal([]byte(s), &pos)
if !reflect.DeepEqual(s, &pos) {
fmt.Printf("\nExpected %#v\nbut got %#v", s, pos)
}
}
A practical solution:
Do nothing.
The difference in the numbers is about a tenth of the width of a single small atom, and your measurements can't possibly be that precise.
The eighth decimal place (you have 15 in your numbers) represents a distance of about 1.1mm. I doubt if your measurements are accurate to this degree, and anything more is getting really silly. The 5th decimal place is about 1.1m, which is in the realm of sanity, and not affected by floating point errors.
The wikipedia page on Decimal Degrees may be helpful in determining which values are reasonable for your project.
Some considerations:
There are two potential issues at play:
Floating point:
Some reading that might shed light on floating point issues:
What Every Programmer Should Know About Floating-Point Arithmetic or Why don’t my numbers add up?
What Every Computer Scientist Should Know About Floating-Point Arithmetic
If you read these, and understand how floating point works in
practice, you may be enlightened, and understand what's happening
and how to work around it.
Precision of measurement:
This, in my opinion, is the bigger issue. One number you posted was 13.519004709972312, which was displayed as 13.519004709972313. Whether the value has "changed" or not (see: 1), every software calculator I tried to calculate the difference between these values returned 0, which is indicative.
Doing the calculation by hand revealed a difference of 0.000000000000001 in the values. That is, a 14 zeroes before the trailing one, or 1^-15.
The wikipedia page on Latitude says:
the meridian length of 1 degree of latitude on the sphere is 111.2 km.
Working backward from this, the difference in locations represented by the 15th decimal place in a latitude corresponds to a distance of approximately 0.00000011mm, or 0.11nanometers.
From the The Physics Factbook's Diameter of an Atom page:
An atom is a million times smaller than the thickest human hair. The diameter of an atom ranges from about 0.1 to 0.5 nanometers
Therefore, your measurement would be "off" by at most 1/10 of the diameter of a single atom.
Even if all my calculations were off by a million or billion times, the distances would still be so small that they would not matter in practice!
I am trying to implement a simple kalman filter that will be used for filtering/predicting the movement of a vehicle in long/loat coordinates.
There are no measurements from vehicle sensors, just a new update on an observed long/lat position, so basically the state that I will be trying to predict and correct is the longitude and latitude of the vehicle at any given time.
As far as I understand the model is non linear as there may be random accelerations change of direction etc, but I think this can be largely ignored as long as I keep track of the bearing as well in my state. My problem is that I do not know how to model this system in terms of the state and prediction matrices and on top of this it seems that it is necessary to convert/project the long/lat coordinates into some cartesian xy system so that the two become independent, but I am not exactly sure how to go about this.
It seems that converting back to wgs84 from xy is not that trivial and potentially a bit intense computationally. Can anyone shed some light into this?
It looks like your state variable would be a vector [lat, long], and your measurement variable would be [lat, long, bearing]. You will need to figure out appropriate f and h functions, based on these vectors, for the process and measurement models, respectively. Since this is a non-linear problem, you will probably need to use a nonlinear filter, such as the EKF, UKF or CKF (cubature Kalman filter).
When using a Kalman-type filter to deal with modular values such as angles, latitudes, or longitudes, there is a big problem whenever your state or your measurements are near the discontinuous modular boundary. For example, if your bearing is an angle from 0 to 360 degrees, the filter will have problems if you are measuring at 1 degree or 359 degrees. Also, you could have problems if your longitude is around plus or minus 180 degrees longitude, or your latitude is at one of the poles (which might be remote possibilities that you could ignore).
One example of how to deal with angles in the state or measurement variables is presented in David Frederic Crouse, "Cubature/ Unscented/ Sigma Point Kalman Filtering with Angular Measurement Models," 18th Int'l Conf. on Information Fusion (Wash., D.C. July 6-9, 2015), https://ieeexplore.ieee.org/document/7266741. Based on Crouse's approach, to use bearing as a measurement variable you would need to add a wrapping function to a couple of locations in the standard unscented or cubature filter equations. If you want to deal with the discontinuities in latitude and longitude (which you might not), you would need to transform the coordinates to and from Euclidean space while calculating the covariance matrices.
I have created a 2D camera (code below) for a top down game. Everything works fine when the players position is close to 0.0x and 0.0y.
Unfortunately as distance increases the transform seems to have problems, at around 0.0x 30e7y (yup that's 30 million y) the camera starts to shudder when the player moves (the camera gets updated with the player position at the end of each update) At really big distances, a billion + the camera wont even track the player, as I'm guessing what ever error is in the matrix is amplified by too much.
My question is: Is there either a problem in the matrix, or is this standard behavior for extreme numbers.
Camera Transform Method:
public Matrix getTransform()
{
Matrix transform;
transform = (Matrix.CreateTranslation(new Vector3(-position.X, -position.Y, 0)) *
Matrix.CreateRotationZ(rotation) * Matrix.CreateScale(new Vector3(zoom, zoom, 1.0f)) *
Matrix.CreateTranslation(new Vector3((viewport.Width / 2.0f), (viewport.Height / 2.0f), 0)));
return transform;
}
Camera Update Method:
This requests the objects position given it's ID, it returns a basic Vector2 which is then set as the cameras position.
if (camera.CameraMode == Camera2D.Mode.Track && cameraTrackObject != Guid.Empty)
{
camera.setFocus(quadTree.getObjectPosition(cameraTrackObject));
}
If any one can see an error or enlighten me as to why the matrix struggles I would be most grateful.
I have actually found the reason for this, it was something I should have thought of.
I'm using single precision floating points, which only have precision to 7 digits. That's fine for smaller numbers (up to around the 2.5 million mark I have found). Anything over this and the multiplication functions in the matrix start to gain precision errors as the floats start to truncate.
The best solution for my particular problem is to introduce some artificial scaling (I need the very large numbers as the simulation is set in space). I have limited my worlds to 5 million units squared (+/- 2.5 million units) and will come up with another way of granulating the world.
I also found a good answer about this here:
Vertices shaking with large camera position values
And a good article that discusses floating points in more detail:
What Every Computer Scientist Should Know About Floating-Point Arithmetic
Thank you for the views and comments!!
I have a dxf file of a town in meter coordinates. I need to extract polylines from the map and convert them to geographical coordinates. My idea is to add 3 or 4 points on the map with known coordinates. I will place them using google map as reference. These 3 or 4 points will be placed at intersections roads so I can not place them as they defined a rectangle (I think it would be simpler).
I can not found out what calculation I have to do to convert all the coordinates of the objects of the map.
google map earth radius: 6378137 meter.
so, If I consider 3 points, I will have 3 relations:
(x1,y1) with (lat1, lng1)
(x2,y2) with (lat2, lng2)
(x3,y3) with (lat3, lng3)
I have done one simple conversion with only 2 points but I'd like a more accurate result.
I preferably use c/c++ to do it.
example of one equivalent point:
latitude: -2.148707
longitude: -79.876270
x: 2012078.15
y: 498355.88
It's not a UTM, I verify it from here. Because I do not know if it s a normalized.
I googled a lot, I found libraries, but without knowing if tmy coordinates meet a specific format, I don't think I can use one.
Anyway, thanks to read and I hope someone could help me.
It is not as easy at that. First you need to know which reference ellipsoid you are using (e.g. WGS-84) and then which projection. I wouldn't try to implement this by hand, but use postgis instead, which would do all this ugly work for you.
The correct way is to ask the provider of the file what the coordinate system is related to. dxf is not realy a suitable format. you need a format like ESRI Shp file or mif/mid with a defined geographic coordinate system.
otherwise it is a bit unclear if the data are precise enough, to be used for geographic reference.
However it is not difficult to transform between meters and wgs84 lat longitude, especially if the area is not more than 10-20 miles.
you could use as first try the cylyndrical equidistant transformation, which is only a few lines of simple code. look also if the y-achsis in the dxf file points to the nort pole, otherwise you must find out that amount of false northing and rotate back to north.
MapInfo Professional is a tool with free evaluation period, this tool alows to specify reference points for such unknown coordinate systems. (at least for bitmaps i rememer that feature).
But if you are a professional sw developper, You should reject that file and demand a version in wgs84 lat lon.