TBC Macros and Extensions

 View Only

 How do determine local coordinates for a ground scaling point?

David Brubacher's profile image
David Brubacher posted 07-01-2025 10:35

As seen in the Local Site Settings pane.

  • I can get the CSDContainer object from the collection of ISnapIns in Project
  • I can cast the CSD property to a SiteCalibration object, which gives me GroundCoordinateScaleFactor
  • I can see LocationHeight, LocationLongitude and LocationLatitude properties which should give me the scaling point location
  • I can see the GetLocalXYZFromLocalLLH(ICoordinate location) method too, but I need a point object.
  • Ok, the project location should be stored in settings, but all the relevant settings objects are UI based, or at least that's how it seems. There are a LOT of settings.
  • I don't really want to create a point, but maybe that's the way?

Also, this seems like a lot of hoop-jumping, so I expect there is an easier way.

Bryce Haire's profile image
Bryce Haire

Not totally sure exactly what you're trying to do, but maybe try CoordinateManager (Trimble.Vce.Coordinates) (use the ITransformer from the CSDContainer). 
Specifically, GetPosition (passing in null for Source).

Just another rabbit hole to jump down lol. 

David Brubacher's profile image
David Brubacher

I need to send these numbers (and a lot of other stuff I have figured out) to a web service. I realize my question should have been GRID coordinates, not LOCAL coordinates.
I will look at what you suggested shortly. Thanks Bryce

Bryce Haire's profile image
Bryce Haire

Maybe try CoordinateUtilities.ConvertCoordinateGridInUnderlyingSystem (Trimble.Vce.Coordinates)

var coordData = new CoordinateData(toSystem);
 ICoordinate iCoord = CoordinateUtilities.ConvertCoordinateGridInUnderlyingSystem(ki, cType, project);



David Brubacher's profile image
David Brubacher

In response to the 2nd suggestion, I have all the Trimble DLLs in my object browser custom component set, and I can't find anything called CoordinateUtilities or ConvertCoordinateGridInUnderlyingSystem. I also tried your first suggestion and only got null back, but maybe I needed a coordinate collection with a point in it.

Anyway, I made it work thanks to the first line in the second suggestion.

            if (coordinateSystem.CSD is SiteCalibration site)
            {
                // create a coordinate data object to hold the lat/long site location
                var localPoint = new CoordinateData(CoordSystem.eLocal)
                {
                    Height1 = site.LocationHeight,
                    // this seems wierd but it works
                    Planar1 = site.LocationLatitude,
                    Planar2 = site.LocationLongitude
                };
                localPoint.CreateCoordinate();
                // 
                var gridPoint = localPoint.Transform(site.ITransformer, CoordSystem.eGrid);
                job.Append("|ScalePointNorth|");
                job.Append(gridPoint.Planar1.ToString("F5", CultureInfo.InvariantCulture));
                job.Append("|ScalePointEast|");
                job.Append(gridPoint.Planar2.ToString("F5", CultureInfo.InvariantCulture));
                job.Append("|ScalePointElevation|");
                job.Append(gridPoint.Elevation.ToString("F5", CultureInfo.InvariantCulture));
                job.Append("|CombinedScaleFactor|");
                job.Append(site.GroundCoordinatesScaleFactor);
            }

I started with a CoordinateData object in the from system, populated the properties (I guessed at Planar1 and Planar2 because I sure didn't give it Planar values!), created the object internally and then transformed it using the ITransformer from the SiteCalibration CSD.

Is this best practices? no idea, but I have what I need.

A test project with the local project location

Same project but in Grid

Properties of gridPoint after transformation

Thanks again for the good clues Bryce.