Template:Digitalisierung - Module - Snapping
From MapbenderWiki
(Redirected from Digitalisierung - Module - Snapping)
[edit]
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.
[edit]
variables
- coord: the 'snapping list'. An array that contains information about the points of a geometry array that a current point will be checked against. The array coord[i] consists of the following sub-array:
- coord[i]['coord']: a vertex representing a point of a geometry array.
- coord[i]['member']: the member index of the i-th point in the geometry array.
- coord[i]['geometry']: the geometry index of the i-th point in the geometry array.
- coord[i]['point']: the vertex index of the i-th point in the geometry array.
- canvas: an array that represents the content of the div tag of the snapping graphics, e.g. canvas['mapframe1'] corresponds to the content of the graphics of 'mapframe1'.
- min_i: the index of the vertex in the snapping list that is currently snapped. If no vertex is snapped, min_i equals -1.
- tolerance: the snapping range in pixel.
- color: the color of the circular graphic.
- snappingTarget: the frame that contains the div tag and in which the graphic will be displayd.
[edit]
functions
The following public functions are available:
- isSnapped(): returns true if the current basepoint is within range of another.
- getSnappedVertex(): if isSnapped() is true, the snapped vertex is returned.
- addPointToSnapping(p, i, j, k): adds the given vertex p (representing the vertex at index i,j,k in the geometry array) to the snapping list.
- storeSnapCoords(event, currentBasepoint): stores all relevant basepoints in the snapping list. If the event corresponds to a basepoint move, the current vertex of the geometry array is not stored.
- checkSnapped(currentBasepoint): checks if the currentBasepoint is within snappingTolerance of all points stored in the snapping list. If no point is that close to the currentBasepoint, min_i will be set -1. Otherwise, min_i contains the index of closest vertex in the snapping list.
- drawSnappingArea(): fills the div tag with the circular image generated by wz_graphics.
- cleanCanvas(): empties the div tag that contains the circular image generated by wz_graphics.
all other functions are private and shall not be used.

