VrOne/Python Programming
|
ON-LINE REFERENCE DOCUMENTATION CARDINAL SYSTEMS, LLC 386-439-2525
|
VrOne/Python DTM routines More...
The PythonVrOne DTM Class contains routines for creating and working with DTM models. This includes DTM processing, contour generation, and elevation querying.
IMPORTANT USAGE NOTE: There are two main ways to use the DTM class.
See the dtmtest.py and testslope.py scripts for sample code that use the PyVrDtm class.
Returns a DTM object. This object
is either a newly created DTM object or a reference to the VrOne DTM object, depending
on what value is passed in for UseVrDtm.
|
UseVrDtm |
True = Return reference to
existing VrOne DTM object. False = Return new DTM object. |
|
|
CgNum |
Optional. Surface number to use.
0-7, or –1 to use active surface. |
|
|
returns |
(Object) |
|
|
|
Object |
PyVrDtm oject. |
Reset DTM parameters so a new
Process command can be called. Always call this command or ResetMinMax before
calling Process. This method does not need to be called if using the ProcessWs
method.
Reset DTM parameters so points can
be manually added to the DTM. This should always be called before points are
added using AddPoint. All points added using AddPoint must fall within these
bounds. If you are not adding points manually with AddPoint, then you can use
Reset instead.
|
MinX |
Min x of bounding box covering
extents of points to be added to DTM |
|
MinY |
Min y of bounding box covering
extents of points to be added to DTM |
|
MinZ |
Min z of bounding box covering
extents of points to be added to DTM |
|
MaxX |
Max x of bounding box covering
extents of points to be added to DTM |
|
MaxY |
Max y of bounding box covering
extents of points to be added to DTM |
|
MaxZ |
Max z of bounding box covering
extents of points to be added to DTM |
Manually adds a point to the DTM
model. ResetMinMax() must be called before adding the first point. The Process
method must be used after manually adding points, or the points will be
ignored.
|
x |
X coordinate of point to add. |
|
y |
Y coordinate of point to add. |
|
z |
Z coordinate of point to add. |
Sets workspace area to model.
|
AreaToModel |
0=Entire workspace, 1=Window area
only |
Sets verbose mode.
|
Verbose |
0=Verbose mode off, 1=Verbose
mode on |
Sets workspace to consider.
|
WsToConsid |
0=All Workspaces, 1= Current
Workspace |
Processes the DTM TIN only. Does
not place triangles or contours into the current VrOne file. This will process
points and breaklines according to the current DTM parameters. If you would
like to only process manually added points, then call SetPointsLayer and
SetBreaksLayer with empty strings before beginning processing.
Processes the complete DTM.
Ignores any manually added points, and places triangles, contours, boundary line,
and depressions into the current VrOne file according to the current DTM
parameters. This command is equivalent to using the RUNDTM command in VrOne.
Returns elevation of point within
the DTM.
|
x |
Floating point X coordinate of
point where elevation should be computed. |
|
|
y |
Floating point Y coordinate of
point where elevation should be computed. |
|
|
returns |
(z) |
|
|
|
z |
Return elevation. |
Determines whether DTM will remain
in memory after processing. This must be True for cursor tracking. This value
may default to True or False depending on the currently loaded DTM parameters.
|
FreeFlag |
True = Keep DTM in memory. False
= Remove DTM from memory. |
Returns status of DTM.
|
returns |
(ret) |
|
|
|
ret |
True = DTM is valid, False = DTM
is not valid. |
Sets layer for DTM Points.
|
Layer |
String value representing layers
to use when searching for DTM points. This may be a number line (Ex. '1-6 25
65') |
Sets layer for DTM Breaks.
|
Layer |
String value representing layers
to use when searching for DTM breaklines. This may be a number line (Ex. '1-6
25 65') |
Returns minimum Z value of DTM.
|
returns |
(ret) |
|
|
|
ret |
Floating point value of minimum
Z coordinate in DTM. |
Returns maximum Z value of DTM.
|
returns |
(ret) |
|
|
|
ret |
Floating point value of maximum
Z coordinate in DTM. |
Returns points along DTM boundary.
|
returns |
(ret) |
|
|
|
ret |
List of tuples containing points
that make up DTM boundary. Each tuple contains x,y,z floating point
coordinate. |
|
Example |
Bndry =
Cg.GetBoundary() for coord in
Bndry: x, y, z = coord |
Returns status of point in
relation to DTM boundary.
|
x |
X coordinate of point to check |
|
|
y |
Y coordinate of point to check |
|
|
returns |
(ret) |
|
|
|
ret |
True = Points is inside DTM
boundary, False = Points is outside DTM boundary |
Returns points for all contours at
a given elevation.
|
Elev |
Elevation of contour to return. |
|
|
returns |
(ret) |
|
|
|
ret |
List of tuples containing points
that make up all contours at this elevation. Each tuple contains code,x,y,z
where x,y,z are floating point coordinate of the point location, and code is
an integer number that is 0 when a new contour should be started. |
|
Example |
def
SaveContour(Contour, Layer): Line
= PyVrLine () Line.SetLayer
(Layer) #
Go through contour points for
coord in Contour: code,
x, y, z = coord #
New contour starting if code is 0 if (code == 0
and Line.GetNumXyz() > 0): Line.Rec (Ws.Aws()) Line.Reset() Line.AddPoint (x, y,
z) # Make sure last
contour is saved if
(Line.GetNumXyz() > 0): Line.Rec (Ws.Aws()) Line.Reset() ContElev = 125.0 Contour = Cg.GetContour (ContElev) if (len(Contour) >
1): SaveContour (Contour, 2) |
Used with GetNextContour to walk
through all contours at a specified interval.
|
returns |
(Stat, Elev, Contours) |
|
|
|
Stat |
0=More contours to follow, -1=No
more contours available |
|
|
Elev |
Elevation of current Contour |
|
|
Contours |
list of tuples containing points
that make up all contours at this elevation. Each tuple contains code,x,y,z
where x,y,z are floating point coordinate of the point location, and code is
an integer number that is 0 when a new contour should be started. |
|
Example |
Stat, Elev, Contour = Cg.GetFirstContour
(2) # Get contours with 2’ interval SaveContour (Contour, int(Elev)) while (Stat == 0): Stat,
Elev, Contour = Cg.GetNextContour () SaveContour (Contour, int(Elev)) |
Used with GetFirstContour to walk
through all contours at a specified interval.
|
returns |
(Stat, Elev, Contours) |
|
|
|
Stat |
0=More contours to follow, -1=No
more contours available |
|
|
Elev |
Elevation of current Contour |
|
|
Contours |
list of tuples containing points
that make up all contours at this elevation. Each tuple contains code,x,y,z
where x,y,z are floating point coordinate of the point location, and code is
an integer number that is 0 when a new contour should be started. |
|
Example |
# Walk through all triangles (Tri, x1, y1, z1, x2, y2, z2, x3, y3, z3) = Dtm.GetFirstTriangle () while (Tri): (Tri, x1, y1, z1, x2, y2, z2, x3, y3, z3) = Dtm.GetNextTriangle () |
Used with GetNextTriangle to walk
through all triangles.
|
returns |
(TriNum, x1, y1, z1, x2, y2, z2,
x3, y3, z3) |
|
|
|
TriNum |
Triangle number. If 0, then no
triangle was found. |
|
|
x1 |
X Coordinate location of
triangle vertex 1 |
|
|
y1 |
Y Coordinate location of
triangle vertex 1 |
|
|
z1 |
Z Coordinate location of
triangle vertex 1 |
|
|
x2 |
X Coordinate location of
triangle vertex 2 |
|
|
y2 |
Y Coordinate location of
triangle vertex 2 |
|
|
z2 |
Z Coordinate location of
triangle vertex 2 |
|
|
x3 |
X Coordinate location of
triangle vertex 3 |
|
|
y3 |
Y Coordinate location of
triangle vertex 3 |
|
|
z3 |
Z Coordinate location of
triangle vertex 3 |
Used with GetFirstTriangle to walk
through all triangles.
|
returns |
(TriNum, x1, y1, z1, x2, y2, z2,
x3, y3, z3) |
|
|
|
TriNum |
Triangle number. If 0, then no
triangle was found. |
|
|
x1 |
X Coordinate location of
triangle vertex 1 |
|
|
y1 |
Y Coordinate location of
triangle vertex 1 |
|
|
z1 |
Z Coordinate location of
triangle vertex 1 |
|
|
x2 |
X Coordinate location of
triangle vertex 2 |
|
|
y2 |
Y Coordinate location of
triangle vertex 2 |
|
|
z2 |
Z Coordinate location of
triangle vertex 2 |
|
|
x3 |
X Coordinate location of
triangle vertex 3 |
|
|
y3 |
Y Coordinate location of
triangle vertex 3 |
|
|
z3 |
Z Coordinate location of
triangle vertex 3 |
Find triangles that share point
x,y. If x,y is inside a triangle then only 1 triangle will be returned. If x,y
is on edge, then 1 (if boundary triangle) or 2 triangles will be returnred. If
x,y is on vertex, then multiple triangles may be returned.
|
x |
X coordinate of search point |
|
|
y |
Y coordinate of search point |
|
|
returns |
(Triangles) |
|
|
|
Triangles |
List of triangles found |
|
Example |
(Triangles)
= Dtm.FindTriangles (x, y) print
"Found %d triangles." % len(Triangles) for Triangle
in Triangles: (Slope,
Aspect, Cx, Cy) = Dtm.GetTriangleInfo (Triangle) |
Find triangles that share the edge
between ex1, ey1 and ex2, ey2. Will return 1 triangle if edge is on boundary,
or 2 triangles if edge is inside tin.
|
ex1 |
X coordinate of point 1 |
|
|
ey1 |
Y coordinate of point 1 |
|
|
ex2 |
X coordinate of point 2 |
|
|
ey2 |
Y coordinate of point 2 |
|
|
returns |
(Triangles) |
|
|
|
Triangles |
List of triangles found |
|
Example |
(Triangles)
= Dtm.FindTrianglesFromEdge (x1, y1, x2, y2) print
"Found %d triangles." % len(Triangles) for
Triangle in Triangles: (Slope, Aspect, Cx, Cy) = Dtm.GetTriangleInfo (Triangle) |
Get vertex coordinates for a single
triangle.
|
TriNum |
Triangle number. |
|
|
returns |
(x1, y1, z1, x2, y2, z2, x3, y3,
z3) |
|
|
|
x1 |
Vertex 1 x coordinate |
|
|
y1 |
Vertex 1 y coordinate |
|
|
z1 |
Vertex 1 y coordinate |
|
|
x2 |
Vertex 2 x coordinate |
|
|
y2 |
Vertex 2 y coordinate |
|
|
z2 |
Vertex 2 y coordinate |
|
|
x3 |
Vertex 3 x coordinate |
|
|
y3 |
Vertex 3 y coordinate |
|
|
z3 |
Vertex 3 y coordinate |
Get additional triangle
information.
|
TriNum |
Triangle number. |
|
|
returns |
(Slope, Aspect, cx, cy) |
|
|
|
Slope |
Slope of triangle 0.0 to 1.0 |
|
|
Aspect |
Direction of slope in radians
with 0.0=north |
|
|
cx |
Barycenter x coordinate |
|
|
cy |
Barycenter y coordinate |