(defun C:convert_rw5_to_kml (/ patch-rw5 list-rw5 list-gps-points list-strings list_points_list)
  (if(setq patch-rw5 (getfiled "Выбор файла OpenStreetMap" (getvar "DWGPREFIX") "rw5" 0))
    (progn
      (setq list-rw5 (file_read_to_list patch-rw5))
      (foreach x list-rw5
	(if (eq "GPS" (substr x 1 3));(or(eq "BP" (substr x 1 2)))
	  (setq list-gps-points (append list-gps-points (list x)))
	  )
	)
      
      (foreach x list-gps-points
	(setq list_points_list (append list_points_list (list (convert-string-to-list-be-delimiter x ","))))
	)
      (setq list-strings (list
			   "<?xml version=\"1.0\" encoding=\"windows-1251\"?>"
			   "<kml xmlns=\"http://earth.google.com/kml/2.2\">"
			   "<Document>"
			   )
	    )
      (foreach z list_points_list
	(setq list-strings
	       (append list-strings
		       (list
			 (strcat"  <Placemark><name>"(strcat"["(substr (nth 1 z) 3)"]"(substr (nth 5 z) 3))
				"</name><Point><coordinates>"
				(rtos(convert-gmmsssssss-to-g(substr (nth 3 z) 3))2 9) "," (rtos(convert-gmmsssssss-to-g(substr (nth 2 z) 3))2 9)
				",0.000000</coordinates></Point></Placemark>")
			 )
		       )
	      )
	)
      (setq list-strings
	     (append list-strings
		     (list
		       "</Document>"
		       "</kml>"
		       )
		     )
	    )
      (if(setq patch-rw5 (getfiled "Имя сохраняемого файла..." (strcat (vl-filename-directory patch-rw5)"\\"(vl-filename-base patch-rw5)) "kml" 1))
	(file_write_list_to_file patch-rw5 list-strings))
      
      )
    )
;;;  (file_write_list_to_file (strcat (vl-filename-directory patch-rw5)"\\"(vl-filename-base patch-rw5)"_"(vl-filename-extension patch-rw5)) clear-list-rw5)
  (princ)
  )

;;;"51.342961633800" "51°34'29.61634"
(defun convert-gmmsssssss-to-g ( str / )
  (+
    (atof(substr str 1 2))
    (/
      (+
	(*
	  (atof(substr str 4 2))
	  60)
	(+(atof(substr str 6 2))(atof(strcat"0."(substr str 8)))))
	3600
	)
      )
    )