home products news downloads documentation support gallery online maps resellers search
TNTmips Downloads Menu

HOME

CONTACT US

CURRENT RELEASE
  TNT 2013

DEVELOPMENT VERSION
  TNT 2014

TNTmips Pro
PRIOR RELEASES
  TNT 2012

FREE SOFTWARE
  TNTmips Free
  TNTatlas
  TNTsdk

MORE DOWNLOADS
  HASP Key Driver
  Screen Recorder
  TNT Language Kits
  Sample Geodata
  TNT Scripts

DOCUMENTATION
  TNTmips Tutorials
  Tutorial Datasets
  Technical Guides
  Scripts
  Quick Guides

MORE INFO
  Download FAQs
  FTP
  Download Managers
  Find Reseller

SITE MAP


VecLinesFromXYXYdB.sml


# Dave Breitwisch
# 23 March 2005
#
# Draw point-to-point lines to a new Vector object.  Coordinates taken
# from a main-level database.
#
#  Database will need one table with 4 fields in the following form:
#
#              StartX    StartY      EndX      EndY
#     
#    Line 1        X1        Y1        X2        Y2   
#    Line 2        X3        Y3        X4        Y4
#    Line 3        X5        Y5        X6        Y6 
#    ...
#    ...
#
#  Each line is symbolized as (X1, Y1) to (X2, Y2), etc,.. 
#  Each point is assumed to be in (Easting (m), Northing (m)).
#
#  Note:  Any overlaping lines that are created in the Vector will
#         have a node inserted at the intersection.
#


##################################################
# Change the following values to match your data #
##################################################
#
# filename$ = The location of the project file where the database is located
# objectname$ = Name of the database object holding your data
# tablename$ = Name of the table holding your data
#

string filename$ = "c:/Workspace/TestData.rvc";
string objectname$ = "Database";
string tablename$ = "SamplePts";

##################################################
# Declaration of variables                       #
##################################################

class DATABASE db;
class DBTABLEINFO tableInfo;
class GEOREF G;
numeric i;
array numeric line[4];
vector V;

##################################################
##################################################

clear();

# Select output Vector and Georeference
GetOutputVector(V, "VectorToolkit");
G = GeorefGetParms();
CopyGeorefToObject(V, G);

db = OpenDatabase(filename$, objectname$);

# Make sure the table containing the vector line points exists
# Print error and exit if it does not.
numeric n = TableExists(db, tablename$);
if (n == 0 ) {
  print("The table name specified in the script does not match your database");
  Exit();
}

# Determine number of entries
tableInfo = DatabaseGetTableInfo(db, tablename$);
numeric numberEntries = NumRecords(tableInfo);

# Read fields in each table entry and draw the line using the points
for i = 1 to numberEntries
{
  line[1] = TableReadFieldNum(tableInfo, "StartX", i);
  line[2] = TableReadFieldNum(tableInfo, "StartY", i);
  line[3] = TableReadFieldNum(tableInfo, "EndX", i);
  line[4] = TableReadFieldNum(tableInfo, "EndY", i);

  VectorAddTwoPointLine(V, line[1], line[2], line[3], line[4]);
}

# Clean up procedures
VectorValidate(V);
CloseDatabase(db);
CloseVector(V);

# Inform user of the number of lines that were drawn
print("Number of lines drawn to your output vector: ", numberEntries);


Back Home ©MicroImages, Inc. 2013 Published in the United States of America
11th Floor - Sharp Tower, 206 South 13th Street, Lincoln NE 68508-2010   USA
Business & Sales: (402)477-9554  Support: (402)477-9562  Fax: (402)477-9559
Business info@microimages.com  Support support@microimages.com  Web webmaster@microimages.com

25 March 2009

page update: 26 May 11