Mod geometryArray.js

From MapbenderWiki

Jump to: navigation, search

Contents

mod_geometryArray.js

constants

  • geomTypePolygon, geomTypePoint and geomTypeLine are defining the geometry types.
  • nameGeometryArray, nameMultiGeometry and nameGeometry are defining the names of the classes. Used for snapping.


class GeometryArray

A geometry array consists of a set of multigeometries.

count()

  • returns the number of multigeometries

get(i)

  • returns the i-th multigeometry. get(-i) returns the last but i-th multigeometry, e.g. get(-1) returns the last (or current) multigeometry.

getGeometry(i,j)

  • returns the j-th geometry of the i-th multigeometry (-i is allowed as well).

getPoint(i,j,k)

  • returns the k-th point of the j-th geometry of the i-th multigeometry

addMember(geomtype)

  • adds a new multigeometry of type geomtype. Individual geometries may be inserted via addGeometry.

appendMember(aMember)

  • adds a copy of the given multigeometry aMember.

del(i)

  • deletes the i-th multigeometry.

delGeometry(i,j)

  • deletes the j-th geometry of the i-th multigeometry. If all the geometries of a multigeometry have been deleted, the multigeometry will be deleted as well.

delPoint(i,j,k)

  • deletes the k-th point of the j-th geometry of the i-th multigeometry. If all points of a geometry have been deleted, the geometry will be deleted as well. If all geometries of a multigeometry have been deleted, the multigeometry will be deleted as well.

delAllPointsLike(aPoint)

  • deletes all points with the same coordinates as aPoint. If all points of a geometry have been deleted, the geometry will be deleted as well. If all geometries of a multigeometry have been deleted, the multigeometry will be deleted as well.

updateAllPointsLike(oldP, newP)

  • replaces all points like oldP by newP in all multigeometries.

close()

  • finishes the current geometry. If no coordinates have been added, the geometry is discarded. When a polygon is being constructed, the polygon will be closed by connecting the last to the first point. Actually, the first point is stored twice at index 0 and index length

toString()

  • displays the complete geometryArray, e.g. if d is a geometryArray, alert(d) displays all information.


all other functions are private and shall not be used.


variables

  • m: an array of members (a member represents a multigeometry. A geometry is either a point, a line or a polygon). private
  • name: the name is the value of the constant nameGeometryArray. private

class MultiGeometry

count()

  • returns the number of geometries

get(i)

  • returns the i-th geometry. get(-i) returns the last but i-th geometry, e.g. get(-1) returns the last (or current) geometry.

getPoint(j,k)

  • returns the k-th point of the j-th geometry

addGeometry()

  • adds a new geometry to the multigeometry.

del(i)

  • deletes the i-th geometry.

delPoint(i,j)

  • deletes the j-th point of the i-th geometry. If all points of a geometry have been deleted, the geometry will be deleted as well.

emptyMember()

  • deletes all geometries.

updateAllPointsLike(oldP, newP)

  • replaces all points like oldP by newP in all geometries.

getBBox()

  • returns an array of two points (lower left and upper right) specifying the bounding box of this multigeometry.

getCenter()

  • returns the center of the multigeometry (equals the center of the bounding box)

getTotalPointCount()

  • returns the number of points included in this multigeometry.

isComplete()

  • returns if the multigeometry is complete (true) or is currently being constructed (false).

toString()

  • displays the complete multigeometry, e.g. if m is a multigeometry, alert(m) displays all information.


all other functions are private and shall not be used.

variables

  • e: a WFS element belonging to the multigeometry.
  • geomtype: the geometry type of the multigeometry. This is either geomTypePoint, geomTypeLine or geomTypePolygon.
  • wfs_conf: the index of the corresponding WFS configuration.
  • g: an array of geometries. private
  • name: the name is the value of the constant nameMultiGeometry. private

class Geometry

count()

  • returns the number of points.

get(i)

  • returns the i-th point. get(-i) returns the last but i-th point, e.g. get(-1) returns the last (or current) point.

getBBox()

  • returns an array of two points (lower left and upper right) specifying the bounding box of this geometry.

close()

  • finishes this geometry. If no coordinates have been added, the geometry is discarded. When a polygon is being constructed, the polygon will be closed by connecting the last to the first point. Actually, the first point is stored twice at index 0 and index length

addPoint(aPoint)

  • adds a new point to the geometry.

addPointAtIndex(aPoint, i)

  • adds a new point to the i-th position in this geometry.

addPointByCoordinates(x, y)

  • generates a new point with coordinates x and y and adds it to the geometry.

del(i)

  • deletes the i-th point.

updateGeometry(p, i)

  • replaces the point at index i by point p.

toString()

  • displays the complete geometry, e.g. if g is a geometry, alert(g) displays all its points.


all other functions are private and shall not be used.

variables

  • geomtype: the geometry type of the multigeometry. This is either geomTypePoint, geomTypeLine or geomTypePolygon.
  • v: an array of points (vertices). private.
  • complete: a boolean indicating if a polygon is finished. private.
  • name: the name is the value of the constant nameGeometry. private.

class Wfs_element

count()

  • returns the number of WFS elements.

getElementValueByName(elementName)

  • returns the value of the attribute elementName.

getName(i)

  • returns the name of the attribute at index i.

getValue(i)

  • returns the value of the attribute at index i.

setElement(aName, aValue)

  • sets the attribute aName with value aValue. If aName exists, the value will be overwritten, if not, a new attribute will be added.


all other functions are private and shall not be used.

variables

  • name: an array of attribute names. private.
  • value: an array of attribute values. private.

class Snapping

the snapping class ensures, that there is no basepoint within a certain pixel range of another (snapping range, snapping tolerance). If the basepoints are too close to eachother, they will be snapped and represented by a single basepoint. Also being used to close polygons (digitizing or wfs request) and lines (digitizing).

isSnapped()

  • returns true if the current basepoint is within range of a point in the snapping list.

getSnappedPoint(geom)

  • if isSnapped() is true, the snapped point of geom is returned.

add(geom, i, j, k)

  • adds the point given by geom and the indices i, j and k to the snapping list. If geom is a geometry, j and k may be omitted. If geom is a multigeometry, k may be omitted.

store(geom, event, point)

  • stores all relevant basepoints of geom in respect to point in the snapping list. If event corresponds to a basepoint move, point is not stored.

check(currentBasepoint)

  • checks if the currentBasepoint is within tolerance of all points stored in the snapping list. If no point is that close to currentBasepoint, the index of closest vertex in the snapping list is stored.


all other functions are private and shall not be used.

variables

  • tolerance: the snapping range in pixel.
  • color: the color of the graphics.
  • target: the frame in which the graphics will be displayed.
Views
Personal tools