function geometry2Scoord3d (feature, pyramid) {
  const geometry = feature.getGeometry()
  console.info('map coordinates from pixel matrix to slide coordinate system')
  const frameOfReferenceUID = pyramid[pyramid.length - 1].FrameOfReferenceUID
  const type = geometry.getType()
  if (type === 'Point') {
    let coordinates = geometry.getCoordinates()
    coordinates = geometryCoordinates2scoord3dCoordinates(coordinates, pyramid)
    return new Point({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else if (type === 'Polygon') {
    /*
     * The first linear ring of the array defines the outer-boundary (surface).
     * Each subsequent linear ring defines a hole in the surface.
     */
    const coordinates = geometry.getCoordinates()[0].map((c) => {
      return geometryCoordinates2scoord3dCoordinates(c, pyramid)
    })
    return new Polygon({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else if (type === 'LineString') {
    const coordinates = geometry.getCoordinates().map((c) => {
      const result = geometryCoordinates2scoord3dCoordinates(c, pyramid)
      return result
    })
    return new Polyline({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else if (type === 'Circle') {
    const center = geometry.getCenter()
    const radius = geometry.getRadius()
    // Endpoints of major and  minor axis of the ellipse.
    let coordinates = [
      [center[0] - radius, center[1], 0],
      [center[0] + radius, center[1], 0],
      [center[0], center[1] - radius, 0],
      [center[0], center[1] + radius, 0]
    ]
    coordinates = coordinates.map((c) => {
      return geometryCoordinates2scoord3dCoordinates(c, pyramid)
    })
    return new Ellipse({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else {
    // TODO: Combine multiple points into MULTIPOINT.
    console.error(`unknown geometry type "${type}"`)
  }
}
/**
 * Converts a vector graphic from an OpenLayers Feature Geometry into a DICOM SCOORD3D
 * representation.
 *
 * @param {object} feature - OpenLayers Feature
 * @param {Object[]} pyramid - Metadata for resolution levels of image pyramid
 * @returns {Scoord3D} DICOM Microscopy Viewer Scoord3D
 * @private
 */
Converts a vector graphic from an OpenLayers Feature Geometry into a DICOM SCOORD3D
representation.

@param {object} feature - OpenLayers Feature
@param {Object[]} pyramid - Metadata for resolution levels of image pyramid
@returns {Scoord3D} DICOM Microscopy Viewer Scoord3D
@private
Converts a vector graphic from an OpenLayers Feature Geometry into a DICOM SCOORD3D representation . @param { object } feature - OpenLayers Feature @param { Object [] } pyramid - Metadata for resolution levels of image pyramid @returns { Scoord3D } DICOM Microscopy Viewer Scoord3D @private
function geometry2Scoord3d (feature, pyramid) {
  const geometry = feature.getGeometry()
  console.info('map coordinates from pixel matrix to slide coordinate system')
  const frameOfReferenceUID = pyramid[pyramid.length - 1].FrameOfReferenceUID
  const type = geometry.getType()
  if (type === 'Point') {
    let coordinates = geometry.getCoordinates()
    coordinates = geometryCoordinates2scoord3dCoordinates(coordinates, pyramid)
    return new Point({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else if (type === 'Polygon') {
    const coordinates = geometry.getCoordinates()[0].map((c) => {
      return geometryCoordinates2scoord3dCoordinates(c, pyramid)
    })
    return new Polygon({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else if (type === 'LineString') {
    const coordinates = geometry.getCoordinates().map((c) => {
      const result = geometryCoordinates2scoord3dCoordinates(c, pyramid)
      return result
    })
    return new Polyline({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else if (type === 'Circle') {
    const center = geometry.getCenter()
    const radius = geometry.getRadius()
    let coordinates = [
      [center[0] - radius, center[1], 0],
      [center[0] + radius, center[1], 0],
      [center[0], center[1] - radius, 0],
      [center[0], center[1] + radius, 0]
    ]
    coordinates = coordinates.map((c) => {
      return geometryCoordinates2scoord3dCoordinates(c, pyramid)
    })
    return new Ellipse({
      coordinates,
      frameOfReferenceUID: frameOfReferenceUID
    })
  } else {
    console.error(`unknown geometry type "${type}"`)
  }
}
function geometry2Scoord3d ( feature , pyramid ) { const geometry = feature . getGeometry ( ) console . info ( 'map coordinates from pixel matrix to slide coordinate system' ) const frameOfReferenceUID = pyramid [ pyramid . length - 1 ] . FrameOfReferenceUID const type = geometry . getType ( ) if ( type === 'Point' ) { let coordinates = geometry . getCoordinates ( ) coordinates = geometryCoordinates2scoord3dCoordinates ( coordinates , pyramid ) return new Point ( { coordinates , frameOfReferenceUID : frameOfReferenceUID } ) } else if ( type === 'Polygon' ) { const coordinates = geometry . getCoordinates ( ) [ 0 ] . map ( ( c ) => { return geometryCoordinates2scoord3dCoordinates ( c , pyramid ) } ) return new Polygon ( { coordinates , frameOfReferenceUID : frameOfReferenceUID } ) } else if ( type === 'LineString' ) { const coordinates = geometry . getCoordinates ( ) . map ( ( c ) => { const result = geometryCoordinates2scoord3dCoordinates ( c , pyramid ) return result } ) return new Polyline ( { coordinates , frameOfReferenceUID : frameOfReferenceUID } ) } else if ( type === 'Circle' ) { const center = geometry . getCenter ( ) const radius = geometry . getRadius ( ) let coordinates = [ [ center [ 0 ] - radius , center [ 1 ] , 0 ] , [ center [ 0 ] + radius , center [ 1 ] , 0 ] , [ center [ 0 ] , center [ 1 ] - radius , 0 ] , [ center [ 0 ] , center [ 1 ] + radius , 0 ] ] coordinates = coordinates . map ( ( c ) => { return geometryCoordinates2scoord3dCoordinates ( c , pyramid ) } ) return new Ellipse ( { coordinates , frameOfReferenceUID : frameOfReferenceUID } ) } else { console . error ( ` ${ type } ` ) } }
Converts a vector graphic from an OpenLayers Feature Geometry into a DICOM SCOORD3D
 representation.
Converts a vector graphic from an OpenLayers Feature Geometry into a DICOM SCOORD3D representation .
/*
     * The first linear ring of the array defines the outer-boundary (surface).
     * Each subsequent linear ring defines a hole in the surface.
     */ // Endpoints of major and  minor axis of the ellipse. // TODO: Combine multiple points into MULTIPOINT.