generatePositionAndOrientationTargetCentered method

Pair<GemError, PositionOrientation> generatePositionAndOrientationTargetCentered(
  1. Coordinates targetCoords,
  2. Point3d cameraHeadingPitchDegDistanceMeters
)

Generate a position and orientation relative to, and oriented toward/centered on, a target position which is relative to the focused sphere (orientation relative to sphere).

The specified target position is at lon,lat in degrees, with respect to surface of the focused sphere, altitude in meters above sphere (sea level).

The target position does not have an orientation, so it can be considered a point.

The generated orientation is toward the target position, where heading in degrees (0=N, 90=E, 180=S, 270=W) is with respect to the surface of the focused sphere, so heading 0 is looking at the target toward the north, from a position south of the target (the generated position is at 180 degrees as seen from the target).

Pitch in degrees (0=looking toward the target center from above the target, 90=looking at the target center from the horizontal plane/equator of the target, which is the plane containing the target forward and right vectors). The roll is always 0, so the horizon is level.

The generated position is at the specified distance in meters from the target center.

The camera position and orientation are unchanged. The camera or any other object can then be set at the resulting position and with the resulting orientation.

Parameters

  • IN targetCoords Coordinates representing the desired latitude, longitude and altitude.
  • IN cameraHeadingPitchDegDistanceMeters Point3d desired heading pitch and distance for camera.

Returns

Throws

  • An exception if it fails.

Implementation

Pair<GemError, PositionOrientation>
    generatePositionAndOrientationTargetCentered(
  final Coordinates targetCoords,
  final Point3d cameraHeadingPitchDegDistanceMeters,
) {
  final OperationResult resultString = objectMethod(
    _pointerId,
    'MapCamera',
    'generatePositionAndOrientationTargetCentered',
    args: <String, Object>{
      'coordinates': targetCoords,
      'tuple3D': cameraHeadingPitchDegDistanceMeters,
    },
  );

  return Pair<GemError, PositionOrientation>(
    GemErrorExtension.fromCode(resultString['result']['errorCode']),
    PositionOrientation(
      position: Point3d.fromJson(resultString['result']['tuple3D']),
      orientation: Point4d.fromJson(resultString['result']['tuple4D']),
    ),
  );
}