![]() ![]() We are sure it can't be our map that is wrong in any way, because we have aligned it with multiple locations. If someone could explain further that'd be amazing! ![]() We think it might be because that formula was meant for a spherical earth, but maybe we did something wrong. Basically the north and south distance between different places we tested with that formula have worked, however the east west distance between them was way bigger than it should have been. This is not a duplicate, secondly my friend and I already found the stackoverflow topic you sent me, but it seems to not be working for us (maybe we did something wrong). If you are curious as to why I am doing this it is simply because a friend of mine and me are trying to build a game using our city and this GPS system as a basisĮxcept that I'll be honest I have no idea how cartesian coordinates work, but they seem to be what I am looking for yes :P Coordinates on a flat plane and with X,Y coords I mean basically just coordinates I could use in Unit圓D on a flat 2D plane which is what I am working in. What I am trying to do is convert the GPS coords (lon and lat) to X and Z (Unit圓D flat coordinates, may also just be X and Y) so that if I align the map right I get a small GPS system for just my city. I am currently working in Unity with a simple 2D map I got from the internet of the city I live in (Groningen, The Netherlands) and I am trying to basically take GPS coordinates I get from my android phone and then show them on that map with a red dot, however to do this I need to be able to move the red dot to the right coordinates on the map. Honestly I only half understand how all this works, anyways to clear some things up. These coordinates should end up on "Wegalaan 3, Groningen, The Netherlands" if you would look them up on a map. To quickly note I am not sure if the sort of coordinates we have are actual decimal coordinates so this is what they look like: ![]() If anyone knows how to convert the coordinates we have to the basic X and Z coordinates (so our longitude and latitude) it'd be amazing. However everything we have been finding on the internet so far has been for a conversion to a sphere map where as we just have a basic flat digital map. Preferebly X and Z, because we do not actually need height. Now I've run in to a small problem, basically we are able to request (what we think are decimal) coordinates from an android phone, but now we are trying to convert those coordinates to X, Y, Z coordinates. I am currently working on a GPS system in C# in Unity 3D (the person that has given us the assignment is making us use this program, so I can't do it in anything else). Result.y = p2 - (p * Math.Cos(a)) //Convert to Map Px ?ġ) How do I adjust the Albers projection result to the factor in the Map Size (width/height in pixels) for X/Y pixel placement?Ģ) Is my Albers Math formula to C# code conversion correct?ģ) What do the reference longitude (λ 0) and reference latitude (φ 0) refer to? I guessed these meant the US Map West Long (minLng) and US Map North Lat (maxLat).Ĥ) What do the standard parallels (φ 1 and φ 2) refer to? I guessed these meant the US Map North Lat (maxLat) and US Map South Lat (minLat).So here is the basic problem. Result.x = p * Math.Sin(a) //Convert to Map Px ? Var p2 = (n / Math.Sqrt(c - (2 * n) * Math.Sin(minLat))) / n Var p = Math.Sqrt(c - ((2 * n) * Math.Sin(lat))) Var c = Math.Pow(Math.Cos(minLat), 2) + ((2 * n) * Math.Sin(minLat)) Var n = (Math.Sin(minLat) + Math.Sin(maxLat)) *. Here's my C# code so far: int mapWidth = 1460 //US Map Width Pxĭouble maxLat = 48.291667 //US Map North Lat (Approx)ĭouble minLat = 22.46 //US Map South Lat (Approx)ĭouble maxLng = -65.529722 //US Map East Long (Approx)ĭouble minLng = -128.876944 //US Map West Long (Approx) The standard map projection of the United States is an Albers Projection as seen below, but StackOverflow only has references for Lat/Long conversions that refer to basic Mercator projections. I'm trying to use C# or Javascript to convert Lat/Longs into X/Y Coordinates to position divs with CSS (left, top) onto a background image of a US map. ![]()
0 Comments
Leave a Reply. |