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

Round the number to nearest integer #104

Open
dadiorchen opened this issue Mar 13, 2023 · 0 comments
Open

Round the number to nearest integer #104

dadiorchen opened this issue Mar 13, 2023 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@dadiorchen
Copy link
Collaborator

The two 1k here should be 1k and 2k.

    
      /* sql case1 tile */
      
      SELECT 
      'cluster' AS type,
      'case1 tile' AS log,
      NULL AS zoom_to,
      region_id id, 
      st_point(LEAST(st_x(centroid), 170), st_y(centroid)) estimated_geometric_location,St_asgeojson(st_point(LEAST(st_x(centroid), 170), st_y(centroid))) latlon,
      type_id as region_type,
      count(tree_region.id) count,
      CASE WHEN count(tree_region.id) > 1000 
      THEN  (count(tree_region.id) / 1000) || 'K'
      ELSE count(tree_region.id) || ''
      END AS count_text
      FROM active_tree_region tree_region
      JOIN trees ON tree_region.tree_id = trees.id
INNER JOIN wallet.token ON wallet.token.capture_id::text = trees.uuid 
INNER JOIN wallet.wallet ON wallet.wallet.id = wallet.token.wallet_id 

      WHERE zoom_level = 2
      AND wallet.wallet.name = 'heveya.replant.world'
      
      GROUP BY region_id, centroid, type_id

Result:

  type   |    log     | zoom_to |   id    |        estimated_geometric_location        |                           
latlon                            | region_type | count | count_text 
---------+------------+---------+---------+--------------------------------------------+---------------------------
----------------------------------+-------------+-------+------------
 cluster | case1 tile |         |   30286 | 010100000041BC1502E78052C0443F657A6F0B3240 | {"type":"Point","coordinat
es":[-74.014099618,18.044669771]} |           2 |     4 | 4
 cluster | case1 tile |         | 6632636 | 0101000000B0BB7ED6B7B43140AB29E99B3003E8BF | {"type":"Point","coordinat
es":[17.705930143,-0.75038939]}   |           9 |  1100 | 1K
 cluster | case1 tile |         | 6632644 | 010100000039ED9093A7BB5C402BBD034430D21240 | {"type":"Point","coordinat
es":[114.932103054,4.705262244]}  |           9 |  1896 | 1K

@dadiorchen dadiorchen added bug Something isn't working good first issue Good for newcomers labels Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant