TPoint represents a geometrical point, identified by the x and y coordinates.
Float: X coordinate of the point in the point's coordinate system.
Float: Y coordinate of the point in the point's coordinate system.
String: returns "TPoint".
Void: assigns to the object all the attributes of the given TPoint object p.
TPoint: returns a new copy of the object.
Float: returns the cartesian distance between the point and another point p.
Void: rounds the object's coordinates to the nearest integer using the Math.round() method.
TRect: expands the point into a TRect object; the rect coordinates are calculated subtracting (leftX, upY) from min and summing (rightX, downY) to max.
If omitted, upY and rightX will be assumed being equal to leftX while downY will be assumed being equal to upY.
Void: moves the point to the new coordinates.
TPoint: assuming the current instance has coordinates relative to the origin point origin, returns a new instance of the object having absolute coordinates.
TPoint: returns a new instance of the object having coordinates expressed relatively to the origin point origin.
Class constructor: creates a new point object given the x and y coordinates.
Example:
p = new TPoint(150, 100)
TPoint: returns a point representing the translation of the current object from coordinate system defined by the TRect object src into the coordinate system defined by the TRect object dest. The method assumes that the rectangle objects src and dest cover the same area.
Boolean: returns true if the object is within the TRect object r.
TRect represents a geometrical rectangle.
String: returns "TRect".
Float: the rectangle's height.
TPoint: the upper right corner for geographical rects, and the lower right corner for graphical rects.
TPoint: the lower left corner for geographical rects, and the upper left corner for graphical rects.
Float: the rectangle's width.
Integer: these two variables return 1 or -1 according to the
direction of the increasing values along the X axis and the Y
axis respectively.
A value of 1 means from left to right on the X axis, and from top
to bottom in the Y axis. This is a graphic coordinate system.
A value of -1 should be only used for yAxis to indicate a
bottom-up order, suitable for geographic coordinate systems.
xAxis and yAxis are used only in the translate method of the TPoint object, and are not needed when dealing with objects in the same coordinate system. The values of 1 and -1 are merely conventional, and have no geometric meaning, apart from indicating a direction which is completely subjective.
Void: assigns to the object all the attributes of the given TRect object r.
TPoint: returns the center of the rectangle.
TRect: returns a copy of the object.
Void: rounds the object's coordinates to the nearest integer using the Math.round() method.
TRect: returns the rectangle representing the intersection with the rect r.
Always test the result, like in the following
example:
if (i = r1.intersection(r2)) {do domething with rect i}
Boolean: returns true if the rect intersects the geometrical object obj.
Void: moves a rectangle adding an offset to it's min and max point coordinates.
Void: moves or resizes the rectangle. If newMaxX and newMaxY are omitted, they are recalculated according to min and the former width and eight of the rectangle.
Void: resizes a rectangle. max is recalculated according to min and the new values of width and height.
TRect: assuming the current instance has coordinates relative to the origin TPoint origin, returns a new instance of the object having absolute coordinates.
TRect: returns a new instance of the object having coordinates expressed relatively to the origin TPoint origin.
TRect: returns the rectangle representing the translation of the current object from coordinate system defined by the rectangle src into the coordinate system defined by the rectangle dest. The method assumes that the rectangle objects src and dest cover the same area.
Class constructor: returns a new rectangle object given the min and max x and y couple of coordinates. The bottomUpY parameter defaults to false, thus indicating a graphical rectangle. rightLeftX should always left to its default value, false, to indicate a left-right order for the x axis, which fits both graphic and geographic reference systems.
Boolean: returns true if the object is within the rectangle r.
TPoint and TRect are to be considered as geometric object primitives and, considering the poor nature of JavaScript as a drawing environment, should fit every need of drawing objects on a map.
A way of drawing more complex objects could be envisaged in drawing every point composing the object perimeter; this however, is left to future versions of the JS-GIS API.
Io order to make new objects work, however, the following methods should be implemented:
centroid() should return the centroid of the object
as TPoint object. See the TRect_centroid implementation.
mbr() should return the minimum bounding rectangle as
a TRect object.
transform(r1, r2) should transform the object's
coordinates, possibly using TPoint.transform() calls.
toRelative(origin), toAbsolute(origin) can
rely on the corresponding TPoint methods.
contains(obj), within(obj), intersects(obj)
could work on the mbr() of the objects, calling the native
corresponding TRect methods; otherwise, a dedicated method should
be implemented.
The doRound() method should round each of the object
coordinate to the nearest integer.
Please note that, for "unknown" geometric objects, TPoint and TRect within(obj) method call obj.contains(this), while TRect contains(obj) calls obj.within(this).
The className property has to be implemented for all new classes.
JS-GIS © 2001, 2002 by Luca S. Percich (mailto:luca.percich@reacoop.it)
Last updated: dec 26, 2002