Longitude, Longitude to X, Y format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
(defun GeoMarker ( / )
(entmakex '((0 . "POSITIONMARKER")
(100 . "AcDbEntity")
(100 . "AcDbGeoPositionMarker")
(90 . 0)
(10 0.0 0.0 0.0)
(40 . 1.0)
(1 . "")))
)
(setq new_points '()) ;; Initialize new_points list
(foreach point points
(setq nest '()) ;; Initialize nest list for each iteration
;; Create a GeoMarker at origin
(setq origin_marker (GeoMarker))
;; Make GeoMarker a VLA object
(setq om (vlax-ename->vla-object origin_marker))
;; Set the Longitude and Latitude properties on the entity (make sure they exist)
(vlax-put-property om 'Longitude (car point))
(vlax-put-property om 'Latitude (cadr point))
;; Get the X and Y position values from the entity (ensure getpropertyvalue works as expected)
(setq pos-x (getpropertyvalue origin_marker "Position/X"))
(setq pos-y (getpropertyvalue origin_marker "Position/Y"))
;; Ensure pos-x and pos-y are numbers before continuing
(if (and (numberp pos-x) (numberp pos-y))
(progn
;; Set the new point with Z value as 0
(setq nest (list pos-x pos-y 0.0))
;; Append new point to new_points list (consider using cons for performance)
(setq new_points (append new_points (list nest)))
)
(progn
(princ "Error: Invalid coordinate values!")
)
)
;; Delete the created marker
(entdel origin_marker)
)
TLDR: I'm trying to convert the longitude and latitude of a list of points into cartesian coordinates and the resulting list refuses to be sent anywhere outside the main code line.
I'm making a script that takes a path drawn on a KMZ file and retrieves all parcel lines within a 1000 foot area. To accomplish this I have LISP run a py executable that creates a square region around a drawn path and stores the lat and long of the polyline into a csv file. Afterwards I import the csv into LISP and parse out the lat and long into a nested list where each list represents a point with this format (long (x), lat (y)). EX: ((Long1, Lat1), (Long2, Lat2), etc). The problem that is semi solved, is that I need to convert this coordinate system to cartesian coordinates so that the line is drawn in the correct place. I accomplished this by making a geomarker and moving it to the location defined by the coordinates then recording the x and y position of the geomarker before deleting it. The x and y are correct but the problem I'm having is that I can't send the list anywhere without it breaking. Chatgpt said it maybe because the lisp is evaluating the list as a function instead of data. However, I can't figure out how to avoid this misinterpretation. The best solution I came up with is not making this process a definition with a return item but instead keeping it in the main code block. While this work around works in drawing a polyline I would like to use the cartesian coordinates to find what parcel line objects fall within the created region. Any ideas how to avoid this issue? Also I just found out I can't use ADE Query so any ideas on how to automate this as well?