if (mergedTimeRefIndex != null){
refTimeIndex = mergedTimeRefIndex.intValue();
}
Object o = settings.get(DATA_TO_MERGE + "_" + refTimeIndex);
DataSource mergedTimeReferenceDs = null;
if (o instanceof TimeStampedDataSource){
mergedTimeReferenceDs = ((TimeStampedDataSource)o).getTime();
} else if (o instanceof TimeStampedDataSourceCollection){
// we take the fisrt TimeSource
mergedTimeReferenceDs = ((TimeStampedDataSource)((TimeStampedDataSourceCollection)o).get(0)).getTime();
} else {
mergedTimeReferenceDs = (DataSource)settings.get(TIME_REFERENCE + "_" + refTimeIndex);
}
double offset = ((Double)settings.get(TIME_REFERENCE_OFFSET + "_" + refTimeIndex)).doubleValue();
boolean refTimeIsRelative = false;
if ( settings.get(TIME_REFERENCE_IS_RELATIVE + "_" + refTimeIndex)!=null){
refTimeIsRelative = ((Boolean)settings.get(TIME_REFERENCE_IS_RELATIVE + "_" + refTimeIndex)).booleanValue();
}
long initialDate = 0;
if ( settings.get(TIME_REFERENCE_INITIAL_DATE + "_" + refTimeIndex)!=null) {
initialDate = ((Long)settings.get(TIME_REFERENCE_INITIAL_DATE + "_" + refTimeIndex)).longValue();
}
try {
ret= new JSSynchronousMergeDSCollection(
collectionName,
interpolationOrder,
collectionTimeReferenceIsRelative,
mergedTimeReferenceDs,
refTimeIsRelative,
offset,
initialDate);
} catch (MergeDataException e) {
ret = null;
}
}
if (ret != null) {
// Add data to merge collection
for(int i=0;i<numberOfAddedData;i++) {
try{
Object o = settings.get(DATA_TO_MERGE + "_" + i);
double offset = ((Double)settings.get(TIME_REFERENCE_OFFSET + "_" + i)).doubleValue();
boolean refTimeIsRelative = false;
if ( settings.get(TIME_REFERENCE_IS_RELATIVE + "_" + i)!=null)
refTimeIsRelative = ((Boolean)settings.get(TIME_REFERENCE_IS_RELATIVE + "_" + i)).booleanValue();
long initialDate = 0;
if ( settings.get(TIME_REFERENCE_INITIAL_DATE + "_" + i)!=null)
initialDate = ((Long)settings.get(TIME_REFERENCE_INITIAL_DATE + "_" + i)).longValue();
if (o instanceof DataSourceCollection){
if (o instanceof TimeStampedDataSourceCollection){
ret.add((TimeStampedDataSourceCollection)o, offset,initialDate);
}else{
// get synchronous parameters
DataSource refTime = (DataSource)settings.get(TIME_REFERENCE + "_" + i);
ret.add((DataSourceCollection)o, refTime, refTimeIsRelative,offset, initialDate);
}
} else{
if (o instanceof TimeStampedDataSource){
ret.add((TimeStampedDataSource)o, offset, initialDate);
}else{
// get synchronous parameters
DataSource refTime = (DataSource)settings.get(TIME_REFERENCE + "_" + i);
ret.add((DataSource)o, refTime, refTimeIsRelative, offset, initialDate);
}
}
} catch(MergeDataException e) {
}