Advertisement
Guest User

Example of slow compile shapeless lenses

a guest
Jun 21st, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 10.24 KB | None | 0 0
  1. /*
  2.  * Copyright (c) 2014 Azavea.
  3.  *
  4.  * Licensed under the Apache License, Version 2.0 (the "License");
  5.  * you may not use this file except in compliance with the License.
  6.  * You may obtain a copy of the License at
  7.  *
  8.  * http://www.apache.org/licenses/LICENSE-2.0
  9.  *
  10.  * Unless required by applicable law or agreed to in writing, software
  11.  * distributed under the License is distributed on an "AS IS" BASIS,
  12.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13.  * See the License for the specific language governing permissions and
  14.  * limitations under the License.
  15.  */
  16.  
  17. package geotrellis.io.geotiff
  18.  
  19. import shapeless._
  20.  
  21. case class TagMetadata(tag: Int, fieldType: Int,
  22.   length: Int, offset: Int)
  23.  
  24. case class ModelTiePoint(i: Double, j: Double, k: Double,
  25.   x: Double, y: Double, z:Double)
  26.  
  27. case class MetadataTags(
  28.   artist: Option[String] = None,
  29.   copyright: Option[String] = None,
  30.   dateTime: Option[String] = None,
  31.   computer: Option[String] = None,
  32.   imageDesc: Option[String] = None,
  33.   maker: Option[String] = None,
  34.   model: Option[String] = None,
  35.   software: Option[String] = None
  36. )
  37.  
  38. case class BasicTags(
  39.   bitsPerSample: Vector[Int] = Vector(1),
  40.   colorMap: Option[Vector[Int]] = None,
  41.   imageLength: Option[Int] = None,
  42.   imageWidth: Option[Int] = None,
  43.   compression: Int = 1,
  44.   photometricInterp: Option[Int] = None,
  45.   resolutionUnit: Option[Int] = None,
  46.   rowsPerStrip: Int = (1 << 31) - 1,
  47.   samplesPerPixel: Int = 1,
  48.   stripByteCounts: Option[Vector[Int]] = None,
  49.   stripOffsets: Option[Vector[Int]] = None,
  50.   xResolution: Option[(Int, Int)] = None,
  51.   yResolution: Option[(Int, Int)] = None
  52. )
  53.  
  54. case class NonBasicTags(
  55.   cellLength: Option[Int] = None,
  56.   cellWidth: Option[Int] = None,
  57.   extraSamples: Option[Vector[Int]] = None,
  58.   fillOrder: Option[Int] = None,
  59.   freeByteCounts: Option[Vector[Int]] = None,
  60.   freeOffsets: Option[Vector[Int]] = None,
  61.   grayResponseCurve: Option[Vector[Int]] = None,
  62.   grayResponseUnit: Option[Int] = None,
  63.   newSubfileType: Option[Int] = None,
  64.   orientation: Option[Int] = None,
  65.   planarConfiguration: Option[Int] = None,
  66.   subfileType: Option[Int] = None,
  67.   thresholding: Int = 1,
  68.   t4Options: Option[Int] = None,
  69.   t6Options: Option[Int] = None,
  70.   halftoneHints: Option[Vector[Int]] = None,
  71.   predictor: Option[Int] = None
  72. )
  73.  
  74. case class GeoTiffTags(
  75.   modelTiePoints: Option[Vector[ModelTiePoint]] = None,
  76.   modelPixelScale: Option[(Double, Double, Double)] = None,
  77.   geoKeyDirectory: Option[GeoKeyDirectory] = None,
  78.   doubles: Option[Vector[Double]] = None,
  79.   asciis: Option[String] = None
  80. )
  81.  
  82. case class DocumentationTags(
  83.   documentNames: Option[String] = None,
  84.   pageNames: Option[String] = None,
  85.   pageNumbers: Option[Vector[Int]] = None,
  86.   xPositions: Option[Vector[(Int, Int)]] = None,
  87.   yPositions: Option[Vector[(Int, Int)]] = None
  88. )
  89.  
  90. case class TileTags(
  91.   tileWidth: Option[Int] = None,
  92.   tileLength: Option[Int] = None,
  93.   tileOffsets: Option[Vector[Int]] = None,
  94.   tileByteCounts: Option[Vector[Int]] = None
  95. )
  96.  
  97. case class CmykTags(
  98.   inkSet: Option[Int] = None,
  99.   numberOfInks: Option[Int] = None,
  100.   inkNames: Option[String] = None,
  101.   dotRange: Option[Vector[Int]] = None,
  102.   targetPrinters: Option[String] = None
  103. )
  104.  
  105. case class DataSampleFormatTags(
  106.   sampleFormat: Option[Vector[Int]] = None,
  107.   maxSampleValues: Option[Vector[Int]] = None,
  108.   minSampleValues: Option[Vector[Int]] = None
  109. )
  110.  
  111. case class ColimetryTags(
  112.   whitePoints: Option[Vector[(Int, Int)]] = None,
  113.   primaryChromaticities: Option[Vector[(Int, Int)]] = None,
  114.   transferFunction: Option[Vector[Int]] = None,
  115.   transferRange: Option[Vector[Int]] = None,
  116.   referenceBlackWhite: Option[Vector[Int]] = None
  117. )
  118.  
  119. case class JpegTags(
  120.   jpegProc: Option[Int] = None,
  121.   jpegInterchangeFormat: Option[Int] = None,
  122.   jpegInterchangeFormatLength: Option[Int] = None,
  123.   jpegRestartInterval: Option[Int] = None,
  124.   jpegLosslessPredictors: Option[Vector[Int]] = None,
  125.   jpegPointTransforms: Option[Vector[Int]] = None,
  126.   jpegQTables: Option[Vector[Int]] = None,
  127.   jpegDCTables: Option[Vector[Int]] = None,
  128.   jpegACTables: Option[Vector[Int]] = None
  129. )
  130.  
  131. case class YCbCrTags(
  132.   yCbCrCoefficients: Option[Vector[(Int, Int)]] = None,
  133.   yCbCrSubSampling: Option[Vector[Int]] = None,
  134.   yCbCrPositioning: Option[Int] = None
  135. )
  136.  
  137. case class ImageDirectory(
  138.   count: Int,
  139.   metadataTags: MetadataTags = MetadataTags(),
  140.   basicTags: BasicTags = BasicTags(),
  141.   nonBasicTags: NonBasicTags = NonBasicTags(),
  142.   geoTiffTags: GeoTiffTags = GeoTiffTags(),
  143.   documentationTags: DocumentationTags = DocumentationTags(),
  144.   tileTags: TileTags = TileTags(),
  145.   cmykTags: CmykTags = CmykTags(),
  146.   dataSampleFormatTags: DataSampleFormatTags = DataSampleFormatTags(),
  147.   colimetryTags: ColimetryTags = ColimetryTags(),
  148.   jpegTags: JpegTags = JpegTags(),
  149.   yCbCrTags: YCbCrTags = YCbCrTags(),
  150.   imageBytes: Option[Vector[Byte]] = None
  151. )
  152.  
  153. object ImageDirectoryLenses {
  154.  
  155.   val countLens = lens[ImageDirectory] >> 'count
  156.  
  157.   val metaDataTagsLens = lens[ImageDirectory] >> 'metadataTags
  158.  
  159.   val artistLens = metaDataTagsLens >> 'artist
  160.   val copyrightLens = metaDataTagsLens >> 'copyright
  161.   val dateTimeLens = metaDataTagsLens >> 'dateTime
  162.   val computerLens = metaDataTagsLens >> 'computer
  163.   val imageDescLens = metaDataTagsLens >> 'imageDesc
  164.   val makerLens = metaDataTagsLens >> 'maker
  165.   val modelLens = metaDataTagsLens >> 'model
  166.   val softwareLens = metaDataTagsLens >> 'software
  167.  
  168.   val basicTagsLens = lens[ImageDirectory] >> 'basicTags
  169.  
  170.   val bitsPerSampleLens = basicTagsLens >> 'bitsPerSample
  171.   val colorMapLens = basicTagsLens >> 'colorMap
  172.   val imageLengthLens = basicTagsLens >> 'imageLength
  173.   val imageWidthLens = basicTagsLens >> 'imageWidth
  174.   val compressionLens = basicTagsLens >> 'compression
  175.   val photometricInterpLens = basicTagsLens >> 'photometricInterp
  176.   val resolutionUnitLens = basicTagsLens >> 'resolutionUnit
  177.   val rowsPerStripLens = basicTagsLens >> 'rowsPerStrip
  178.   val samplesPerPixelLens = basicTagsLens >> 'samplesPerPixel
  179.   val stripByteCountsLens = basicTagsLens >> 'stripByteCounts
  180.   val stripOffsetsLens = basicTagsLens >> 'stripOffsets
  181.   val xResolutionLens = basicTagsLens >> 'xResolution
  182.   val yResolutionLens = basicTagsLens >> 'yResolution
  183.  
  184.   val nonBasicTagsLens = lens[ImageDirectory] >> 'nonBasicTags
  185.  
  186.   val cellLengthLens = nonBasicTagsLens >> 'cellLength
  187.   val cellWidthLens = nonBasicTagsLens >> 'cellWidth
  188.   val extraSamplesLens = nonBasicTagsLens >> 'extraSamples
  189.   val fillOrderLens = nonBasicTagsLens >> 'fillOrder
  190.   val freeByteCountsLens = nonBasicTagsLens >> 'freeByteCounts
  191.   val freeOffsetsLens = nonBasicTagsLens >> 'freeOffsets
  192.   val grayResponseCurveLens = nonBasicTagsLens >> 'grayResponseCurve
  193.   val grayResponseUnitLens = nonBasicTagsLens >> 'grayResponseUnit
  194.   val newSubfileTypeLens = nonBasicTagsLens >> 'newSubfileType
  195.   val orientationLens = nonBasicTagsLens >> 'orientation
  196.   val planarConfigurationLens = nonBasicTagsLens >> 'planarConfiguration
  197.   val subfileTypeLens = nonBasicTagsLens >> 'subfileType
  198.   val thresholdingLens = nonBasicTagsLens >> 'thresholding
  199.   val t4OptionsLens = nonBasicTagsLens >> 't4Options
  200.   val t6OptionsLens = nonBasicTagsLens >> 't6Options
  201.   val halftoneHintsLens = nonBasicTagsLens >> 'halftoneHints
  202.   val predictorLens = nonBasicTagsLens >> 'predictor
  203.  
  204.   val geoTiffTagsLens = lens[ImageDirectory] >> 'geoTiffTags
  205.  
  206.   val modelTiePointsLens = geoTiffTagsLens >> 'modelTiePoints
  207.   val modePixelScaleLens = geoTiffTagsLens >> 'modelPixelScale
  208.   val geoKeyDirectoryLens = geoTiffTagsLens >> 'geoKeyDirectory
  209.   val doublesLens = geoTiffTagsLens >> 'doubles
  210.   val asciisLens = geoTiffTagsLens >> 'asciis
  211.  
  212.   val documentationTagsLens = lens[ImageDirectory] >> 'documentationTags
  213.  
  214.   val documentNamesLens = documentationTagsLens >> 'documentNames
  215.   val pageNamesLens = documentationTagsLens >> 'pageNames
  216.   val pageNumbersLens = documentationTagsLens >> 'pageNumbers
  217.   val xPositionsLens = documentationTagsLens >> 'xPositions
  218.   val yPositionsLens = documentationTagsLens >> 'yPositions
  219.  
  220.   val tileTagsLens = lens[ImageDirectory] >> 'tileTags
  221.  
  222.   val tileWidthLens = tileTagsLens >> 'tileWidth
  223.   val tileLengthLens = tileTagsLens >> 'tileLength
  224.   val tileOffsetsLens = tileTagsLens >> 'tileOffsets
  225.   val tileByteCountsLens = tileTagsLens >> 'tileByteCounts
  226.  
  227.   val cmykTagsLens = lens[ImageDirectory] >> 'cmykTags
  228.  
  229.   val inkSetLens = cmykTagsLens >> 'inkSet
  230.   val numberOfInksLens = cmykTagsLens >> 'numberOfInks
  231.   val inkNamesLens = cmykTagsLens >> 'inkNames
  232.   val dotRangeLens = cmykTagsLens >> 'dotRange
  233.   val targetPrintersLens = cmykTagsLens >> 'targetPrinters
  234.  
  235.   val dataSampleFormatTagsLens = lens[ImageDirectory] >> 'dataSampleFormatTags
  236.  
  237.   val sampleFormatLens = dataSampleFormatTagsLens >> 'sampleFormat
  238.   val maxSampleValuesLens = dataSampleFormatTagsLens >> 'maxSampleValues
  239.   val minSampleValuesLens = dataSampleFormatTagsLens >> 'minSampleValues
  240.  
  241.   val colimetryTagsLens = lens[ImageDirectory] >> 'colimetryTags
  242.  
  243.   val whitePointsLens = colimetryTagsLens >> 'whitePoints
  244.   val primaryChromaticitiesLens = colimetryTagsLens >> 'primaryChromaticities
  245.   val transferFunctionLens = colimetryTagsLens >> 'transferFunction
  246.   val transferRangeLens = colimetryTagsLens >> 'transferRange
  247.   val referenceBlackWhiteLens = colimetryTagsLens >> 'referenceBlackWhite
  248.  
  249.   val jpegTagsLens = lens[ImageDirectory] >> 'jpegTags
  250.  
  251.   val jpegProcLens = jpegTagsLens >> 'jpegProc
  252.   val jpegInterchangeFormatLens = jpegTagsLens >> 'jpegInterchangeFormat
  253.   val jpegInterchangeFormatLengthLens =
  254.     jpegTagsLens >> 'jpegInterchangeFormatLength
  255.   val jpegRestartIntervalLens = jpegTagsLens >> 'jpegRestartInterval
  256.   val jpegLosslessPredictorsLens = jpegTagsLens >> 'jpegLosslessPredictors
  257.   val jpegPointTransformsLens = jpegTagsLens >> 'jpegPointTransforms
  258.   val jpegQTablesLens = jpegTagsLens >> 'jpegQTables
  259.   val jpegDCTablesLens = jpegTagsLens >> 'jpegDCTables
  260.   val jpegACTablesLens = jpegTagsLens >> 'jpegACTables
  261.  
  262.   val yCbCrTagsLens = lens[ImageDirectory] >> 'yCbCrTags
  263.  
  264.   val yCbCrCoefficientsLens = yCbCrTagsLens >> 'yCbCrCoefficients
  265.   val yCbCrSubSamplingLens = yCbCrTagsLens >> 'yCbCrSubSampling
  266.   val yCbCrPositioningLens = yCbCrTagsLens >> 'yCbCrPositioning
  267.  
  268.   val imageBytesLens = lens[ImageDirectory] >> 'imageBytes
  269.  
  270. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement