TEXT   27

work for map

Guest on 30th April 2022 11:44:23 PM

  1. ) Suppose the map is to be 1000x800 pixels.  We want to do a map of just Japan.
  2. Where is the southernmost point of japan plotted?
  3.  
  4.  
  5. Find the point
  6.   select * from edges where Polygon in (select polygon from polygons where code = "ja") order by latitude limit 1;
  7.    +---------+------+-----------+------------+
  8.    | Polygon | Edge | Latitude  | Longitude  |
  9.    +---------+------+-----------+------------+
  10.    |     560 |  278 | 28.022601 | 116.984001 |
  11.    +---------+------+-----------+------------+
  12.  
  13.  
  14. Find the edges of the map
  15.    select min(latitude), min(longitude), max(latitude), max(longitude) from edges where Polygon in (select polygon from polygons where code = "ja") ;
  16.    +---------------+----------------+---------------+----------------+
  17.    | min(latitude) | min(longitude) | max(latitude) | max(longitude) |
  18.    +---------------+----------------+---------------+----------------+
  19.    |     28.022601 |     116.172001 |     48.574901 |     125.048001 |
  20.    +---------------+----------------+---------------+----------------+
  21.  
  22.  
  23. Use the formula
  24.    x = width * (lon - min_lon) / (max_lon - min_lon)
  25.    x = 1000 * (116.984001 - 116.172001) / (125.048001 - 116.172001)
  26.    x = 91.48
  27.  
  28.    y = height - height * (lat - min_lat) / (max_lat - min_lat)
  29.    y = 800 - 800 * ( 28.022601 - 28.022601) / (28.022601 - 48.574901)
  30.    y = 0;

Raw Paste


Login or Register to edit or fork this paste. It's free.