2

I've done my 3D map generation in WebGL/THREE.JS project and have an issue with the building locations.

I have the data about building position ( its polygon ) from DB server, but first of all I want just to locate not the polygon data, but a simple cube. The aim is clear is as a crystal: to set a building to the correct position by putting a cube on the 3D map.

Now it does look like:

enter image description here

I have demonstrated it, because I want to admit, that to create a building and place it on the map - isn't a problem. The problem is to set building into the correct position/location on the map.

What I have done before?

Because the building record has two fields in DB:

position on map ( lat | long ) | polygon data of building ( points collection )

I thought that I must convert the geospatial coordinates of each building: latitude, longitude to its cartesian values, because WebGL/THREE.JS don't work with the shperical/geographic coordinates system.

So I have built also a JSON web-service which helps in data transformations and similar aims.

For e.g. the conversion of the point { 38.23, 55.89 } to its cartesian representation:

enter image description here

Now... I'm really confused how to use it for locating the building correctly on the map. If you would like see, I'm prinring the position of each building in console:

enter image description here

Spherical coordinates and converting at web-service side by such formula in my C# code:

internal Models.PointCartesian ConvertFromSphericalToCartesian(double angleTheta, double anglePhi)
{
    var radTheta = ConvertDegreesToRadians(angleTheta);
    var radPhi = ConvertDegreesToRadians(anglePhi);

    var model = new Models.PointCartesian()
    {
        X = earthRadius * Math.Cos(radTheta) * Math.Cos(radPhi),
        Y = earthRadius * Math.Cos(radTheta) * Math.Sin(radPhi),
        Z = earthRadius * Math.Sin(radTheta)
    };

    return model;
}

So... Right now I'm thinking about some proportions to use... But this way can be incorrect... So what's your suggestion how to set a cube into the correct position on the 3D map just for showing the real position of some buildings.

PS: The records lat | long of each building in DB is 100% correct. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy