Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SYJeon87 · Aug 17, 2017 at 02:53 AM · convertcoordinatesgps

how to convert gps coordinates to unity

hello. first, my english skill is not good. sorry.. anyway i want to convert lat/lon to unity x,y coordinates. i already read some another questions but not solved..

i made c# script to get the gps data and it works well. i also made a object in the unity world, and made another c# script to control camera rotation with gyro. and!! last!! i just want to move my unity camera according to gps lat/lon data. so i convert my lat/lon data. like this page https://stackoverflow.com/questions/32311647/converting-gps-coordinates-to-x-y-z-coordinates but, my camera is not moved as i wanted. problem is this. lat, lon is correct, but converted data(x/z) is incorrect.

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;

} i think in this function, the equation is little wrong.. please someone make me know how can i convert that.

thanks and have a good day

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by NorthStar79 · Aug 17, 2017 at 06:10 AM

if I understand StackOverflow answer correct, that means these " 6.503091 & 53.178469" has nothing to do with you, and you should calculate this numbers for yourself.

I suggest,

1- pin point your position on a "real map", and mark that position in "unity map",

2- make public variables for these numbers ( 6.503091 & 53.178469) and make a UI slider for changing them

3- Build and install, hit play, try to adjust your camera view with those UI sliders you made for 'these numbers'

4- once you satisfy for your position, note that sliders value.

5- Go back to unity and enter numbers that you note into the equations.

and don't forget to notify us about results.

I hope this will help you.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SYJeon87 · Aug 17, 2017 at 06:47 AM 0
Share

Thanks for your answer. right 6.503091 & 53.178469 these number is nothing to me, so i initialize that numbers to my gps coordinates. and also i need gps coordinates regularly, gps receive data in Update() function. i am wondering how he(in stackoverflows person) get or calculate this number 0.00728553580298947812081345114627.

i saw 1 meter is 1 unity unit from a website. so, i am trying below: 1. convert longitude and latitude to meter(1 latitude is 110979.309 meter like this) 2. move camera to new position

function is here first, check the gps data correct

public bool isGPSDataCorrect() { if (($$anonymous$$athf.Abs(lat - oldLat) > 0.001) | ($$anonymous$$athf.Abs(lon - oldLon) > 0.001) ) { return false; } else { //double x = (lon - oldLon) / 0.000001 0.00728553580298947812081345114627 40; //double z = (lat - oldLat) / 0.00001 0.12179047095976932582726898256213 40; double x = (lon - oldLon) 88907.949; double z = (lat - oldLat) 110979.309; moveX = (float)x; moveZ = (float)z; return true; } }

and then, move camera to new position private void Update () {

     camPos.text = "x: " + cameraContainer.transform.position.x.ToString() +
                 "\ny: " + cameraContainer.transform.position.y.ToString() +
                 "\nz: " + cameraContainer.transform.position.z.ToString();

     if (gyroSupported && startY == 0)
     {
         ResetGyroRotation();
     }
     transform.localRotation = gyro.attitude * rotFix;

     if (PipeLine.Instance.isGPSDataCorrect())
     {
         cameraContainer.transform.position += new Vector3(PipeLine.Instance.moveX, 0f, -PipeLine.Instance.moveZ);            
     }
 }

i just show you a part of my sources cause more complex. now, i am trying and i hope like these questions and answers will be helpful unity and me.. me.......meeee.... Thank you!!

avatar image SYJeon87 · Aug 17, 2017 at 07:20 AM 0
Share

i tried but failed 1. camera is moved but just little. i can see my camera position but it moved just little. 2. so i modify to * 10, but it also not good. it is like turn around lat and long.

avatar image
0

Answer by maxima06 · Nov 14, 2019 at 10:18 PM

I need help with that. If you have solved the problem, can you write the solution here?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

69 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to get GPS coordinates in unity 3d 3 Answers

Lat Long to Unity world coordinates 1 Answer

Converting Mesh to Set of Discrete Coordinates 1 Answer

GPS coordinates (lat/long/altitude) to Unity 3D coordinates (x, y, z) 1 Answer

Are there examples of GPS-based indoor item placement apps? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges