Examples of SegmentFunction


Examples of net.sourceforge.gpstools.math.PieceWiseFunction.SegmentFunction

        ele = null;
        final double tmin = time[0];
        final double tmax = time[n - 1];

        try {
            fLongi.addSegmentFunction(new SegmentFunction(tmin, tmax,
                    interpolator.interpolate(time, longi)));
            fLati.addSegmentFunction(new SegmentFunction(tmin, tmax,
                    interpolator.interpolate(time, lati)));
            addEle(tmin, tmax, elev);
        } catch (MathException ex) {
            throw new IllegalArgumentException(ex);
        }
View Full Code Here

Examples of net.sourceforge.gpstools.math.PieceWiseFunction.SegmentFunction

    private void addEle(double tmin, double tmax,
            SortedMap<Double, BigDecimal> elev) throws MathException {
        final int ne = elev.size();
        if (ne == 0) {
            // no elevation info
            fEle.addSegmentFunction(new SegmentFunction(tmin, tmax,
                    new ConstantFunction(BigDecimal.ZERO)));
            return;
        }
        final double ti0 = elev.firstKey().doubleValue();
        final double tin = elev.lastKey().doubleValue();
        if (elev.get(tmin) == null) {
            // elevation data missing at start
            fEle.addSegmentFunction(new SegmentFunction(tmin, ti0,
                    new ConstantFunction(elev.get(ti0))));
        }
        if (elev.get(tmax) == null) {
            // elevation data missing at end
            fEle.addSegmentFunction(new SegmentFunction(tin, tmax,
                    new ConstantFunction(elev.get(tin))));
        }
        switch (ne) {
        case 1:
            // only one point with elevation data
            // nothing more to do
            break;
        case 2:
            // two points with elevation data
            fEle.addSegmentFunction(ti0, tin,
                    new LinearFunction(ti0, elev.get(ti0).doubleValue(), tin,
                            elev.get(tin).doubleValue()));
            break;
        default:
            final double[] eleTime = new double[ne];
            final double[] eleVal = new double[ne];
            int i = 0;
            for (Double d : elev.keySet()) {
                eleTime[i] = d;
                eleVal[i] = elev.get(d).doubleValue();
                i++;
            }
            fEle.addSegmentFunction(new SegmentFunction(ti0, tin, interpolator
                    .interpolate(eleTime, eleVal)));
        }

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.