<commit_before>package com.azavea.rf.ingest.model

import java.net.URI

import spray.json._
import DefaultJsonProtocol._
import geotrellis.raster._
import geotrellis.vector._
import geotrellis.proj4.{CRS, LatLng}
import com.azavea.rf.ingest.util.getTiffTags
import com.typesafe.scalalogging.LazyLogging

/** This class provides all information required to read from a source
  *
  * @param uri      The URI of the source imagery
  * @param extent   The Extent of a source tile
  * @param crs      The CRS of the projection to target in tiling
  * @param bandMaps A list of mappings from source to destination tile
  */
case class SourceDefinition(
  uri: URI,
  extent: Extent,
  extentCrs: CRS,
  crs: CRS,
  cellSize: CellSize,
  bandMaps: Array[BandMapping]
)

object SourceDefinition extends LazyLogging {
  implicit val jsonFormat = jsonFormat6(SourceDefinition.apply _)

  /** This object handles deserialization of source definitions and overrides any values which
    *  might be found in the tiff's header.
    */
  case class Overrides(
    uri: URI,
    extent: Option[Extent],
    extentCrs: Option[CRS],
    crs: Option[CRS],
    cellSize: Option[CellSize],
    bandMaps: Array[BandMapping]
  ) {
    def toSourceDefinition: SourceDefinition = {
      if (extent.isDefined && crs.isDefined && cellSize.isDefined) {
        SourceDefinition(<commit_msg>suppress warnings on checked option get<commit_after>package com.azavea.rf.ingest.model

import java.net.URI

import spray.json._
import DefaultJsonProtocol._
import geotrellis.raster._
import geotrellis.vector._
import geotrellis.proj4.{CRS, LatLng}
import com.azavea.rf.ingest.util.getTiffTags
import com.typesafe.scalalogging.LazyLogging

/** This class provides all information required to read from a source
  *
  * @param uri      The URI of the source imagery
  * @param extent   The Extent of a source tile
  * @param crs      The CRS of the projection to target in tiling
  * @param bandMaps A list of mappings from source to destination tile
  */
case class SourceDefinition(
  uri: URI,
  extent: Extent,
  extentCrs: CRS,
  crs: CRS,
  cellSize: CellSize,
  bandMaps: Array[BandMapping]
)

object SourceDefinition extends LazyLogging {
  implicit val jsonFormat = jsonFormat6(SourceDefinition.apply _)

  /** This object handles deserialization of source definitions and overrides any values which
    *  might be found in the tiff's header.
    */
  case class Overrides(
    uri: URI,
    extent: Option[Extent],
    extentCrs: Option[CRS],
    crs: Option[CRS],
    cellSize: Option[CellSize],
    bandMaps: Array[BandMapping]
  ) {
    @SuppressWarnings(Array("OptionGet"))
    def toSourceDefinition: SourceDefinition = {
      if (extent.isDefined && crs.isDefined && cellSize.isDefined) {
        SourceDefinition(
{'fraction_non_alphanumeric': 0.08041458184417441, 'fraction_numerical': 0.0014295925661186562, 'mean_word_length': 3.8175559380378656, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1092956', 'n_tokens_mistral': 884, 'n_tokens_neox': 884, 'n_words': 271}