function scoord3d2Geometry (scoord3d, pyramid) {
  console.info('map coordinates from slide coordinate system to pixel matrix')
  const type = scoord3d.graphicType
  const data = scoord3d.graphicData

  if (type === 'POINT') {
    const coordinates = scoord3dCoordinates2geometryCoordinates(data, pyramid)
    return new PointGeometry(coordinates)
  } else if (type === 'POLYLINE') {
    const coordinates = data.map((d) => {
      return scoord3dCoordinates2geometryCoordinates(d, pyramid)
    })
    return new LineStringGeometry(coordinates)
  } else if (type === 'POLYGON') {
    const coordinates = data.map((d) => {
      return scoord3dCoordinates2geometryCoordinates(d, pyramid)
    })
    return new PolygonGeometry([coordinates])
  } else if (type === 'ELLIPSE') {
    // TODO: ensure that the ellipse represents a circle, i.e. that
    // major and minor axis form a right angle and have the same length
    const majorAxisCoordinates = data.slice(0, 2)
    // const minorAxisCoordinates = data.slice(2, 4)
    // Circle is defined by two points: the center point and a point on the
    // circumference.
    const point1 = majorAxisCoordinates[0]
    const point2 = majorAxisCoordinates[1]
    let coordinates = [
      [
        (point1[0] + point2[0]) / parseFloat(2),
        (point1[1] + point2[1]) / parseFloat(2),
        0
      ],
      point2
    ]
    coordinates = coordinates.map((d) => {
      return scoord3dCoordinates2geometryCoordinates(d, pyramid)
    })
    // to flat coordinates
    coordinates = [
      ...coordinates[0].slice(0, 2),
      ...coordinates[1].slice(0, 2)
    ]

    // flat coordinates in combination with opt_layout and no opt_radius are also accepted
    // and internally it calculates the Radius
    return new CircleGeometry(coordinates, null, 'XY')
  } else {
    console.error(`unsupported graphic type "${type}"`)
  }
}
/**
 * Converts a vector graphic from a DICOM SCOORD3D into an Openlayers Geometry
 * representation.
 *
 * @param {Scoord3D} scoord3d - DICOM Microscopy Viewer Scoord3D
 * @param {Object[]} pyramid - Metadata for resolution levels of image pyramid
 * @returns {object} Openlayers Geometry
 * @private
 */
Converts a vector graphic from a DICOM SCOORD3D into an Openlayers Geometry
representation.

@param {Scoord3D} scoord3d - DICOM Microscopy Viewer Scoord3D
@param {Object[]} pyramid - Metadata for resolution levels of image pyramid
@returns {object} Openlayers Geometry
@private
Converts a vector graphic from a DICOM SCOORD3D into an Openlayers Geometry representation . @param { Scoord3D } scoord3d - DICOM Microscopy Viewer Scoord3D @param { Object [] } pyramid - Metadata for resolution levels of image pyramid @returns { object } Openlayers Geometry @private
function scoord3d2Geometry (scoord3d, pyramid) {
  console.info('map coordinates from slide coordinate system to pixel matrix')
  const type = scoord3d.graphicType
  const data = scoord3d.graphicData
  if (type === 'POINT') {
    const coordinates = scoord3dCoordinates2geometryCoordinates(data, pyramid)
    return new PointGeometry(coordinates)
  } else if (type === 'POLYLINE') {
    const coordinates = data.map((d) => {
      return scoord3dCoordinates2geometryCoordinates(d, pyramid)
    })
    return new LineStringGeometry(coordinates)
  } else if (type === 'POLYGON') {
    const coordinates = data.map((d) => {
      return scoord3dCoordinates2geometryCoordinates(d, pyramid)
    })
    return new PolygonGeometry([coordinates])
  } else if (type === 'ELLIPSE') {
    const majorAxisCoordinates = data.slice(0, 2)
    const point1 = majorAxisCoordinates[0]
    const point2 = majorAxisCoordinates[1]
    let coordinates = [
      [
        (point1[0] + point2[0]) / parseFloat(2),
        (point1[1] + point2[1]) / parseFloat(2),
        0
      ],
      point2
    ]
    coordinates = coordinates.map((d) => {
      return scoord3dCoordinates2geometryCoordinates(d, pyramid)
    })
    coordinates = [
      ...coordinates[0].slice(0, 2),
      ...coordinates[1].slice(0, 2)
    ]
    return new CircleGeometry(coordinates, null, 'XY')
  } else {
    console.error(`unsupported graphic type "${type}"`)
  }
}
function scoord3d2Geometry ( scoord3d , pyramid ) { console . info ( 'map coordinates from slide coordinate system to pixel matrix' ) const type = scoord3d . graphicType const data = scoord3d . graphicData if ( type === 'POINT' ) { const coordinates = scoord3dCoordinates2geometryCoordinates ( data , pyramid ) return new PointGeometry ( coordinates ) } else if ( type === 'POLYLINE' ) { const coordinates = data . map ( ( d ) => { return scoord3dCoordinates2geometryCoordinates ( d , pyramid ) } ) return new LineStringGeometry ( coordinates ) } else if ( type === 'POLYGON' ) { const coordinates = data . map ( ( d ) => { return scoord3dCoordinates2geometryCoordinates ( d , pyramid ) } ) return new PolygonGeometry ( [ coordinates ] ) } else if ( type === 'ELLIPSE' ) { const majorAxisCoordinates = data . slice ( 0 , 2 ) const point1 = majorAxisCoordinates [ 0 ] const point2 = majorAxisCoordinates [ 1 ] let coordinates = [ [ ( point1 [ 0 ] + point2 [ 0 ] ) / parseFloat ( 2 ) , ( point1 [ 1 ] + point2 [ 1 ] ) / parseFloat ( 2 ) , 0 ] , point2 ] coordinates = coordinates . map ( ( d ) => { return scoord3dCoordinates2geometryCoordinates ( d , pyramid ) } ) coordinates = [ ... coordinates [ 0 ] . slice ( 0 , 2 ) , ... coordinates [ 1 ] . slice ( 0 , 2 ) ] return new CircleGeometry ( coordinates , null , 'XY' ) } else { console . error ( ` ${ type } ` ) } }
Converts a vector graphic from a DICOM SCOORD3D into an Openlayers Geometry
 representation.
Converts a vector graphic from a DICOM SCOORD3D into an Openlayers Geometry representation .
// TODO: ensure that the ellipse represents a circle, i.e. that // major and minor axis form a right angle and have the same length // const minorAxisCoordinates = data.slice(2, 4) // Circle is defined by two points: the center point and a point on the // circumference. // to flat coordinates // flat coordinates in combination with opt_layout and no opt_radius are also accepted // and internally it calculates the Radius