Using GPS - Part 1 (AutoCAD)
Posted by Charlie Recksieck
Geolocation And AutoCAD
This is the start of a 2-part article with some basic advice for starting to implement GPS. Part 2 next week will be about using user locations in web applications.
But right here we are dealing with AutoCAD. If you aren't curious about ACAD, then we'll see you back here for part two.
GPS and AutoCAD
Whereas some programmers never or rarely deal with coordinates, locations and GPS in their whole careers, anybody working in CAD (Computer Aided Design) knows that it's part of their daily professional life.
Most of us here at Plannedscape got our start in programming with AutoCAD, first in a company that provided software and consultation for electric utilities with their engineering and system design, then we were acquired by AutoDesk in the same sector. Even since then, a large percentage of our projects have been for large utility companies.
By its very nature, working in AutoCAD means that everything in your drawing is geolocated in some way. Even a interior design CAD file of furniture is still dealing with coordinates in its project coordinate system.
And, of course, larger systems like street maps are dealing with real-world coordinates (a survey coordinate system). Translating the coordinate systems between the X/Y of a GPS coordinate and the X/Y of the internal AutoCAD coordinates is the key, and we'll get into that a bit later.
Where To Get GPS Points
An AutoCAD system that is enabled for use with phones and tables have their own APIs and methods.
In our experience, some of our more sophisticated apps were worked on in an office environment. For example, when the utility company first gets a request for new service, a company rep literally goes to the location to discuss the project and also grabs the GPS coordinates from a specialized GPS tool, such as a handheld Garmin GPS unit. Values are emailed to the designer or imported via an in-house interface.
In general, we would say that the accuracy of the GPS location depends on the quality of equipment you are using. Smartphones are excellent but can still be off of their location by several meters, whereas dedicated GPS devices like a Garmin will usually get it right within 1-3 feet.
That said, GPS technology continues to get more and more accurate every year. (If you're interested in reading further, here is an excellent article.)
Translating Coordinate Systems
We don't want to get too deep in the weeds here in this post on every step you need to do (if you are looking for a quick consult, feel free to reach out to us - we're always happy to talk).
For starters, you have to make sure to understand the differences between model space and paper space in AutoCAD. Don't be scared - there are plenty of good references out there and it's not that hard, once you get used to it.
The more complicated aspect is what exact coordinate system is being used. There are the two biggies in AutoCAD: World Coordinate System (WCS) and User Coordinate System (UCS). But then you've also got the "Cartesian coordinate system" and another 4-5 major ones that might be the system for supplied drawings. There are also even proprietary systems.
This can all sound scary and make your head spin when you try to visualize how each is measured, but the good news is that smart people have designed these systems and there are usually lots of handy APIs available to do your translation of coordinates.
When it comes to working with Autocad code, there's one superior voice out there whom you can always trust: It's Kean Walmsley.
He's been a longtime Autodesk employee and the guru of "how do it do this in Autocad code". If you've read this far in this article on Autocad, then I strongly urge you to follow his blog and use it as a resource: https://www.keanw.com
In my tenure at Autodesk we were in drastically different departments, but I've met him on a few occasions and sat in on workshops of his at AutoCAD University over the years. There's not a nicer guy in programming.
Anyway, I want to include his article with code (C#) on translating between coordinate systems. Even a causal glance at how the code works will be illuminating. Here ya go: .NET Drawing Points From Geolocations.
We'll step back away from the more esoteric AutoCAD stuff next week and get more into general programming and using GPS on the web. Hope to see you there.
Part 2 (available June 6, 2022)