public static ICoordinate GetCoordinate(this OSGeo.OGR.Geometry geometry, int index) { ICoordinate coordinate = null; if (geometry != null) { if (index >= 0 && index < geometry.GetPointCount()) { int dimension = geometry.GetCoordinateDimension(); double[] buffer = new double[dimension]; switch (dimension) { case 2: geometry.GetPoint_2D(index, buffer); break; case 3: geometry.GetPoint(index, buffer); break; case 4: geometry.GetPointZM(index, buffer); break; } coordinate = new Coordinate(buffer); } } return(coordinate); }
public static void SetCoordinate(this OSGeo.OGR.Geometry geometry, int index, ICoordinate coordinate) { if (geometry != null && coordinate != null) { if (index >= 0 && index < geometry.GetPointCount()) { int dimension = geometry.GetCoordinateDimension(); switch (dimension) { case 2: geometry.SetPoint_2D(index, coordinate.X, coordinate.Y); break; case 3: geometry.SetPoint(index, coordinate.X, coordinate.Y, coordinate.Z); break; case 4: geometry.SetPointZM(index, coordinate.X, coordinate.Y, coordinate.Z, coordinate.M); break; } } } }