# Adding x and y offset to a Point

132
2
11-14-2021 11:07 PM
Occasional Contributor

I want to obtain a new Point (geodetic) by adding x and y offset (in meters) to another Point. Is there any class or function to do that like in the case of GeodeticDistanceResult?

1 Solution

Accepted Solutions
Esri Contributor
Hi Fatma - thank you for your message.

Yes, you can create a new point by applying an offset to an existing point using the GeometryEngine::moveGeodetic method (or GeometryEngine.moveGeodetic method using Qml). This allows you to offset a point/points by a specified distance and azimuth.

If you would like to apply an offset in the x and y directions, you could use the moveGeodetic method twice, once in the x-direction and then again in the y-direction. Please find an example of this using the C++ api below, where:
• An initial point initialPoint is created.
• initialPoint is converted from a Point object into a QList<Point> called initialPointList for compatability with the GeometryEngine::moveGeodetic method arguments.
• initialPointList is offset by 1000m in the y-direction to create a new QList<Point> called yOffsetPoint.
• yOffsetPoint is offset by 500m in the x-direction to create a new QList<Point> called offsetPointList.
• The offset point is converted from the QList<Point> into a Point called offsetPoint.

``````// Define initial point.
Point initialPoint(7.65851, 45.97661, SpatialReference::wgs84());

// Apply 1000m offset in the y-direction (i.e. azimuth = 0 deg).
QList<Point> initialPointList{initialPoint};
QList<Point> yOffsetPoint = GeometryEngine::moveGeodetic(initialPointList, 1000, LinearUnit::meters(), 0.0f, AngularUnit::degrees(), GeodeticCurveType::GreatElliptic);

// Apply 500m offset in the x-direction (i.e. azimuth = 90 deg).
QList<Point> offsetPointList = GeometryEngine::moveGeodetic(yOffsetPoint, 500, LinearUnit::meters(), 90.0f, AngularUnit::degrees(), GeodeticCurveType::GreatElliptic);

// Convert offsetPointList from QList<Point> to Point.
Point offsetPoint = offsetPointList.at(0);``````

I hope this helps you achieve your desired result. Let us know if we can provide you with any further information.
2 Replies
Esri Contributor
Hi Fatma - thank you for your message.

Yes, you can create a new point by applying an offset to an existing point using the GeometryEngine::moveGeodetic method (or GeometryEngine.moveGeodetic method using Qml). This allows you to offset a point/points by a specified distance and azimuth.

If you would like to apply an offset in the x and y directions, you could use the moveGeodetic method twice, once in the x-direction and then again in the y-direction. Please find an example of this using the C++ api below, where:
• An initial point initialPoint is created.
• initialPoint is converted from a Point object into a QList<Point> called initialPointList for compatability with the GeometryEngine::moveGeodetic method arguments.
• initialPointList is offset by 1000m in the y-direction to create a new QList<Point> called yOffsetPoint.
• yOffsetPoint is offset by 500m in the x-direction to create a new QList<Point> called offsetPointList.
• The offset point is converted from the QList<Point> into a Point called offsetPoint.

``````// Define initial point.
Point initialPoint(7.65851, 45.97661, SpatialReference::wgs84());

// Apply 1000m offset in the y-direction (i.e. azimuth = 0 deg).
QList<Point> initialPointList{initialPoint};
QList<Point> yOffsetPoint = GeometryEngine::moveGeodetic(initialPointList, 1000, LinearUnit::meters(), 0.0f, AngularUnit::degrees(), GeodeticCurveType::GreatElliptic);

// Apply 500m offset in the x-direction (i.e. azimuth = 90 deg).
QList<Point> offsetPointList = GeometryEngine::moveGeodetic(yOffsetPoint, 500, LinearUnit::meters(), 90.0f, AngularUnit::degrees(), GeodeticCurveType::GreatElliptic);

// Convert offsetPointList from QList<Point> to Point.
Point offsetPoint = offsetPointList.at(0);``````

I hope this helps you achieve your desired result. Let us know if we can provide you with any further information.
Occasional Contributor

Thank you very much @AndrewBladon !  I guess I have overlooked this method of GeometryEngine.