IEnumLasPoint - Reading into array

1463
3
06-05-2013 06:04 AM
by Anonymous User
Not applicable
Original User: gmcquat

I cannot retrieve more than a single point from a Las point enumerator. The Next() method definition says that the enumerator can retrieve several points into an array. However, the accepted parameter type is WKSPointZ, not an array.

IEnumLasPoint.Next() method "populates an array of WKSPointZs, optional arrays of 0-based file indices and 1-based point IDs."

[C#]public void Next (
    int arraySize,
    ref int pPointCount,
    ref WKSPointZ pPoints,
    ref ILongArray pIntensity,
    ref ILongArray pFileIndices,
    ref IDoubleArray pPointIDs);

Where "pPoints is an array of WKSPointZ. Points are retrieved into it. It must be pre-allocated. It's size must be at least as large as arraySize."


// Create and initialize an array of WKSPointZ:
WKSPointZ[] pPoints = new WKSPointZ[10]; // Passing this array of WKSPointZ gives an invalid type error.
pPoints.Initialize();

WKSPointZ point = new WKSPointZ(); // BUT if I pass in this single WKSPointZ it works!

// The method call using the single point instead of the array.
lasenum.Next(1, out pPointCount, out point, null, null, null); // The first parameter (1) should be (10) if attempting to pass in the pre-allocated array.

Also notice that the Next() definition says ref whereas intellisense tells me that the method wants an out.

I would really like to be able to read in more than a point at a time. Any help appreciated.
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: decluster

Hi, gmcquat,

I suffered the same problem, and I could not even read in one point. I used a filter to define the AOI within which I'd like to collect lidar point information (especially Z values). I do not know how many points there are in the AOI (but I know it's less than 100 points)

I'd like to discuss more about using the IEnumLasPoint interface. If you are interested, please contact me at decluster@hotmail.com.
Below is part of my codes:
            Dim pFea As IFeature = pUpdateFeaCur.NextFeature
            Dim pCurPoint As IPoint = pFea.ShapeCopy
            Dim pPntNeighbor As IEnvelope = New Envelope
            pPntNeighbor.XMin = pCurPoint.X - 10
            pPntNeighbor.XMax = pCurPoint.X + 10
            pPntNeighbor.YMin = pCurPoint.Y - 10
            pPntNeighbor.YMax = pCurPoint.Y + 10


            Dim pLasPntFilter As ILasPointFilter = New LasFilter
            pLasPntFilter.AreaOfInterest = CType(pPntNeighbor, IGeometry) 'QI
            Dim pLasPntCloud As ILasPointCloud = pLasDS 'QI
            Dim pLasPntEnum As IEnumLasPoint = pLasPntCloud.GetLasPoints(Nothing, pLasPntFilter, 0, 1)
            Dim points As New WKSPointZ

            pLasPntEnum.Next(100, 100, points, Nothing, Nothing, Nothing)
0 Kudos
AlexanderXue
New Contributor
Hi,
I reviewed again and my problem solved. It seems to me that the LiDAR points can only be read one by one.
So, a for loop was used in my codes to pop up a WKSPointZ array.
I'd like to discuss more about using IEnumLasPoint, if you are interested, please contact me at decluster@hotmail.com
Thanks.
0 Kudos
by Anonymous User
Not applicable
Original User: clayton62

Java is limited to reading only one point at a time but not C# or C++. For performance you definitely want to read a bunch at a time. Pass the 0 index of the pre-allocated WKSPointZ array to load up a bunch of points:

int arraySize = 5000;
WKSPointZ[] points = new WKSPointZ[arraySize];

enumPt = lasPC.GetLasPoints(null, lasFilter, 1, 1);
enumPt.Next(arraySize, out count, out points[0], null, fileIndices, pointIDs);
0 Kudos