转换GPS坐标X,Y,Z坐标 [英] Converting GPS coordinates to X, Y, Z coordinates

查看:1107
本文介绍了转换GPS坐标X,Y,Z坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,这里的基本问题。我目前的工作GPS系统在C#在Unity 3D(即给我们的任务是让我们使用这个程序的人,所以我不能做别的事)。

So here is the basic problem. 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).

现在我在一个小问题上运行,基本上我们能够要求(我们认为是十进制)从Android手机的坐标,但现在我们正试图这些坐标转换为X,Y, Z轴坐标。 Preferebly X和Z,因为我们实际上并不需要的高度。但是,我们一直在寻找互联网迄今已为转换为球体地图上的一切在这里,我们只是有一个基本平的数字地图。

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. Preferebly X and Z, because we do not actually need height. 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.

如果有谁知道如何以我们的基本的X和Z坐标(所以我们的经度和纬度)这将会是惊人的坐标转换。

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.

要迅速记下我不知道,如果诸如此类的坐标,我们必须按实际小数坐标,所以这是他们的样子:

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:

纬度:53.228888经度:6.5403559

Latitude: 53.228888 Longitude: 6.5403559

这些坐标应该在Wegalaan 3,荷兰格罗宁根结束了,如果你想看看他们在地图上。

these coordinates should end up on "Wegalaan 3, Groningen, The Netherlands" if you would look them up on a map.

谢谢了!

编辑:(这也是在评论)

(this is also in the comments)

很抱歉,如果它可能会造成混乱。老实说,我只有一半的了解这一切工作,反正要明确一些事情。我目前统一正与一个简单的2D地图,我从我住在(荷兰格罗宁根)城市的互联网了,我想基本上采取GPS坐标,我从我的Android手机获得,然后让他们知道地图上具有红点,但要做到这一点,我需要能够红点移动到地图上的正确坐标。我所试图做的是转换GPS COORDS(LON和LAT),以X和Z(Unity3D平坐标,也可能只是X和Y),因此,如果我对准地图好吧,我得到一个小的GPS系统只是我市。如果你是好奇,为什么我做的这一点很简单,因为我的一个朋友和我正在尝试使用我们的城市,这个GPS系统为基础

Sorry if it might be confusing. Honestly I only half understand how all this works, anyways to clear some things up. 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. What I am trying to do is convert the GPS coords (lon and lat) to X and Z (Unity3D 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. 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

EDIT2:

但我会说实话,我不知道如何直角坐标系工作,但他们似乎是我所期待的是:P的坐标。一个平面,并与X,Y COORDS我的意思是基本上只是负责协调,我可以在Unity3D使用在一个平面的2D平面这是我在我的工作。

except 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 Unity3D on a flat 2D plane which is what I am working in.

EDIT3:

感谢您的答案,重新开始。这不是重复的,其次是我的朋友,我已经找到你送我的计算器话题,但它似乎没有为我们工作(也许我们做错了什么)。基本上我们与测试公式不同地方之间的南北距离很成功,但是它们之间的东,西距离为方式大于它应该是。我们认为这可能是因为该公式意味着一个球形的地球,但也许我们做错了什么。 !如果有人可以进一步解释那简直是惊人的。

Thanks for the answers, to start. 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). 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. We think it might be because that formula was meant for a spherical earth, but maybe we did something wrong. If someone could explain further that'd be amazing!

EDIT4:

我们相信它不能是我们的地图是错误的以任何方式,因为我们已经与多个位置对准它。我们得到了这些地点的坐标,然后使用这个网站: HTTP://www.gpscoordinaten。 NL / converteer-RD-coordinaten.php 以XY坐标,然后利用这些XY坐标来检查我们的地图会适当调整,将其转换。它做到了,所以我们肯定有一些问题,我们正在使用,而不是与我们的实际地图数学

We are sure it can't be our map that is wrong in any way, because we have aligned it with multiple locations. We got the coordinates for these locations and then used this website: http://www.gpscoordinaten.nl/converteer-rd-coordinaten.php to convert it to XY coordinates and then used these XY coordinates to check if our map would align properly. It did, so we are sure there is some problem with the maths we are using and not with our actual map.

EDIT5:拆了很多,很多语法错误。这是在这里正确,现在被写太热,所以我非常非常抱歉,如果任何这是没有意义的。 。只是让我知道,我会编辑试图解释什么,我们正在尝试做的。

Removed many, many grammatical errors. It's way too hot over here to be writing properly right now, so I am very very sorry if any of this makes no sense. just let me know and I'll edit to try and explain what we are trying to do.

EDIT6:找到我自己asnwer,它已关闭所有其他的答案如果你想看到我做了什么来解决我的问题。

Found my own asnwer, it is down in between all the other answers if you wanna see what I did to fix my problem

推荐答案

到现在为止我已经找到了答案,以我自己的问题(实际上发现前一阵了,但完全忘了张贴在这里)

By now I have found the answer to my own question (actually found it a little while ago already, but totally forgot to post it here)

基本上,我做了我自己的一个小公式,乘以集数坐标(视上阉与否它是x或y轴)是二组之间的差异的坐标点。这两点是我的地图的外点。

Basically I made a little formula of my own that multiplied the coordinates with a set number (depending on wether or not it is the x or y axis) that is the difference between two set coordinate points. These two points are the outer points of my map.

基本上是这样我可以得到相当准确的测量结果我还没甚至有一米的区别我的实际位置尚未

Basically by doing this I can get quite accurate measurements I haven't even had a meter difference to my actual position yet.

我知道这听起来有点含糊,我不完全知道如何解释它,但是对于任何有兴趣在这里是我使用的代码:

I know this sounds a bit vague and I don't entirely know how to explain it, but for anyone interested here is the code I use:

void RetrieveGPSData()
{
    currentGPSPosition = Input.location.lastData;
    System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
    dateTime = dateTime.AddSeconds(currentGPSPosition.timestamp);

    float z = latToZ (Input.location.lastData.latitude);
    float x = lonToX (Input.location.lastData.longitude);

    this.transform.position = new Vector3 (x, 0f, z);

    gpsString = ("Last Location: " + Input.location.lastData.latitude.ToString () + " " + Input.location.lastData.longitude.ToString () + " " + Input.location.lastData.altitude.ToString () + " " + Input.location.lastData.horizontalAccuracy.ToString () + " " + dateTime.ToShortDateString() +" "+ dateTime.ToShortTimeString());
}

float latToZ (double lat){

    lat = (lat - 53.178469) / 0.00001 * 0.12179047095976932582726898256213;
    double z = lat;

    return (float)z;
}

float lonToX (double lon){

    lon = (lon - 6.503091) / 0.000001 * 0.00728553580298947812081345114627;
    double x = lon;

    return (float)x;
}



任何人想知道为什么我把53.something和6.something现在关闭LON和LAT那是因为我的0 X和团结0 Z点对应于我的地图,这是两点我谈过,我使用的这个计算的一个左下角的坐标。

Now for anyone wondering why I took the 53.something and the 6.something off the lon and lat it is because the coordinate of my 0 X and 0 Z point in Unity which corresponds to the bottom left corner of my map, which is one of the two points I talked about that I use for this calculation.

我希望这可以帮助别人谁可能永远停留在类似的东西,如果你有任何问题随时问他们。

I hope this helps anyone else who might ever be stuck on something similar and if you have any questions feel free to ask them.

-LAKster

这篇关于转换GPS坐标X,Y,Z坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆