# GeoProcessing, latitude and longitude in Jmonkey

Hi guys,

I’m fairly new to JMonkey and 3d programming in general. I’m trying to do some aircraft modeling, basically model their flight path.
The data I have is a bunch of latitude/longitude points which represent the flightpath of a particular aircraft.

I was messing around with a simple motionpath with a few waypoints and having a spatial plane follow the path- this seemed like exactly what I need.

When I try to scale it up and convert the latitude and longitude to an xyz vector to create the waypoints, things don’t seem to work. Do I need a GIS service like GeoTools to properly represent the flight paths?

I tried to convert the lat/long using the formulas here: http://swardsonstudios.com/?p=65

Any advice or help would be greatly appreciated

Thanks

@sabredog said: ...things don't seem to work.

Can you be more specific? That could mean any of a thousand things… at least 900 of which are entirely surmountable problems.

Fair point, sorry.

I suspect my latitude/longitude conversion isn’t right which is giving me a weird graphical representation.

Looks like the waypoints are all crammed very close together. I don’t have an error message or exception to post.

You are trying to convert latitude and longitude to points on a sphere?

What math are you using? Maybe there is an error.

Yes, that’s what I’m trying to do, convert the latitude and longitude to a 3fvector.

[java]
double x1, y, z;

x1 = radius * Math.cos(lt) * Math.cos(lng);
z = alt * Math.cos(lt) * Math.sin(lng);
[/java]

I see at least one problem with the math right away… the first being that altitude should be affecting the radius… since your distance from the center of the earth is radius + altitude. Of course, your earth is only 50 units wide so that could also be an issue.

Thanks for your help, I fixed that error and increased the world size, I’m now getting a more reasonable visualisation.

I would like to use an arial image or a map as the ‘terrain’ or floor of the application via Bing or Open street maps, I don’t mind if it is 2D. Is there someway I can accurately map these waypoints like this in JMonkey?

Thanks again

Hmmm… either I don’t understand the question or you don’t.

The images from mapping software will be in a certain projection already and you will have to duplicate that… or reverse it (potentially) to map it onto a big sphere.

It’s all doable. JME has no built in geospatial reprojection but it will happily take and render whatever points you give it.

You’re right, I was a bit unsure about what I need to do. After a bit more looking around I think I’ve found something more suitable. I can obtain map tile images from a web service and I’d like to use these to visualise a map in JMonkey. Not in 3d just as the application ‘floor’ across the x and z axis. I had a look at this tutorial

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:tools:charts

but it’s not quite what I want to do. I had a read through the beginner terrain tutorial.
Is terrainQuad the right data structure for this? Or is there another way I’m missing?

Thanks

TerrainQuad is 2.5d, so you cannot use it for a sphere representation of the world.
If you are fine with essentially a 2.5d view of the world, then you can use TerrainQuad. Ideally you would want many of them tiled together, where each quad is textured with the map image for that area. What coordinates the terrain quad is at is up to you, just offset it.
You can look at TerrainTestTile to see how to tile together many TerrainQuads and get LOD for large worlds.

@Sploreg said: TerrainQuad is 2.5d, so you cannot use it for a sphere representation of the world. If you are fine with essentially a 2.5d view of the world, then you can use TerrainQuad. Ideally you would want many of them tiled together, where each quad is textured with the map image for that area. What coordinates the terrain quad is at is up to you, just offset it. You can look at TerrainTestTile to see how to tile together many TerrainQuads and get LOD for large worlds.

I’m trying to find an article on a texturing technique I saw for this where you could take a cube texture (like you’d use for a skybox) and that’d be the height map on the sides of the cube that you “bulge” into a sphere. There’s some distortion from what I was reading but there is some way to normalize that out. Dang I really wish I had saved the article on this.

Any ways the point is that if you make a sphere-cube or quadsphere you could apply a heighmap and then bulge it by a radius perhaps? Maybe I’m just rambling.

Just to add to the above I did find this which may better explain what I just said there.

http://paoc2001.mit.edu/cmi/development/hydrodynamics/cubedsphere.htm

The video in there illustrates the idea a bit better. Instead of just a flat texture you could use a bump map though I’d think (more complicated than that naturally but whatever).

Thanks for the replies, I’ve been looking into the Jmonkey Navigation cass which provides support for converting lat/long coords into either a point or a vector.

I