Author Topic: google earth terrain import lisp ?  (Read 13394 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 291
google earth terrain import lisp ?
« on: November 15, 2010, 11:24:52 PM »
hi firend
i made other problem ?
i got some mounatain dwg files from client
but that is not complete
so i found google earth tool
but some is diffciulty

i would like to    import   terrain 3d file and   detailed image file  about big area
is that possilbe work ?

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: google earth terrain import lisp ?
« Reply #1 on: November 16, 2010, 02:01:39 AM »
You can do that in Civil3D. Or there might be a Labs tool from Autodesk that imports GE data, but I'm not sure if that still works and what it does.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

Vali

  • Mosquito
  • Posts: 9
Re: google earth terrain import lisp ?
« Reply #2 on: November 16, 2010, 04:55:00 AM »
I hope I didn't opened a can of worms.

MicroStation does import from GE. Then you can export to ACAD.

Regards,
Vali.

ziko30

  • Newt
  • Posts: 51
Re: google earth terrain import lisp ?
« Reply #3 on: November 16, 2010, 10:56:29 AM »
I use AutoCAD MAP 3D and I can do the functions below:

Capture current google earth view and import as raster image

Capture elevation data of the current google earth view and import as mesh


The attachment is an image of what I can capture although if I did import it into AutoCAD, it would be black and white.  I imagine you could have it in color using Google Earth Pro...




============== Acad Map 3D 2009================

yarik

  • Newt
  • Posts: 32
Re: google earth terrain import lisp ?
« Reply #4 on: December 01, 2010, 01:09:16 PM »
Hi dussla!

Maybe you can make trought Google API
Try this
Code: [Select]
(setq earth_application(vlax-create-object "GoogleEarth.ApplicationGE"))
(vlax-dump-object earth_application t)
; Property values:
;   AnimationController (RO) = #<VLA-OBJECT IAnimationControllerGE 00203194>
;   AutoPilotSpeed = 4.434
;   ElevationExaggeration = 0.5
;   SearchController (RO) = #<VLA-OBJECT ISearchControllerGE 001f30b4>
;   StreamingProgressPercentage (RO) = 100
;   TourController (RO) = #<VLA-OBJECT ITourControllerGE 00200354>
;   VersionAppType (RO) = 5
;   VersionBuild (RO) = 1
;   VersionMajor (RO) = 5
;   VersionMinor (RO) = 2
;   ViewExtents (RO) = #<VLA-OBJECT IViewExtentsGE 00203f54>
; Methods supported:
;   GetCamera (1)
;   GetFeatureByHref (1)
;   GetFeatureByName (1)
;   GetHighlightedFeature ()
;   GetLayersDatabases ()
;   GetMainHwnd ()
;   GetMyPlaces ()
;   GetPointOnTerrainFromScreenCoords (2)
;   GetRenderHwnd ()
;   GetTemporaryPlaces ()
;   HideDescriptionBalloons ()
;   IsInitialized ()
;   IsOnline ()
;   LoadKmlData (1)
;   Login ()
;   Logout ()
;   OpenKmlFile (2)
;   SaveScreenShot (2)
;   SetCamera (2)
;   SetCameraParams (8)
;   SetFeatureView (2)
;   ShowDescriptionBalloon (1)

danallen

  • Guest
Re: google earth terrain import lisp ?
« Reply #5 on: December 01, 2010, 10:34:10 PM »
Sketchup will import from google earth as a TIN with image mapped to faces. You can export the geometry to AutoCAD with the Pro version, and the free download gives you 8 hours of working time. The resolution of the TIN varies with your scale, but you can import multiple overlapping areas, though there are some issues with the TIN not lining up but that can be resolved sketchup scripts. The images are trickier because I believe they are skewed in Sketchup to better map to the geometry, but AutoCAD can't import that.

Here is a thread on importing, the same group has other info in the archives.
http://forums.sketchucation.com/viewtopic.php?f=15&t=32325

pedroantonio124

  • Guest
Re: google earth terrain import lisp ?
« Reply #6 on: December 28, 2014, 01:30:16 PM »
Hi

(vl-load-com)
(setq earth_application(vlax-create-object "GoogleEarth.ApplicationGE"))

-> result nil

 i have Google Earth 6 installet.

Lee Mac

  • Seagull
  • Posts: 12910
  • London, England
Re: google earth terrain import lisp ?
« Reply #7 on: December 28, 2014, 02:48:17 PM »
Have you tried this by VovKa?

pedroantonio124

  • Guest
Re: google earth terrain import lisp ?
« Reply #8 on: December 28, 2014, 03:06:05 PM »
Hi Lee,

i  need to import the terrain (altitude points)

Code: [Select]
(defun getzfrompoint (lon lat / z GE keyhole)
  (vl-load-com)
  (if (setq GE  (vlax-get-or-create-object "GoogleEarth.ApplicationGE") keyhole (vlax-get-or-create-object "Keyhole.khInterface"))
    (progn
      (while (/= 1 (vlax-invoke-method GE 'isinitialized)))
      (while (/= 1 (vlax-invoke-method GE 'isonline)))
    )
  )
  (vlax-invoke-method
    keyhole 'setViewParams lat lon 1000   0 0 5 5)
  (setvar 'cmdecho 0)
  (while (/= z
        (setq z
          (caddr
            (vlax-invoke
         keyhole
         'GetPointOnTerrainFromScreenCoords
         0
         0
            )
          )
        )
    )
  )
  (setvar 'cmdecho 1)
  (vlax-release-object GE)
  (vlax-release-object keyhole)
  z
)


dgpuertas

  • Newt
  • Posts: 80
Re: google earth terrain import lisp ?
« Reply #9 on: December 29, 2014, 03:14:51 AM »
From vodka too,

Code - Auto/Visual Lisp: [Select]
  1.  
  2.  (defun vk_GetGEarthElevation (lat lon)
  3.   (atof (last (assoc "elevation" (last (assoc "result"
  4.                       (last (assoc "ElevationResponse" (vk_ReadXML
  5.                                  (strcat "http://maps.googleapis.com/maps/api/elevation/xml?locations=" (rtos lat 2 16) "," (rtos lon 2 16))))))
  6.              )))))
  7.  

VovKa

  • Water Moccasin
  • Posts: 1628
  • Ukraine
Re: google earth terrain import lisp ?
« Reply #10 on: December 29, 2014, 05:13:34 AM »

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #11 on: December 29, 2014, 08:39:14 AM »
pedro,

The API in Google Earth is no longer supported.

I believe the last version for which the method
GetPointOnTerrainFromScreenCoords was supported
was 6.1.5001

Furthermore GE would limit you to 5000 pts a day.

So, VovKa's method should be preferred.  Don't
know if they limit you there also.

Here is a link to better data for GE in the form of a kmz file:

ftp://topex.ucsd.edu/pub/srtm15_plus/SRTM15.kmz

ymg
« Last Edit: December 29, 2014, 09:45:41 AM by ymg »

pedroantonio124

  • Guest
Re: google earth terrain import lisp ?
« Reply #12 on: December 30, 2014, 05:13:49 PM »
Hi ymg

the problem is that with the method from
VovKa there is a restriction of 2,500 requests per day.


The Elevation API has the following limits in place:
Users of the free API:
        2,500 requests per 24 hour period.
        512 locations per request.
        5 requests per second.

Is there no possibility to receive the elevation data from Google Earth? and to steer Google Erath?




ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #13 on: December 30, 2014, 08:29:09 PM »
Pedro,

Like I told you, the API on GE is no longer
active and was limited to 5000 pts a day.

Furthermore, GE elevation data was never too accurate.

For a free source of good elevation go to Jonathan de Ferranti's site
and download the file for the zone you need or the whole world
if you feel like it.

http://www.viewfinderpanoramas.org/dem3.html

ymg



alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: google earth terrain import lisp ?
« Reply #14 on: January 05, 2015, 04:01:13 PM »
Running version: 7.1.2.2041 and the api still works for me.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #15 on: January 05, 2015, 05:54:55 PM »
Allenjt,

Still works but partially, the particular method "GetPointOnTerrainFromScreenCoords"
we were speaking about does not.

It seems Google is letting go GE more and more.  Does not look good for
the future.  :-(

ymg

danallen

  • Guest
Re: google earth terrain import lisp ?
« Reply #16 on: January 05, 2015, 06:38:13 PM »
maybe Trimble will buy it like they did sketchup...

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: google earth terrain import lisp ?
« Reply #17 on: January 05, 2015, 08:30:02 PM »
Allenjt,

Still works but partially, the particular method "GetPointOnTerrainFromScreenCoords"
we were speaking about does not.

It seems Google is letting go GE more and more.  Does not look good for
the future.  :-(

ymg
I also must disagree with you. I use that very function with my current version.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #18 on: January 06, 2015, 09:27:57 AM »
allenjt,

I will verify with the latest version,  because I've stopped updating
when the first version 7 came out and reverted to v. 6

So maybe it was for only one version or a bug.

Google has also erase most of the documentation pertaining to the API.
However I could find it on the Wayback machine.

Thanks,

ymg

« Last Edit: January 06, 2015, 09:31:07 AM by ymg »

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #19 on: January 06, 2015, 03:45:02 PM »
alanjt,

I verified by installing the latest GE
and running Vovka's "getzfrompoints".

Sorry to report that it no longer works
as I stated before.

Quote
$ (getzfrompoint 40 -62); With version 6.5 Result OK !
-5182.4
_$ (getzfrompoint 40 -62);With Latest version Result Wrong !
-1.41623e-009

ymg

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: google earth terrain import lisp ?
« Reply #20 on: January 06, 2015, 03:51:52 PM »
Execute it again after google earth has completely loaded.

Code: [Select]
Command: (getzfrompoint 40 -62)
-1.41623e-009

Command: (getzfrompoint 40 -62)
-5182.12
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #21 on: January 06, 2015, 04:20:11 PM »
alanjt,

Did try your suggestion and it does work.

However seems to be related to the first call
not functionning even if GE is completely loaded.
Further test seems to be that the first call for a given
Long, Lat returns a wrong results.

Second call result is OK

If so this is easy enough to work around,
although we probably are limited to 2500 pts
instead of 5000

ymg
« Last Edit: January 06, 2015, 04:31:56 PM by ymg »

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: google earth terrain import lisp ?
« Reply #22 on: January 06, 2015, 04:49:26 PM »
alanjt,

Did try your suggestion and it does work.

However seems to be related to the first call
not functionning even if GE is completely loaded.
Further test seems to be that the first call for a given
Long, Lat returns a wrong results.

Second call result is OK

If so this is easy enough to work around,
although we probably are limited to 2500 pts
instead of 5000

ymg
I would think it would just be 1- for each session of autocad the command was executed.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #23 on: January 06, 2015, 06:04:46 PM »
alanjt,

Here a small test:

Code: [Select]
(defun test (/ long lat)
   (setq long -79.0
lat  49.11
   )  
   (repeat 10
     (print (getzfrompoint long lat))
     (print (getzfrompoint long lat))
     (print)
     (setq long (- long 0.1))
   )
 )


Quote
_1$ (test)

0.0
330.824

313.22
313.219

-7.08115e-010
296.83

-1.41623e-009
318.393

-7.08115e-010
334.706

-7.08115e-010
315.692

-2.12435e-009
313.809

308.181
315.999

-7.08115e-010
338.803

312.755
312.755
-80.0
_1$

ymg

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #24 on: January 06, 2015, 08:02:11 PM »
alanjt,

Some more testing, and it turns out that we have to wait
for the (vlax-invoke-method  keyhole 'setViewParams lat lon 1000   0 0 5 5)
to settle down, and then do the (vlax-invoke keyhole 'GetPointOnTerrainFromScreenCoords 0 0)

I did it with a dummy counting loop up to 30000 and now I get repeating values.
Code: [Select]
(repeat 30000 (setq dummy nil))
Will look into the api documentation if there is a way to insure
that the view has settle down.

ymg

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: google earth terrain import lisp ?
« Reply #25 on: January 06, 2015, 11:46:58 PM »
Wow. That's really temperamental. Are you running the delay with repeat after each call to the keyhole, before getting the screen coord?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #26 on: January 07, 2015, 12:42:58 AM »
alanjt,

Here I've modified Vovka's routine and seem to get reliable results.
Note that there is no need to create the keyhole object.

Code - Auto/Visual Lisp: [Select]
  1. (defun getzfrompoint (lat long /  GE z)
  2.   (if (setq GE  (vlax-get-or-create-object "GoogleEarth.ApplicationGE"))
  3.     (progn
  4.       (while (/= 1 (vlax-invoke-method GE 'isinitialized)))
  5.       (while (/= 1 (vlax-invoke-method GE 'isonline)))
  6.     )
  7.   )
  8.  
  9.   (vlax-invoke-method GE 'SetCameraParams lat long 5000 2 5000 0 0 5)
  10.  
  11.   (repeat 50000 (setq dummy nil)); Works OK but will need to be adjusted depending on your system
  12.  
  13.   (setq z (vlax-get-property (vlax-invoke GE 'GetPointOnTerrainFromScreenCoords 0 0) 'Altitude))
  14.   z
  15. )
  16.  

I tried with waiting on streaming percentage to reach 100%, it did not work.
Code: [Select]
(while (not (= (vlax-get-property GE 'StreamingProgressPercentage) 100)))
Also tried the following based on getting the camera position, didn't work either:
Code: [Select]
(setq cam (vlax-invoke-method GE 'GetCamera t))
    (while (not (and (equal (vlax-get-property cam 'FocusPointLatitude) lat fuzz)(equal (vlax-get-property cam 'FocusPointLongitude) long fuzz)))
     (setq cam (vlax-invoke-method GE 'GetCamera t))
) ;Does not work reliably !!!

ymg
« Last Edit: January 07, 2015, 01:10:45 AM by ymg »

pedroantonio123

  • Guest
Re: google earth terrain import lisp ?
« Reply #27 on: January 22, 2015, 04:26:20 AM »
Hi YMG

Your code works perfectly.   :-)
Now it was just a routine need the Google Earth restart.
Once 2500 points have been read.
I have noticed that it is very slow then.
Normal reaction 0.0000000186, 0.0000020303 Busy
(getvar "CDATE")

Is it possible with a Lisp killprocess googleearth.exe
« Last Edit: January 22, 2015, 04:43:37 AM by pedroantonio123 »

ymg

  • Guest
Re: google earth terrain import lisp ?
« Reply #28 on: January 22, 2015, 08:03:25 AM »
Pedro,

Quote
Your code works perfectly

I still believe that it is a Dead-End, with all the restrictions and the speed of transfer.

As stated before, downloading hgt files for your area of interest would be a better way.

Here is a bit of code, based on Michael Puckett's Readstream to read an elevation
from an hgt file given the latitude and longitude. 

Bear in mind that this has not been thorougly tested,
and that for getting thousands of points it would be better to open the file only once.

Code - Auto/Visual Lisp: [Select]
  1. ;;  getHGT   by ymg                                                           ;
  2. ;;                                                                            ;
  3. ;;  Built on ReadStream by Michael Puckett                                    ;
  4. ;;  http://www.theswamp.org/index.php?topic=17465.0                           ;
  5. ;;                                                                            ;
  6. ;;  Reads a Single Elevation from an HGT file.                                ;
  7. ;;                                                                            ;
  8. ;;  Arguments:                                                                ;
  9. ;;                                                                            ;
  10. ;;      lat   Latitude, in Decimal Degrees.                                   ;
  11. ;;      lon   Longitude, in Decimal Degrees.                                  ;
  12. ;;                                                                            ;
  13. ;;  Returns:                                                                  ;
  14. ;;                                                                            ;
  15. ;;      Elevation as a Signed Short Integer [-32768..32767]                   ;
  16. ;;                                                                            ;
  17. ;;  Notes:                                                                    ;
  18. ;;                                                                            ;
  19. ;;      HGT files are assumed to be in dir "C:\\HGT\\",                       ;
  20. ;;      otherwise you will have to change it in code below.                   ;
  21. ;;                                                                            ;
  22. ;;      Works with 1" or 3" hgt files.                                        ;
  23. ;;                                                                            ;
  24.  
  25. (defun getHGT (lat lon / fso file stream rtn)
  26.     (vl-catch-all-apply
  27.        '(lambda (/ row col path size crw pos msb lsb)
  28.             (setq
  29.                 path     (strcat
  30.                               "C:\\HGT\\"
  31.                               (if (minusp lat) "S" "N")
  32.                               (if (< (abs lat) 10) "0" "")
  33.                               (itoa (abs (floor lat)))
  34.                               (if (minusp lon) "W" "E")
  35.                               (if (< (abs lon) 10) "0" "")
  36.                               (if (< (abs lon) 100) "0" "")
  37.                               (itoa (abs (floor lon)))
  38.                               ".hgt"
  39.                          )
  40.                 fso      (vlax-create-object "Scripting.FileSystemObject")
  41.                 file     (vlax-invoke fso 'GetFile path)
  42.                 stream   (vlax-invoke fso 'OpenTextFile path 1 0)      ;1 = Read, 0 = ASCII                
  43.                 size     (vlax-get file 'Size)
  44.                 crw      (fix (sqrt (/ size 2)))                       ; Number of columns or rows in file.
  45.                 row      (round (* (frac lat) crw))
  46.                 col      (round (* (frac lon) crw))
  47.                 pos      (* 2 (+ (* (1- row) crw) col))
  48.                 ***      (if (plusp pos) (vlax-invoke stream 'skip (- pos 2)))  ; Always returns nil        
  49.                 msb      (ascii (vlax-invoke stream 'read 1))                   ; hgt file are "Big Endian"
  50.                 lsb      (ascii (vlax-invoke stream 'read 1))
  51.                 rtn      (if (> (setq rtn (+ (* msb 256) lsb)) 32767) (- rtn 65536) rtn)
  52.             )
  53.             (vlax-invoke stream 'Close)
  54.         )
  55.     )
  56.    
  57.     (if stream (vlax-release-object stream))
  58.     (if file (vlax-release-object file))
  59.     (if fso (vlax-release-object fso))
  60.    
  61.     rtn
  62. )
  63.  
  64. (defun round (x) (floor (+ x 0.5))) ; Round to Nearest Integer              
  65. (defun frac  (x) (- x (floor x)))   ; (Graham, Knuth & Patashnik definition)
  66. (defun floor (x) (if (minusp (rem x 1)) (- (fix x) 1) (fix x)))
  67.  
  68.  

ymg
« Last Edit: January 22, 2015, 08:39:59 AM by ymg »