Adapting coordinates order

5 replies
  1. japanfever
    japanfever says:

    why complicate simple things?

    show_latlon(...lonlat.reverse()) //32 english characters, 2 functions calls
    show_latlon(lonlat[1],lonlat[0]) //32 english characters, 0 calls, faster

    • Génesis
      Génesis says:

      Sorry, which my first example (lotlat) you are right, why complicate simple things but image that you are using a longer access to lotlat

      This is what I was trying to comunicate (solve):

      show_latlon(ol.proj.toLonLat(openlayers_map.getView().getCenter())[1], ol.proj.toLonLat(openlayers_map.getView().getCenter())[0])

      A) Half of the solution’s calls

      show_latlon(...ol.proj.toLonLat(openlayers_map.getView().getCenter()).reverse())

      B) Even less calls but we have to define an extra variable (that we will use it only once), for example we can call it lonlat as in the previous example

      let lonlat = ol.proj.toLonLat(openlayers_map.getView().getCenter())

      show_latlon(lonlat[1], lonlat[0])

      And now in a generic propose (that I should find) imagine that you have even more coordinates with the oposite reference.

  2. japanfever
    japanfever says:


    let lonlat = ol.proj.toLonLat(openlayers_map.getView().getCenter())
    show_latlon(lonlat[1], lonlat[0])

    this is fast and code easy to follow and only this solution is scalable to any number of coordinates accessing in any random order. reverse order inclusive, but other orderings too

    show_latlon(lonlat[1], lonlat[3], lonlat[2], lonlat[0])

    but i must admit that now i understand the intention of your version of the code & what you propose is a valid option. like you i like to do tricks with the code, but I discovered that if nobody understands my code in the end i have to program alone without expecting any help or collaborationfrom any colleague. sorry… lately Im thinking about quitting programming and studying biology but I think it will be more difficult to be a troll in biology, eheheh

    • Génesis
      Génesis says:

      yes, I think the same, code should be as readable and understandable as possible if we wanna get more people involved that why I love high order functions and declarative approach ^^

    • Génesis
      Génesis says:

      haha come on, you will be a troll anyway 😛 you do not have to leave programming dude to start biology! you know that programming is just a way of doing anything you want from scratch, no limit, just your imagination, it’s just a way to communicate with machines. I use programming to create smart cities, my last flatmate studied biology and after that programming by himself and now he’s working with AI and molecular biology! Use the force japanfever

Comments are closed.