Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need Help #2

Open
hassanqaiser opened this issue Sep 12, 2017 · 0 comments
Open

Need Help #2

hassanqaiser opened this issue Sep 12, 2017 · 0 comments

Comments

@hassanqaiser
Copy link

hassanqaiser commented Sep 12, 2017

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()
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant