Page 1 of 4 1234 LastLast
Results 1 to 10 of 31

Thread: UTM Coordinate System projection

  1. #1
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    UTM Coordinate System projection

    hello there..

    I am developing application using wxWidgets and OpenGL using C++.. I want the functionality where in, when a mouse is moved on GLCanvas, on the status bar of the application, x and y coordinates has to be displayed..

    I am able to do this, by writing a code for mouse move event of GLCanvas.. Now, according to geography, there are various Coordinate Systems (CS).. e.g. UTM CS, Geographic CS etc.

    Again for this CS, there are various ellipsoid.. The most commonly used ellipsoid is WGS84.. Now, i have an interface where in user can set the coordinate system either to Local, Geagraphic or UTM... And the ellipsoid is WGS84..

    And also i have an interface, to convert Geographic CS to UTM CS.. Now, once the conversion is done, the projection changes.. I wanted to know how this change in projection can be acheived using OPENGL...

    I found out one library on the internet called, PROJ.4... It can be integrated with C++, and i have used this library for conversion of CS.. But i'm failing to project the objects accordingly..

    I dont know whether proj.4 can be integrated with OpenGL or not.. Any one kindly help me to get this problem solved...

    Thanks in advance..

    With Regards
    Rakesh Patil

  2. #2
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: UTM Coordinate System projection

    Quote Originally Posted by rakesh_thp
    I dont know whether proj.4 can be integrated with OpenGL or not..
    What type of integration are you intended? If you want to define coordinates in one system and GL to display them in another, using Proj.4 - FORGET IT!

    I suggest you to transform your data into the coordinate system in which they will be displayed, and then send them to GL for displaying.

    There is another very interesting topic... To port Proj.4 lib to CUDA or OpenCL. Such library will be brilliant solution for massive coordinates transformations.

  3. #3
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Re: UTM Coordinate System projection

    hey..

    Thanks for your quick reply... Actually, i am transforming the coordinates using proj.4 library... Now i'm facing difficulty in displaying the objects in OpenGL.. Coz, For UTM CS, the display type is somewhat a 2D in comparison with GIS CS, where it is somewhat spherical shape.. So in case of GIS, angle, radius everything will come into picture.. That's why, projection changes from on CS to another..

    Conversion of values i'm able to do without any problem.. But only displaying is a problem for me.. any comments or suggestions on this...???

    Thanks in advance..

  4. #4
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: UTM Coordinate System projection

    Quote Originally Posted by rakesh_thp
    Now i'm facing difficulty in displaying the objects in OpenGL.. Coz, For UTM CS, the display type is somewhat a 2D in comparison with GIS CS, where it is somewhat spherical shape.. So in case of GIS, angle, radius everything will come into picture.. That's why, projection changes from on CS to another..
    I still don't understand what is the problem? Yes, WGS84 is a spheroid, and UTM is as it name implies a Transverse Mercator projection. Displaying object on the WGS84 ellipsoid requires ground to be curved. Terrain can be displayed only in 3D. UTM is a 2D projection. If you want to draw objects in UTM, draw it on the flat surface. If you want to display Earth as in Google Earth, for example, you have to deal with WGS84 (don't convert to UTM), and unproject all data you have to WGS84 (if they are in UTM).

    The only thing you should take care of is a finite precision of the Z-buffer. This is the problem with both WGS and UTM systems. In the WGS84 you have to be at least few kilometer away from the Earth surface to avoid Z-fighting.

    Maybe I'll be able to focus the whole story if you tell me what exactly you want to achieve.

  5. #5
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Re: UTM Coordinate System projection

    Thanks for the concern..

    See i got one user interface where user will set the coordinate system. This user interface includes, the following input to be given...

    1. Horizontal system (HS)
    HS may take any one of the values from,
    a. Local
    b. Geographic
    c. UTM

    2. Ellipsoid
    As far as my knowledge is concerned, there are various ellipsoids like, Clarke96, WGS84, Airy, Everest etc.. I have kept all the available options, but presently concentrating on WGS84 ellipsoid only.

    3. Units (for horizontal system)
    Default i have kept to meters.

    4. If HS is Geographic, user has to set Latitude and Longitude
    If HS is UTM, user has to set Zone and Hemisphere (north/south).

    After setting these things, later on user must be able to convert from one coordinate system to another coordinate system..

    In my case, user can initially set CS to geographic HS, with WGS84 ellipsoid, latitude towards north direction and long towards east direction, and later on convert the CS to UTM HS, with ellipsoid remaining same. Zone I set to 44, and hemisphere (northern). (Or vice-a-versa)

    Now suppose there is a rectangle on OpenGL canvas.. And i converted CS from UTM to Geographic. That time the orientation of box will change.

    i hope till this it is clear from my side and what i wrote is correct according to the theory.. Please correct me if i'm wrong theoretically...

    Now let me tell you how i do the conversion. On mouse move event of Canvas class, i have written a code that will display x, y pixel values of the canvas on the status bar..

    My center (origin) is at the bottom left corner. I keep this projection same, and only convert the xy values to lat/long and display it on the status bar. I dont really change the
    glOrtho projection.. I dont know whether its the correct way..
    Similarly if i want to convert from lat/long to UTM, i just convert lat/long to UTM and display it on the status bar.. whereas my glOrtho projection remains same..

    Now here i dont know how to handle, coz simply converting values and displaying wont work.. Orientation and projection should also change i feel...

    Where am i wrong and what do i need to do more..??

    Thanks in advance..

  6. #6
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: UTM Coordinate System projection

    I think I get the point. It is OK to leave to the user to decide in which coordinate system he/she wants to see coordinates on mouse move, but the displaying should/need not be in the same system. You can also let users choose, or hardcode to some coordinate system (UTM44 for example, if application is for your region only, or more general in WGS). All spatial coordinates of the vertices should be in that system (e.g. WGS).

    glOrtho gives an orthographic projection, which means it is not suitable in most cases (because the lack of perspective), except you are building a CAD application (don't mix meaning of glOrtho with geographical projection). If it is a CAD, distances generally are not such that geographic projections can make dramatical change. In that case confine your work only on coordinates conversion for displaying in the status bar.

    More general case is to convert coordinates of your objects to displaying coordinate system, and draw all polygons. When mouse is over each pixel of the window, do the unprojection in OpenGL. (The function gluUnProject can do the stuff, but it uses deprecated functions, so if you intend to use GL 3.x core functionality it won't be available)

    After the unprojection you will know where in 3D space the mouse is pointing to (that is in displaying coordinate system, e.g. WGS). Then convert those coordinates using Proj.4 lib to chosen coordinate system and display them in status bar.

    Try to distinguish coordinates in which your scene is rendered and coordinates that are displayed in the status bar.

  7. #7
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Re: UTM Coordinate System projection

    at present what i am doing is that, when user draws a line, of a point, each object is having a property called m_projection_type.. The current ellipsoid value( either Geographic or UTM) is stored in this member (m_projection_type).

    when storing x,y data in the object, i check for the current ellipsoid.. If it is Geographic, i convert x,y data to Lat/lon data and store it.. Else if ellipsoid is UTM, i convert x,y data into Northing and Easting (UTM coordinates) and save it in object..

    And later on when it comes to display the objects, I check the value of m_projection_type.. If value is UTM, i convert UTM to xy pixel values, and if it is Geographic, i convert Lat/lon to xy pixel values.. Is this the correct way, what i am doing..??

    I am sorry but I didnt get the solution what you explained.. It will be grateful of you if you kindly provide me with a small example of a point.. i.e. creating, and displaying a point, and displaying it after conversion.. If possible, no compulsion..

    Anyways, thanks a lot..

  8. #8
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: UTM Coordinate System projection

    Quote Originally Posted by rakesh_thp
    at present what i am doing is that, when user draws a line, of a point, each object is having a property called m_projection_type.. The current ellipsoid value( either Geographic or UTM) is stored in this member (m_projection_type).
    That's OK! (Only a minor syntactic correction: UTM is not an ellipsoid. )

    Quote Originally Posted by rakesh_thp
    when storing x,y data in the object, i check for the current ellipsoid.. If it is Geographic, i convert x,y data to Lat/lon data and store it.. Else if ellipsoid is UTM, i convert x,y data into Northing and Easting (UTM coordinates) and save it in object..
    OK! The screen coordinates to m_projection_type system conversion.

    Quote Originally Posted by rakesh_thp
    And later on when it comes to display the objects, I check the value of m_projection_type.. If value is UTM, i convert UTM to xy pixel values, and if it is Geographic, i convert Lat/lon to xy pixel values.. Is this the correct way, what i am doing..??
    Inverse transformation. It is also OK, but you can also store, as you called "XY", coordinates together with "projection" coordinates, to avoid frequent conversions.

    Quote Originally Posted by rakesh_thp
    I am sorry but I didnt get the solution what you explained..
    Can you be precise which part you didn't understand? It is hard (and time consuming) to write a complete GIS tutorial.

    This is a short example (pseudo-code) how to retrieve "world" coordinates of the pixel you have clicked on:
    Code :
    MouseClick()
    {
     [screen_X screen_Y] <- GetMousePosition()
     screen_Z <- ReadPixelDepth(screen_X, screen_Y)
     [scene_X scene_Y scene_Z] <- UnProject(screen_X, screen_Y, screen_Z, ModelViewMatrix, ProjMatrix, Viewport)
     [world_X world_Y world_Z] <- SceneToWorld(scene_X, scene_Y, scene_Z)
     
    }

  9. #9
    Member Contributor
    Join Date
    Jun 2009
    Posts
    60

    Re: UTM Coordinate System projection

    Well, i guess that part i have done.. Tell me one thing.. Currently my setting is as follows..

    Horizontal system is Geographic (which uses lat/lon values).
    Ellipsoid is WGS84.
    Units is meters.

    Now suppose i convert this system into

    Horizontal system: UTM
    Ellipsoid WGS84
    Units: meters
    Zone = 44

    I'll get a pair of values after conversion.. Now if i try to convert the original lat/lon values to OpenGL xy coordinates, and also if i convert UTM coordinates to OpenGL xy coordinates, then will i get same OpenGL xy values of there will be any variation in them..??

    I feel, anyhow both conversion must point to same OpenGL XY coordinates.. Coz, i came across a software, where the projection changes a little bit when changed from one CS to another...

    Thanks.

  10. #10
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,214

    Re: UTM Coordinate System projection

    Quote Originally Posted by rakesh_thp
    Horizontal system is Geographic (which uses lat/lon values).
    Ellipsoid is WGS84.
    Units is meters.
    Units cannot be meters if system is Geographic. They can be: degrees, minutes, seconds, radians, or something like that.

    Quote Originally Posted by rakesh_thp
    I'll get a pair of values after conversion.. Now if i try to convert the original lat/lon values to OpenGL xy coordinates, and also if i convert UTM coordinates to OpenGL xy coordinates, then will i get same OpenGL xy values of there will be any variation in them..??
    Depends on the precision, but should be approximately the same.

    Quote Originally Posted by rakesh_thp
    I feel, anyhow both conversion must point to same OpenGL XY coordinates.. Coz, i came across a software, where the projection changes a little bit when changed from one CS to another...
    The finite precision of the arithmetic operations is the cause of that. Whenever you need a calculation use double precision. That is the reason you cannot calculate geographic projections in shaders (if you plan to use them). Order of operations and trigonometric functions calculations are also important, but you will probably use Proj.4, so leave the calculation to the library.

Page 1 of 4 1234 LastLast

Similar Threads

  1. what about coordinate system?
    By beloni in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-16-2007, 12:21 PM
  2. 3D coordinate system
    By woodstock in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-11-2005, 04:16 AM
  3. Projection of 3D Object to a 2D Plain in a XYZ coordinate system
    By steveee in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-26-2004, 11:15 AM
  4. GDI Coordinate system
    By DVazanias in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-05-2002, 06:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean