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


smlgeo.sml


# smlgeo.sml
#
# SML script to demonstrate creation of georef object in SML
#
# 1. opens a Raster - cb_tm/blue
# 2. creates a new Vector object and draws a box
# 3. georeferences the Vector so that it bounds the raster
#
# NOTES:
# 1. you must use a minimum of three control points 
# 2. they must not be all on the same line!
#
#
# AUTHOR: 			David Wilson
# 						MicroImages, Inc.
# REQUESTED BY:
# CREATION DATE: 	Nov. 4, 1997
# REVISION LIST: 
#

#########################################################################################
#
# alternate method to get extents of object
#
# can use this in general - if last parm is omitted then returns object coordinates
#
# rgeoref = GetLastUsedGeorefObject(Rin)
# GetObjectExtents(Rin, rxmin, rymin, rxmax, rymax, rgeoref)
#
# now do same for Vector except do not use georef parm
# this will give us object coordinates
# GetObjectExtents(Vout, vxmin, vymin, vxmax, vymax)
#
#########################################################################################


# the source arrays will hold the object coordinates
# for a raster this would be cell values
# for Vector, CAD, TIN it would be object, (non-georefenced), coordinates
array numeric xsrc[5], ysrc[5], zsrc[5];

# the destination arrays will hold the appropriate, (georeferenced), values
array numeric xdest[5], ydest[5], zdest[5];

# arrays to hold Vector points to draw box
array numeric xpoints[10];
array numeric ypoints[10];

# fill in the control points (source and destination) - need 3 minimum

# we will assume a georeferenced raster and a non-georeferenced vector 
# that we wish to georeference to the raster

clear();

raster Rin;
vector Vout;
class Georef rgeoref;
numeric numlines, numcols;
numeric xUL, yUL, xLR, yLR, xUR, yUR, xLL, yLL;

# get the raster
GetInputRaster(Rin);

# get number of lines and columns
numlines = NumLins(Rin);
numcols = NumCols(Rin);

# get the upper left (UL), lower right (LR) 
# upper right (UR), and lower left (LL) coordinates
rgeoref = GetLastUsedGeorefObject(Rin);
ObjectToMap(Rin, 0, 0, rgeoref, xUL, yUL);
ObjectToMap(Rin, numcols, numlines, rgeoref, xLR, yLR);
ObjectToMap(Rin, numcols, 0, rgeoref, xUR, yUR);
ObjectToMap(Rin, 0, numlines, rgeoref, xLL, yLL);

printf("UL: %7.2f %7.2f\n", xUL, yUL);
printf("UR: %7.2f %7.2f\n", xUR, yUR);
printf("LL: %7.2f %7.2f\n", xLL, yLL);
printf("LR: %7.2f %7.2f\n", xLR, yLR);

# create a new Vector here !!!!
# we will draw a box to and match it to the raster
GetOutputVector(Vout, "VectorToolkit");

# draw the box - this will create a polygon
# fill in the points
xpoints[1] = 0;
ypoints[1] = 0;
xpoints[2] = 100;
ypoints[2] = 0;
xpoints[3] = 100;
ypoints[3] = 100;
xpoints[4] = 0;
ypoints[4] = 100;
xpoints[5] = 0;
ypoints[5] = 0;

VectorAddLine(Vout, 5, xpoints, ypoints);


# fill in four control points - one for each corner
# the source values are for the Vector
 
# control point 1 - upper left corner
xsrc[1] = 0;
ysrc[1] = 100;
zsrc[1] = 0;

xdest[1] = xUL;
ydest[1] = yUL;
zdest[1] = 0;

# control point 2 - lower right corner
xsrc[2] = 100;
ysrc[2] = 0;
zsrc[2] = 0;

xdest[2] = xLR;
ydest[2] = yLR;
zdest[2] = 0;

# control point 3 - upper right corner
xsrc[3] = 100;
ysrc[3] = 100;
zsrc[3] = 0;

xdest[3] = xUR;
ydest[3] = yUR;
zdest[3] = 0;

# control point 3 - lower left corner
xsrc[4] = 0;
ysrc[4] = 0;
zsrc[4] = 0;

xdest[4] = xLL;
ydest[4] = yLL;
zdest[4] = 0;

# print out the control points
numeric i;
for i = 1 to 4 {
	printf("%s %2d %7.2f %7.2f %7.2f  ", "i: xsrc, ysrc, zsrc, xdest, ydest, zdest ", i, xsrc[i], ysrc[i], zsrc[i]);
	printf("%7.2f %7.2f %7.2f\n", xdest[i], ydest[i], zdest[i]);
	}

# set number of control points
numeric numpoints = 4;

# now create the georef via dialog
CreateControlPointGeoref(Vout, numpoints, xsrc, ysrc, zsrc, xdest, ydest, zdest);

GeorefFree(rgeoref);
CloseRaster(Rin);


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