Search code examples
arcgis-runtime

ArcGISRuntime 100.0 What methods for coordinate conversion


I'm using ArcGISRuntime 100.0 with Qt (linux) and I'm looking for helper classes that provide conversions between DMS / DD and possible toScreenCoords etc. Do these exist ? thanks.


Solution

  • Use the CoordinateFormatter class - https://developers.arcgis.com/qt/latest/cpp/api-reference/esri-arcgisruntime-coordinateformatter.html

    For example, here is how you could take in a lat/long string and convert it to a few formats:

    // Convert Lat Long Coordinates as String to Point
    Point pt = CoordinateFormatter::fromLatitudeLongitude(inputString, 
    SpatialReference(4326));
    
    // Convert Point to various String formats
    qDebug() << CoordinateFormatter::toLatitudeLongitude(pt, LatitudeLongitudeFormat::DecimalDegrees, 5);
    
    qDebug() << CoordinateFormatter::toLatitudeLongitude(pt, LatitudeLongitudeFormat::DegreesDecimalMinutes, 5);
    
    qDebug() << CoordinateFormatter::toLatitudeLongitude(pt, LatitudeLongitudeFormat::DegreesMinutesSeconds, 5);
    

    Here is a sample that showcases how to use it https://github.com/Esri/arcgis-runtime-samples-qt/tree/master/ArcGISRuntimeSDKQt_CppSamples/Geometry/FormatCoordinates