Author Topic: Altitude from Google Earth API  (Read 14213 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #30 on: October 18, 2018, 04:55:00 AM »
Hi

Thanks for your replies.  Can anyone change the function to get the Elevations from Bing API instead of Google Earth.
Also, as Kirby suggested, we download Geotiff from USGS website but how to get elevations of various points from Geotiff within AutoCAD / Civil 3D, using Autolisp ?

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Altitude from Google Earth API
« Reply #31 on: October 18, 2018, 04:00:05 PM »
Elevation data from the National Map project for US is available and more accurate then Google, see link https://nationalmap.gov/epqs/


VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #32 on: October 19, 2018, 05:49:45 AM »
Can anyone change the function to get the Elevations from Bing API instead of Google Earth.
i'd try but i don't have a bing key
i tried to register but microsoft demands my phone number which i'm not going to share with them...

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #33 on: October 22, 2018, 06:07:25 AM »
Hi Vovka

Can you modify the function without the key. The Key can be an input variable to the function.

Thanks.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #34 on: October 22, 2018, 06:46:45 AM »
Can you modify the function without the key. The Key can be an input variable to the function.
ok
without tesing
Code: [Select]
(defun vk_MAssoc (Key InList)
  (vl-remove-if-not
    (function (lambda (e) (equal Key (car e))))
    InList
  )
)
(defun vk_ConcatList (StrList Delimiter)
  (or Delimiter (setq Delimiter ""))
  (substr (apply 'strcat
(mapcar (function (lambda (s) (strcat Delimiter (vl-princ-to-string s))))
StrList
)
  )
  (1+ (strlen Delimiter))
  )
)
(defun vk_GE-GetElevations (lst key / url)
;;;  https://developers.google.com/maps/documentation/elevation/usage-and-billing
  (setq url (strcat "https://maps.googleapis.com/maps/api/elevation/xml?key=" key "&locations="))
  (mapcar (function (lambda (e)
      (list (cons 'E (atof (last (assoc "elevation" (last e)))))
    (cons 'R (atof (last (assoc "resolution" (last e)))))
      )
    )
  )
  (vk_MAssoc "result"
     (last
       (assoc "ElevationResponse"
      (vk_ReadXML
(strcat url
(vk_ConcatList (mapcar (function (lambda (e) (strcat (rtos (car e) 2 8) "," (rtos (cadr e) 2 8))))
       lst
       )
       "|"
)
)
      )
       )
     )
  )
  )
)
Edit: changed URL to use SSL
« Last Edit: October 22, 2018, 07:26:20 AM by VovKa »

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #35 on: October 22, 2018, 01:55:39 PM »
Dear Vovka

The function still calls google earth instead of bing. Please check.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #36 on: October 22, 2018, 05:28:40 PM »
The function still calls google earth instead of bing. Please check.
sorry i thought you were asking about google's api key

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #37 on: October 22, 2018, 06:23:12 PM »
Code: [Select]
(defun vk_AssocXmlPath (keys data)
  (vl-every (function (lambda (e) (setq data (last (assoc e data))))) keys)
  data
)
(defun vk_VE-GetElevations (lst key / url)
  (setq url (strcat "http://dev.virtualearth.net/REST/v1/Elevation/List?heights=sealevel&output=xml&key="
    key
    "&points="
    )
  )
  (mapcar (function (lambda (e) (atof (last e))))
  (vk_AssocXmlPath
    (list "Response" "ResourceSets" "ResourceSet" "Resources" "ElevationData" "Elevations")
    (vk_ReadXML
      (strcat url
      (vk_ConcatList
(mapcar (function (lambda (e) (strcat (rtos (car e) 2 8) "," (rtos (cadr e) 2 8)))) lst)
","
      )
      )
    )
  )
  )
)

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Altitude from Google Earth API
« Reply #38 on: October 23, 2018, 10:09:27 AM »
Hi Vovka

Thanks for your inputs.
I have generated a Key (without them asking for my phone number, I only created a new email address and thats the only thing they ask) and I'm able to get elevations. But the elevations are rounded to nearest integer.

Can we increase the precision of the elevations to maybe 2 to 3 digits ?


Elevation data from the National Map project for US is available and more accurate then Google, see link https://nationalmap.gov/epqs/

Also, can we also create a LISP to get multiple elevations using above link, as suggested by snownut.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Altitude from Google Earth API
« Reply #39 on: October 23, 2018, 11:21:44 AM »
Can we increase the precision of the elevations to maybe 2 to 3 digits ?
no
bing returns elevations this way
and that's why i've not added bing's elevations to my IRT app

Also, can we also create a LISP to get multiple elevations using above link, as suggested by snownut.
i've already tried it maybe a year ago
with no success
i couldn't get a response from their site
i think it's somehow connected with security protocols