(defun C:import_OSM ( / file patch poi-num polygon-num polyline-num text-line type-objects child collection list-points n o-doc summ list-all-points)
  (setq patch (getfiled "Выбор файла OpenStreetMap" (getvar "DWGPREFIX") "osm" 0))
;;;  (setq patch "E:\\Карты GPS векторные\\OSM\\map1.osm")
  (if (file-p patch)
    (progn
      
      (setq o-doc(XML-Get-XMLObject patch))
      (setq collection(XML-Get-Children o-doc nil))
      (setq summ(vlax-get-property collection 'length))
      (setq n 0)
      (while (setq child (vlax-invoke-method collection 'nextNode))
	(grtext -1 (strcat"Обрабатываю "(itoa n)"/"(itoa summ)))
	(if (=(vlax-get-property child 'tagName) "node")
	  (setq list-all-points (append list-all-points (list(list
						       (XML-Get-Attribute child "id" "")
						       (list(atof(XML-Get-Attribute child "lon" ""))
							    (atof(XML-Get-Attribute child "lat" "")))))))
	  )
	(if (and(=(vlax-get-property child 'tagName) "node")(/= (setq ChildList(XML-Get-ChildList child)) nil))
	  (progn
	    (setq layer (get-layer-be-tags ChildList))
	    (entmake (list '(0 . "POINT")
			   (cons 8 layer)
			   (cons 10 (list(atof(XML-Get-Attribute child "lon" ""))(atof(XML-Get-Attribute child "lat" ""))))
			   ))
	    )
	  )
	(if (=(vlax-get-property child 'tagName) "way")
	  (progn
	    (setq list-points nil)
	    (foreach x (XML-Get-ChildList child)
	      (if (=(vlax-get-property x 'tagName) "nd")
		(setq list-points (append list-points (cdr(assoc(XML-Get-Attribute x "ref" "")list-all-points))))
		))
	    (setq layer (get-layer-be-tags (XML-Get-ChildList child)))
	    (draw-lwpolyline-vla-by-list-property
	      (list(cons "spece" model_spece)
		   (cons "Layer" layer)
		   (cons "Coordinates" list-points)
		   ))
	    )
	  )
	(setq n (1+ n))
	)
      (grtext -1 "")
;;;      (setq recorg (vlax-get-property collection 'item 3))
;;;      (XML-Get-Child-ByAttribute o-doc "node" "id" "93540542")
;;;      (vlax-dump-object o-doc T)
;;;      (vlax-dump-object (setq recorg (vlax-get-property collection 'item 3)) T)
;;;      (vlax-dump-object (setq recorg (XML-Get-Child-ByAttribute o-doc nil "id" "241895600")) T)
;;;      (vlax-dump-object (XML-Get-Child-ByAttribute o-doc nil "id" "241864601") T)
;;;      (vlax-dump-object (XML-Get-Child-ByTeg-and-Attribute o-doc nil "id" "241895600" "node") T)
;;;      (vlax-dump-object  T)
      (vlax-release-object o-doc)
      (vlax-release-object collection)
;;;      (vlax-release-object recorg)
      )
    (alert(strcat"Файл "patch" не найден!"))
    )
  (princ)
  )
;;;(vlax-ename->vla-object o-doc)

(defun get-point-coor-be-id (XML-doc id / collection child flag result)
  (setq collection(XML-Get-Children XML-doc nil))
  (while (not flag)
    (if (setq child (vlax-invoke-method collection 'nextNode))
      (if (and(=(XML-Get-Attribute child "id" "")id)(=(vlax-get-property child 'tagName)"node"))
	(progn
	  (setq result(list(atof(XML-Get-Attribute child "lon" ""))(atof(XML-Get-Attribute child "lat" ""))))
	  (setq flag T)
	  )
	)
      (setq flag T)
      )
    (vlax-release-object child)
    )
  (vlax-release-object collection)
  result
  )


(defun get-layer-be-tags (ChildList / flag list-item-tags list-tags n result tag)
  
  (setq list-tags
	 (list
	   (list"building" "Здания")
	   (list"man_made" "Искусственные сооружения")
	   (list"highway" "Дороги улицы")
	   (list"service" "Разновидности служебных проездов")
	   (list"barrier" "Преграды")
	   (list"cycleway" "Велодорожка")
	   (list"waterway" "Гидрография проточных вод")
	   (list"railway" "Рельсовые пути")
	   (list"aeroway" "Воздушный транспорт")
	   (list"aerialway" "Канатные дороги")
	   (list"power" "Энергетика")
	   (list"leisure" "Места проведения досуга")
	   (list"amenity" "Инфраструктура")
	   (list"office" "Офисы")
	   (list"shop" "Магазины")
	   (list"craft" "Мастерские")
	   (list"tourism" "Туризм")
	   (list"historic" "Исторические места")
	   (list"landuse" "Назначение территории")
	   (list"military" "Военные объекты")
	   (list"natural" "Природные образования")
	   (list"route" "Маршруты")
	   (list"boundary" "Границы")
	   (list"sport" "Спорт")
	   (list"abutters" "Прилегающий район")
	   )
	)
  (foreach x ChildList
    (if (=(vlax-get-property x 'tagName) "tag")
      (setq list-item-tags (append list-item-tags (list(XML-Get-Attribute x "k" ""))))
      ))
  (setq n 0)
  (while (not flag)
    (if (setq tag (nth n list-item-tags))
      (if (setq result (cadr(assoc tag list-tags)))
	(setq flag T)
	)
      (setq flag T)
      )
    (setq n (1+ n))
    )
  (if (= result nil) (setq result "0"))
  result
  )