Aller au contenu

recuperer longitude/latitude


yethi

Messages recommandés

bonjour

 

je cherche a ecrire une fonction qui me permettrais de recupere longitude/latitude stockée dans une fichier JPG (visible dans les propriéte du fichier dans l'explorateur)

 

j'arrive a recuperer certaines info (nom,taille ....) via cette fonction

 

(defun GetFileInfo (FileName / FileObj FileSysObj ReturnVal)
(vl-load-com)
(setq	FileSysObj (vlax-create-object "Scripting.FileSystemObject")
		ReturnVal (cond
						(
							(= (vlax-invoke FileSysObj "FileExists" FileName) 0)
							nil
						)
						(
							(setq FileObj (vlax-invoke FileSysObj "GetFile" FileName))
							(list
								(vlax-get FileObj "type")
								(/ (vlax-get FileObj "Size") 1000.0)
								(vlax-get FileObj "Attributes")
							)
						)
						(T nil)
					)
)
(if FileObj
	(vlax-release-object FileObj)
)
(vlax-release-object FileSysObj)
ReturnVal
)
(GetFileInfo (getstring "\nNom de la photo :" T))

 

 

mais comment recuperer les infos longitude / latitude ???

 

merci

Lien vers le commentaire
Partager sur d’autres sites

Tu dois lire les données GPS stockées dans l'entête du fichier JPG. Elles doivent se trouver dans le bloc APP1, dans un IFD (Image File Directory).

 

Tu peux trouver une brève description du format JPEG sur Wikipedia : https://en.wikipedia.org/wiki/JPEG et plus d'informations ici : http://www.codeproject.com/Articles/47486/Understanding-and-Reading-Exif-Data

 

En théorie tu dois pouvoir le faire entièrement en LISP avec open/read-char/close sauf que read-char transforme les séquences CR/LF en LF donc ça peut poser le problème pour le décodage. Et comme tu lis un byte à la fois, tu dois gérer à la main l'Endianness. C'est quand même assez compliqué (voir impossible) et ça peut prendre du temps.

 

Sinon tu dois trouver un ActiveX qui est capable de faire ça.

Maxence DELANNOY

Développement de compléments aux logiciels Autodesk : AutoCAD, Revit, Inventor, Vault, Navisworks... et autres logiciels de CAO

WIIP - http://wiip.fr

Lien vers le commentaire
Partager sur d’autres sites

Salut

 

Par exemple

 

(setq fic (getfiled "Veuillez choisir une image" "" "JPG" 8))

(setq ado (vlax-create-object "ADODB.Stream"))
(vlax-put ado 'type 1)
(vlax-invoke ado 'open)
(vlax-invoke ado 'loadfromfile fic)
(vlax-put ado 'position 0)
(setq res (vlax-invoke-method ado 'read -1))
(vlax-release-object ado)

(vlax-safearray->list (vlax-variant-value res))

A toi de voir à quoi correspondent les valeurs

 

Ou encore ce lisp trouvé sur theswamp

;;  SS:ReadBinaryStream V2.0  
;;  
;;  function : Read binarystream from file(full path) by given charset , return a List or a String .
;;  
;;  Args:
;;  file -- file name with full path , The file size must be less than amount of memory can be used for the current AUTOCAD .
;;           
;;  char -- charset name , it must register in your system , see the Windows registry sub-key in \\HKEY_CLASSES_ROOT\\MIME\\Database\\Charset
;;          	such as "unicode","ascii","us-ascii","chinese","GB2132", etc.
;;          nil & "Unicode" , allways return a list like by vlisp function Read-char .
;;          Oterwise , the char will be used to convert the stream into text string .
;;           
;;  pos  -- position for start read byte , first start pos is 0 , second is 1, 
;;                   for Bigfont-Char it maybe use two bytes , if so the second text start pos is 2 , 4 ... 2n .
;;  len  -- Numbits for read or readtext , if nil or beyond the size , will be set to suit Maximum value .
;;  
;;  Returns -- if char is nil or "Unicode" , returns a ascii code list ;after Acad2008 , The system expansion Charset beyond the 256 limit ,
;;                      so it may return number like 18714 or -18918(after Acad2013) ,for this case , you can use (rem 18714 256)
;;			or (rem (+ 256(rem -18714 256)) 256) to get the ascii code like old version .
;;             if char is not nil and "Unicode" , and it's supported in your window system , returns a string .
;;  
;;  by GSLS(SS) 10.23-2011 ~ 
;;--------------------------------------------------------------------------;;
;; Refrence :
;;   adodb.stream      from   http://baike.baidu.com/link?url=HkCWIQo1pSmTMN76tTipNkSUR5O_s7_8ctpH_XXuo06y2qhd-TCAkCCuxDOtNi55zA5V9eTPO4fobMbeYDNjHK
;;   Microsoft Data Access Components
;;                     from   http://en.wikipedia.org/wiki/Microsoft_Data_Access_Components
;;   Nonsmall's        from   http://bbs.mjtd.com/forum.php?mod=viewthread&tid=78782&extra=page%3D2%26filter%3Dtypeid%26typeid%3D110&page=1
;;   Michale's         from   http://www.theswamp.org/index.php?topic=17465.0
;;   LeeMac's          from   http://www.theswamp.org/index.php?topic=39814.0
;;   Highflybird's     from   http://www.theswamp.org/index.php?topic=36656.0
;;                            this vbs can't run in my used case : ACAD2011 Win7 64Bit.  
;;--------------------------------------------------------------------------;;
;; Method of Adodb.Stream object .                                          ;;
;;    Open ,  Close ,  Write ,  WriteText , Read ,  ReadText,               ;;
;;    Flush , CopyTo , Cancel , SkipLine,   SetEOS                          ;;
;; Property of Adodb.Stream object .                                        ;;
;;     LineSeparator,   SaveToFile, LoadFromFile , Charset ,                ;;
;;     Size ,  Position , Type , State , Mode , EOS ,                       ;;
;;--------------------------------------------------------------------------;;
;; e.g.  (SS:ReadBinaryStream (findfile "gslsshp.shx")  "us-ascii"  23  32) -->
;;        "\032\010\000\010\000\001\000\010\000\022\000HELL\000\r\031^d\035z6q(`\000\000\000EOF" 
;;       (SS:ReadBinaryStream (findfile "gslsshp.shx") "Unicode" 23 4)--> '(18714 18824 18688 18824)  '(-18918 -18808 -18944 -18808)--of ACAD2015
;;       (SS:ReadBinaryStream (findfile "gslsshp.shx") nil 23 4)--> '(18714 18824 18688 18824)
;;       (SS:ReadBinaryStream (findfile "gslsshp.shx") "ascii" 23 4)-->"\032\010\000\010"
(defun SS:ReadBinaryStream
      (file char pos len / adostream ret size str)  
;_(setq file "gslsshp.shx"  file (findfile file)  char "us-ascii" pos 0 len nil)
;_(setq file "gslsshp.shx"  file (findfile file)  char nil pos 23 len nil)
 (vl-load-com)
 (if (and (findfile file) ;_check file exists , No rebuild file name by (findfile file) , because it maybe not you want truely . 
   (setq adostream (vlax-create-object "ADODB.Stream")) ;_check Adodb.Stream Object created .
   )
   (progn
     (setq ret
     (vl-catch-all-apply
       (function
	 (lambda nil
	   (vlax-put adostream (quote Type) 1)
;_Type --   The Type  property is to read / write only when the current postion located
;_        at the beginning  (Position 0) of stream ,   at other location is read-only.
;_          The default value is adTypeText. However, if the binary data was originally
;_        written in a new empty Stream, Type will be changed to adTypeBinary.
;_         ***  adTypeBinary =1 adTypeText =2 ***
	   (vlax-invoke adostream (quote Open))
;_Open -- Stream.Open Source, Mode, OpenOptions, UserName, Password
;_   Source -- Optional. Variant value that specifies Stream data source. Source may contain
;_		     	an absolute URL string that points to the existing nodes of the well-known tree structure
;_			(such as courriel or file system).  Use URL keyword ("URL = http://server/folder") to specify the URL.
;_			In addition, Source may also contain open the Record object reference to the object to open the Record
;_			associated with the default stream. If not specified Source, Stream will be instantiated and open,
;_			by default it is not associated with the underlying source.
;_          
;_	Mode    -- Optional. ConnectModeEnum value that specifies Access Mode (for example, read / write or read-only) of the gotten Stream .
;_			The default value is adModeUnknown. If Mode is not specified, it is inherited source Stream Variant.
;_			E.G, if you open the source Record in read-only mode, then Stream will also be open by read-only mode in default case .
;_	        *** adModeRead =1  adModeReadWrite =3   adModeRecursive =4194304   adModeShareDenyNone =16  adModeShareDenyRead =4
;_		    adModeShareDenyWrite =8   adModeShareExclusive =12  adModeUnknown =0  adModeWrite =2 ***
;_	     
;_ OpenOptions -- Optional. StreamOpenOptionsEnum value that's default value is -1 .
;_		***  adOpenStreamAsync =1   adOpenStreamFromRecord =4  adOpenStreamUnspecified=-1 ***
;_   UserName  -- Optional. String value that contains (when necessary) the identity of the user to access a Stream object.
;_   Password  -- Optional. String value that contains (when required) to access a Stream object password. 
	   (vlax-invoke-method
	     adostream
	     (quote LoadFromFile)
	     file)
;_LoadFromFile --  Load the contents of an existing file into the Stream, or upload the contents of the lacal file to the server .
;_                 FileName can contain any UNC format valid path and name . If the specified file does not exist, a runtime error will occur.
;_                 Stream object must be open before calling LoadFromFile . This method does not change the binding Stream object ,
;_               	it is still bound to the  object specified by URL of the  original open Stream . LoadFromFile overwrite the current
;_               	contents of the Stream object  with the data read from the file . 
	   (setq size (vlax-get adostream (quote Size))) ;_get size
	   (if (and (numberp pos) (< 0 pos size));_check pos(position) suitable 
	     (setq pos (fix pos))
	     (setq pos 0))
	   (if (and (numberp len) (< 0 len size));_check len(length)  suitable 
	     (setq len (min len (- size pos)))
	     (setq len (- size pos)))
	   (vlax-put adostream (quote Position) pos)
;_Position -- For read-only Stream object, If the Position value you set exceed the Size of  Stream ,
;_              ADO will not return an error. This does not change the size of the Stream,
;_              Stream will not change the content in any way. However, you should avoid this operation
;_              because it may produce meaningless Position value.
	   (vlax-invoke-method
	     adostream
	     (quote Write) ;_overite stream contents by binary though Unicode Charset from memory .
;_Write -- Write the binary data to Stream object . method : Stream.Write Buffer
;_	Buffer -- Variant, contains a bytes safearray to be written.
;_ 	    The specified  bytes written to Stream object, are no space between eachother .
;_ 	    Position is set to  1+ byte of the writen data . Write method does not cut off the flow of the remaining data.
;_	    If you want to cut these bytes, call SetEOS.
;_	    If you write more than the current EOS position, Stream's Size will increase to include the new byte,
;_	       EOS will also be moved to the last byte of new Stream  .
	     (car
	       (list (setq ret (vlax-invoke-method
				 adostream
				 (quote Read)
;_ Read -- Reads the specified number of bytes or whole from the Stream object and return the Variant .
;_ 		specified number of bytes  read from binary Stream object . Variant = Stream.Read ( NumBytes )
;_   NumBytes -- optional. default value is adReadAll .
				 len)) ;_read binary 
		     (vlax-put adostream (quote position) 0) ;_reset position to 0 
		     ))) ;_end new stream 
	   (if
	     (or
	       (null char);_check charset 
	       (and (eq (type char) (quote STR))
		    (eq (strcase char) "UNICODE"));_equal default 
	       (null
		 (member
		   char ;_(setq char "us-ascii")
		   (vl-registry-descendents
		     "HKEY_CLASSES_ROOT\\MIME\\Database\\Charset")) ;_check whether character set is supported in system .
		 )) ;_dermine return ascii list or string
	      nil ;_no rebuild ret .
	      (setq ret
		     (cadddr
		       (list
			 (vlax-put adostream (quote position) 0)
			 (vlax-put adostream (quote type) 2) ;_set type adTypeText
			 (vlax-put adostream (quote charset) char) ;_set char
;_ Charset --  Specifies the character set used to convert the text contents of Stream .
;_              Such as , "Unicode" , "ascii" , "iso-8859-1" ,"Windows-1252",etc. .
;_              For systems supported character set , see the Windows registry sub-key in \\HKEY_CLASSES_ROOT\\MIME\\Database\\Charset .
;_ 	     
;_		For text Stream object , the text object is stored as Unicode. The data read from the Stream is converted by the character
;_ 		set of the specified Charset property. Similarly, to write the data into the Stream object, the character set is specified to  Unicode .
;_
;_		For open Stream, it's current Position shall be at the beginning of located Stream (0) , so as to set Charset.
;_		Charset only used with text Stream object (Type of adTypeText) together. If Type is adTypeBinary, this property is ignored.	    
			 (vlax-invoke
			   adostream
			   (quote ReadText)
			   len) ;_ReadText
;_ ReadText -- Reads the specified number of characters from a text Stream object . Method :  Stream.ReadText ( NumChars ) .
;_   		  NumChars is Optional , Default value is adReadAll , If NumChar over the remaining number of characters in the stream,
;_		  will only return the remaining characters; Sring read is not consistent with the NumChar filled to a specified length;
;_		  If there is no remaining characters can be read, it will return a value of Null variant.
;_		***ReadText not be used to read backwards.
;_		ReadText method used with text stream (Type of adTypeText=2) . For a binary stream, please use Read.
			 (setq STR T)
			 ))))
	   (vlax-invoke adostream (quote close))
;_ Close -- Close any open objects and related objects.
;_		Use the Close method to close the Connection, Record, Recordset or Stream object to release any system resources
;_       	associated with it. Close object does not remove it from memory; then you can change its property settings and
;_	   	turn it on again. Completely remove an object from memory, please set object variable to Nothing (Visual Basic)
;_		or nil (Visual Lisp)  after close object . 
	   ret))))
     (vlax-release-object adostream) ;_release object 
     (if (not (vl-catch-all-error-p ret)) ;_catch error 
(if str
  ret ;_by ReadText
  (if (not (vl-catch-all-error-p
	     (setq
	       ret (vl-catch-all-apply
		     (function
		       (lambda nil
			 (vlax-safearray->list
			   (vlax-variant-value ret))))));_transform array format .
	     ));_catch error of Null SQL Variant .
    ret
    (prompt (strcat "\n" (vl-catch-all-error-message ret))))
  ) ;_returns 
(prompt (strcat "\n" (vl-catch-all-error-message ret))) ;_princ error message 
);_if , end result deal 
     );_progn
   );_if
 );_defun

 

@+

Les Lisps de Patrick

Le but n'est pas toujours placé pour être atteint, mais pour servir de point de mire.

Joseph Joubert, 1754-1824

Lien vers le commentaire
Partager sur d’autres sites

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant
×
×
  • Créer...

Information importante

Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer. Politique de confidentialité