Create polyline from points passed in the Lambert coordinate spatialReference(102017)

200
1
03-20-2024 01:47 AM
Labels (3)
JiyuanChang
New Contributor

Hi, fellow GIS persons,

 

I'm trying to create a polyline from points passed in the Lambert coordinate spatialReference(102017) and coordinate wgs 1984. One point in the pole, so I used coordinate Lambert spatialReference(102017), another point in the Toronto, so I used spatialReference::wgs(). But I can't use PolylineBuilder, it can only specify a coordinate system.
Here is the code.

Esri::ArcGISRuntime::Geometry Display_map_lambert::createPolyline(){

const SpatialReference spatialRefer_wgs(4326);
const SpatialReference spatialRefer_lambert(102017);

SimpleLineSymbol* lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, QColor("red"), 1.5f/*width*/, this);

PolylineBuilder polylineBuilder(spatialRefer_wgs);

// create point of lines
Point northPole(-111.8374, 77.5621, spatialRefer_lambert);
Point Toronto(-87.6828, 41.8379);

polylineBuilder.addPoint(northPole);

polylineBuilder.addPoint(Toronto);

return polylineBuilder.toGeometry();

0 Kudos
1 Reply
TroyFoster
Occasional Contributor

You likely want to use GeometryEngine::project to take your lambert point and transform it to wgs84.

https://developers.arcgis.com/qt/cpp/api-reference/esri-arcgisruntime-geometryengine.html#project

 

   QObject::connect(&polylineBuilder,
        &PolylineBuilder::errorOccurred,
       [=](Error loadError)
        {
           cout << __LINE__ << " " << loadError.message().toStdString()
                << " " << loadError.additionalMessage().toStdString()
                << endl;
        });

   Point projectedPole = static_cast< Esri::ArcGISRuntime::Point >(GeometryEngine::project(northPole, spatialRefer_wgs));

 

Depending on the version of the Maps sdk you are using, you may need to do a geometry_cast to get a Point out of the Geometry parent class that is returned from the project call.

also you can connect to the PolylineBuilder's errorOccurred signal to try to see what it is complaining about with the point adds