Curve.js 701 Bytes
Newer Older
yaqizhang's avatar
yaqizhang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30


import Plot from './Plot'
import PlotTypes from '../PlotTypes'
import LineString from 'ol/geom/LineString'
import mix from '../../util/mixin'
import * as PlotUtils from '../utils/plot_util'

export default class Curve extends mix(Plot, LineString) {

    constructor(points) {
        super(points);
        this.type = PlotTypes.CURVE;
        this.t = 0.3;
        this.setPoints(points);
    }
    generate() {
        var count = this.getPointCount();
        if (count < 2) {
            return;
        }
        if (count == 2) {
            this.setCoordinates(this.points);
        } else {
            this.setCoordinates(PlotUtils.getCurvePoints(this.t, this.points));
        }


    }
}