Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to create an indoor map and track the user inside a building. All I have is a simple image of the floor plan, with each corner having a certain lon/lat.

The problem is that the floor plan of the building is not aligned north and is in an awkward position on an actual map:

[Position of building image on an actual map]

I've tried numerous different formulas and calculations and they were loosely accurate when the lon/lat point was somewhere in the middle of the image between the top left and bottom right. Any deviation towards the bottom left or top right and the results got wild.

I think it might be weird because of how weirdly the image is rotated.

Is there any formula I've missed that would help here?

What I have tried:

I have tried pretty much the exact same code as used in the sources below, using the lat/lon of the top left (0, 0) of the image as my min and the bottom right as my max:

https://www.codeproject.com/Questions/1156300/Convert-longitude-and-latitude-coordinates-to-imag

android - How to plot a GPS location on an image being used as a map? - Stack Overflow[^]

java - get x y coordinates of image of particular longitude latitude and vice versa - Stack Overflow[^]
Posted
Updated 30-Dec-20 9:44am
v2

The floor plan is just another "coordinate system".

Create another "layer" for the floor plan; work within that using it's coordinate system; then "rotate" it to align with the other "layer(s)" / coordinate systems.

I'll venture that the user will want to be able to rotate the whole building at some point so they can "face" a particular direction (that suits them).
 
Share this answer
 
// cx, cy - center of square coordinates
// x, y - coordinates of a corner point of the square
// theta is the angle of rotation

// translate point to origin
float tempX = x - cx;
float tempY = y - cy;

// now apply rotation
float rotatedX = tempX*cos(theta) - tempY*sin(theta);
float rotatedY = tempX*sin(theta) + tempY*cos(theta);

// translate back
x = rotatedX + cx;
y = rotatedY + cy;


Finding the center might be the hard part though, if it's not a rectangle.
 
Share this answer
 
Comments
Snupps 31-Dec-20 12:15pm    
Would you be able to explain a little further how I'd be able to get my x and y from this? I assume the coordinates you speak of are the lat/lon coordinates. Also, I have no idea what the rotation angle is between my image and the actual world map :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900