Boost logo

Geometry :

From: John Mairs (john.d.mairs_at_[hidden])
Date: 2021-07-07 19:37:17


Thank you so much for a fully working code example!!
I feel like my flashlight just got a bit brighter as navigate deeper down
the boost tunnels!

John

On Tue, Jul 6, 2021 at 6:54 PM Adam Wulkiewicz via Geometry <
geometry_at_[hidden]> wrote:

> Hi John,
>
> W dniu 06.07.2021 o 22:39, John Mairs via Geometry pisze:
> > I've found some online calculators that compute (in 3 dimensions)
> > ECEF x,y,z to LLA and back.
> > https://www.oc.nps.edu/oc2902w/coord/llhxyz.htm
> > <https://www.oc.nps.edu/oc2902w/coord/llhxyz.htm>
> >
> > And I would like to do the same thing using boost geometry.
> >
> > I watched Adam's 2019 Fos4G in Bucharest and I think I saw that only
> > 2D is supported.
> >
> > I'm new to GIS so all of the vocabulary terms are quite overwhelming.
> >
> > I have seen the example (transform_2) in the docs of going from degree
> > (lon-lat) to 3d on the unit circle. Even with that example i don't
> > understand how (theta 5.0 and phi = 15.0) map to lat/long.
>
> You're talking about this example right?
>
> https://www.boost.org/doc/libs/1_76_0/libs/geometry/doc/html/geometry/reference/algorithms/transform/transform_2.html
> The coordinate system used there is spherical polar. See what is theta
> and phi here:
> https://en.wikipedia.org/wiki/Spherical_coordinate_system
>
> You either need bg::cs::spherical_equatorial<bg::degree> or
> bg::cs::geographic<bg::degree> to represent a point as longitude and
> latitude. And while cs::spherical_equatorial is supported in transform()
> by default cs::geographic is not. By "by default" I mean "without
> passing an additional parameter - strategy" like that:
>
> https://www.boost.org/doc/libs/1_76_0/libs/geometry/doc/html/geometry/reference/algorithms/transform/transform_3_with_strategy.html
>
> My talk was about SRS transformations, this is a different part of the
> library than transform(), though they can be used together. It's more or
> less Proj (https://proj.org) adapted to work with Boost.Geometry well.
> The 2d/3d support depends on specific projection. Conversion between 3d
> geographic coordinates and 3d ECEF cartesian coordinates is supported.
>
> #include <boost/geometry.hpp>
> #include <boost/geometry/srs/transformation.hpp>
>
> int main()
> {
> namespace bg = boost::geometry;
> using pt_geo_t = bg::model::point<double, 3,
> bg::cs::geographic<bg::degree>>;
> using pt_car_t = bg::model::point<double, 3, bg::cs::cartesian>;
>
> bg::srs::transformation
> <
> bg::srs::spar::parameters<bg::srs::spar::proj_lonlat,
> bg::srs::spar::ellps_wgs84>,
> bg::srs::spar::parameters<bg::srs::spar::proj_geocent>
> > tr;
>
> pt_geo_t pt_geo{ lon, lat, h };
> pt_car_t pt_car;
>
> tr.forward(pt_geo, pt_car);
> tr.inverse(pt_car, pt_geo);
> }
>
> In case you wanted to see how it's done or to implement it by yourself:
>
> https://gssc.esa.int/navipedia//index.php/Ellipsoidal_and_Cartesian_Coordinates_Conversion
>
> Adam
> _______________________________________________
> Geometry mailing list
> Geometry_at_[hidden]
> https://lists.boost.org/mailman/listinfo.cgi/geometry
>



Geometry list run by mateusz at loskot.net