/** * Create an instance of {@link SpatioTemporalSegment } * */ public SpatioTemporalSegment createSpatioTemporalSegment() { return new SpatioTemporalSegment(); }
/** * To be included SpatioTemporal segments should be at the same timestamp in addition to ashape comparison. * * @param theSegment * Segment to test "be include" by <code>inThisSegment</code> * @param inThisSegment * Segment to test "includes" <code>theSegment</code> * @return <code>false</code> <code>theSegment</code> isn't included in <code>inThisSegment</code>. <code>true</code> if they are included. */ private static boolean isIncludedSpatioTemporalSegment(final SpatioTemporalSegment theSegment, final SpatioTemporalSegment inThisSegment) { if (theSegment.getTimestamp() == inThisSegment.getTimestamp()) { return SegmentUtil.isIncludedCoordinate(theSegment.getCoordinate(), inThisSegment.getCoordinate()); } return false; }
/** * @param track * The track segment in which to add a spatio temporal * @param timestamp * The index of the <code>Segment</code> start * @param shape * An array of int containing coordinates to be affected to this segment. The smallest array is <code>{x1, y1, x2, y2}</code>. In this case * coordinate 1 (x1;y1) is the centre of a disk, where coordinate 2 (x2;y2) is a point of the border. When shape contains more than tree * coordinates, it defines a closed polygon. * @return The newly created <code>SpatioTemporalSegment</code> */ public final static SpatioTemporalSegment createAndLinkSpatioTemporalSegment(final TrackSegment track, final int timestamp, final int... shape) { final List<Coordinate> coordinates = SegmentFactory.checkAndcreateCoordinates(track, shape); final SpatioTemporalSegment theSeg = SegmentFactory.createAndLinkSegment(track, SpatioTemporalSegment.class); theSeg.setTimestamp(timestamp); theSeg.getCoordinate().addAll(coordinates); return theSeg; }
/** * Creates a <code>SpatioTemporalSegment</code> at <code>timestamp</code>. A best practice is that timestamp is expressed in millisecond. * * @param mu * The <code>MediaUnit</code> containing the <code>Segment</code> * @param timestamp * index of the <code>Segment</code> start * @param shape * An array of int containing coordinates to be affected to this segment. The smallest array is <code>{x1, y1, x2, y2}</code>. In this case * coordinate 1 (x1;y1) is the center of a disk, where coodinate 2 (x2;y2) is a point of the border. When shape contains more than tree * coordinates, it defines a closed polygon. * @return The newly created <code>SpatioTemporalSegment</code> */ public final static SpatioTemporalSegment createAndLinkSpatioTemporalSegment(final MediaUnit mu, final int timestamp, final int... shape) { final List<Coordinate> coordinates = SegmentFactory.checkAndcreateCoordinates(mu, shape); final SpatioTemporalSegment theSeg = SegmentFactory.createAndLinkSegment(mu, SpatioTemporalSegment.class); theSeg.setTimestamp(timestamp); theSeg.getCoordinate().addAll(coordinates); return theSeg; }
final SpatioTemporalSegment stSeg1 = (SpatioTemporalSegment) seg1; final SpatioTemporalSegment stSeg2 = (SpatioTemporalSegment) seg2; final int timestampComparison = Integer.signum(stSeg1.getTimestamp() - stSeg2.getTimestamp()); return this.compareCoordinates(stSeg1.getCoordinate(), stSeg2.getCoordinate());