How can I get the Latitude and longitude coordinates coordinate of element?
I happen to know about this a little bit.
Lat/Lon coordinates locate you anywhere on the globe, but because it's MUCH more convenient to think of buildings being built on a flat surface than on a sphere, there exists a multitude of coordinate system transformations that go from a spherical coordinates (lat-lon-hgt) to planar cartesian coordinates (x-y-hgt)
Unfortunately, converting from one to the other isn't trivial at all (or at least, it's not a simple C++ function). In fact, because earth isn't a perfect sphere, and because different countries want to define their own standards, there exists a multitude (hundreds) of different coordinate systems to choose from, but essentially, they all take a lat-lon min-max range, and project it on a cartesian grid with min-max range. Look here to understand how a bounded lat-lon area gets converted to a bounded rectilinear area:
And FYI, here's a list of all of the coordinate systems supported around the world: https://www.spatialreference.org/ref/epsg/
So, where does this leave you?
Well, first of all, it's not enough to know the lat-lon-height origin of your project. You also need to know which coordinate system you should be using. Do a bit of research to find out which one is most often used in your country/area. You can't just pick any one -- for example it makes no sense to pick an area covering japan if you live in germany.
Anyway, to obtain the lat-lon of your coordinates, do the following:
1) Select a EPSG coordinate system that is valid for your area.
2) Transform your project origin (in lat-lon-height) to the XYH planar coordinate.
3) Add the xy coordinate of your point to your project origin in XYZ planar coordinates. (eg: element.line.begC.x + originX; element.line.begC.y + originY;
4) Make sure you store the result of the addition in doubles (not floats) because the project origin can have huge values when represented as XY.
5) Transform the added result back to lat-lon using the inverse of the transformation you used at step 2.
Of course there are SDKs to help you do this. GDAL is a popular choice for C++ developers. You can look a the tutorials here:
If you are looking for a quick hack, there is another alternative. But it's really a crappy approximations that doesn't work in the general case. But it might be good enough for you if your area is around 50m x 50m.
1) Go here: https://epsg.io/transform
2) Select your target coordinate system (do some research vs where you live)
3) Type in your project origin in lat-lon
4) Click Convert. You now have the XY coordinate of your lat-lon origin.
5) Add 1.0 to the X and Y values.
6) Convert back to lat-lon.
7) Subtract the new lat-lon from the original lat-lon.
You now have a correspondence of (1m, 1m) = (deltaLon, deltaLat)
Now, because you have deltaLon/deltaLat increments for 1 meter in each direction, you can easily approximate the lat-lons of any point in your building.
But, I repeat, these ratios are only valid for very small surfaces, and for points close to the projected origin. You can't apply the same deltaLat/Lon ratios for anything that's too far -- even something just 1 km away will be wrong. Things become imprecise very quickly.