Skip to content

Need Help #2

@hassanqaiser

Description

@hassanqaiser

Would you please comment the following code? Or explain what it is doing? I need to join data with features and finding hard to understand. I need to code to simply access features and join features with extended data from the external database. Would appreciate your guidance.

          val resultSet = preparedStatement.executeQuery
            try {
              val dx = xmax - xmin
              val dy = ymax - ymin
              val px = new Array[Int](7)
              val py = new Array[Int](7)
              val hexCell = new HexCell(hexGrid.size)
              while (resultSet.next) {
                val loc = resultSet.getString(1)
                val pop = resultSet.getInt(2)
                val arr = loc.split(':')
                val row = arr(0).toLong
                val col = arr(1).toLong
                val cellXY = hexGrid.convertRowColToHexXY(row, col)

                var i = 0
                while (i < 7) {
                  val hx = cellXY.x + hexCell.x(i)
                  val hy = cellXY.y + hexCell.y(i)
                  val fx = (hx - xmin) / dx
                  val fy = 1.0 - (hy - ymin) / dy
                  px(i) = (imgW * fx).toInt
                  py(i) = (imgH * fy).toInt
                  i += 1
                }

                val colorIndex = if (pop < minCount) 0
                else if (pop > maxCount) 255
                else math.floor(255 * (pop - minCount) / delCount).toInt
                g.setColor(colorMapper.getColor(colorIndex))
                g.fillPolygon(px, py, 7)
                g.setColor(Color.GRAY)
                g.drawPolygon(px, py, 7)
              }
            } finally {
              resultSet.close()
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions