Maplat Tin library
JavaScript library which performs bijective conversion mutually between the coordinate systems of two planes based on the control points.
This is part of Maplat project.
Important Notice - deprecated
maplat_tin module is renamed as @maplat/tin.
Please use @maplat/tin module instead.
Installation
node.js
The easiest way to install maplat_tin is with npm
.
npm install maplat_tin
Browser
Use maplat_tin.js
How to use (node.js case)
var Tin = ; var tin = wh: 500 500 yaxisMode: TinYAXIS_FOLLOW; tin;tin;
Options
wh (method: setWh)
Set width and height of the first coordinate system.
NOTE: If setWh was called, TIN network is reset. So need to call updateTinAsync() again.
yaxisMode
Set Tin.YAXIS_FOLLOW if the y coordinate of the first coordinate system is the same as the direction of the y axis of the second coordinate system, and set Tin.YAXIS_INVERT if it is in the opposite direction.
Default value is Tin.YAXIS_INVERT.
points (method: setPoints)
A set of corresponding points in the first coordinate system and the second coordinate system is specified as an array. Minimum 3 points required. Also, if the alignment of points is too linear, TIN can not be calculated at updateTinAsync and an error occurs.
NOTE: If setPoints was called, TIN network is reset. So need to call updateTinAsync() again.
Methods
updateTinAsync()
Return value is Promise. Calcurate TIN asynchronously. Before calling transform, this method needs to be completed.
transform(xy, inverse)
Convert the coordinates. If the value of inverse is false, the direction of conversion is from the first coordinate system to the second one, if it is true, the direction of conversion is reverse direction.
Properties
strict_status
Confirm after completion of updateTinAsync(). When the value is Tin.STATUS_STRICT, bijection conversion is guaranteed. In the case of Tin.STATUS_LOOSE it is not guaranteed.