@Override public double calcIntensity(Timestamp from, Timestamp to, int fileIndex) throws Exception { int arrayStart = 0; int arrayEnd = 0; RawData tempRawData = rawData.get(fileIndex); while (tempRawData.getTimestamps()[arrayStart] != from) { arrayStart++; } // Search for the Start-Index in DataArray while (tempRawData.getTimestamps()[arrayEnd] != to) { arrayEnd++; } // Search for the End-Index in DataArra int count = 1; int sampleCounter = 0; int verschiebungsfaktor = 25; int startpunkt = findPointOfMinMov(arrayStart, (arrayStart + verschiebungsfaktor), fileIndex); int endpunkt; while (startpunkt + verschiebungsfaktor < arrayEnd) { endpunkt = findPointOfMinMov(startpunkt + 1, (startpunkt + verschiebungsfaktor), fileIndex); // logger.debug("startpunkt: " + startpunkt); // logger.debug("endpunkt: " + endpunkt); sampleCounter += endpunkt - startpunkt; // logger.debug("Stepsize "+ (endpunkt-startpunkt)); count++; arrayStart = endpunkt; startpunkt = endpunkt; // logger.debug(count); // logger.debug("Samplecounter "+sampleCounter); } if (arrayStart + verschiebungsfaktor > arrayEnd && arrayStart < arrayEnd) { endpunkt = findPointOfMinMov(startpunkt + 1, arrayEnd, fileIndex); sampleCounter += endpunkt - startpunkt; count++; arrayStart = endpunkt; startpunkt = endpunkt; } // logger.debug("Samplecounter: " +sampleCounter + " count " + count); // logger.debug("DurchschnittsschrittlŠnge: "+ sampleCounter/(double)count); // logger.info("Durchschnittsgeschwindigkeit:" + (sampleCounter/(double)count)*40/1000*3.6 + // "km/h"); return -(sampleCounter / (double) count); }
public Vector<Double>[] calcIntensity() throws Exception { int fileIndex = 0; @SuppressWarnings("unchecked") Vector<Double>[] indexedReturn = new Vector[this.rawData.size()]; for (RawData raw : this.rawData) { Vector<Double> sampleReturn = new Vector<Double>(); if (raw.getSegmentStartBorders().size() != 0 && dataNormingRate != 0) { // raw.getSegmentStartBorders().size()!=0 is true if segmentation is used. for (int i = 0; i < raw.getSegmentStartBorders().size(); i++) { // Calculates and saves intensity values for all Segments Timestamp start = raw.getSegmentStartBorders().get(i); if (i == 0) { double intensity = this.calcIntensity(raw.getTimestamps()[0], start, fileIndex); sampleReturn.add((intensity)); } if (i < raw.getSegmentStartBorders().size() - 1) { Timestamp nextStart = raw.getSegmentStartBorders().get(i + 1); double intensity = this.calcIntensity(start, nextStart, fileIndex); // //DATA NORMING PART for (int y = 0; y < (nextStart.getTime() - start.getTime()) / dataNormingRate; y++) { // divided by dataNormingRate to reduce DataOutput sampleReturn.add((intensity)); } } } } else { System.out.println( "Calculation for this module not possible without segmentation and at least data norming of 1!"); } indexedReturn[fileIndex] = sampleReturn; fileIndex++; } logger.info("Stepcounter " + stepCounter); return indexedReturn; }