@@ -486,16 +486,28 @@ public ServiceResponse execute(Service mainService, ServiceRequest request, Serv
486486 final TableField fieldDsId = (TableField ) tDs .field (mdl .colNameDsId );
487487 final TableField fieldDsDtstDatastreamId = (TableField ) tDsDtst .field (mdl .colNameDsDtstDatastreamId );
488488 final TableField fieldDsDtstDatasetId = (TableField ) tDsDtst .field (mdl .colNameDsDtstDatasetId );
489- Record3 <Moment , Moment , Object > result = dslContext
490- .select (
491- DSL .min (tDs .field (mdl .colNameDsPhenStart , MomentBinding .dataType ())),
492- DSL .max (tDs .field (mdl .colNameDsPhenEnd , MomentBinding .dataType ())),
493- DSL .field ("ST_AsText(ST_ConvexHull(ST_Collect(?)))" , DSL .name (mdl .colNameDsObservedArea )))
494- .from (tDs )
495- .innerJoin (tDsDtst )
496- .on (fieldDsId .equal (fieldDsDtstDatastreamId ))
497- .where (fieldDsDtstDatasetId .eq (dataSetId ))
498- .fetchOne ();
489+ Record3 <Moment , Moment , Object > result ;
490+ if (dataset .getProperty (mdl .npDtstDatastreams ).isEmpty ()) {
491+ result = dslContext
492+ .select (
493+ DSL .min (tDs .field (mdl .colNameDsPhenStart , MomentBinding .dataType ())),
494+ DSL .max (tDs .field (mdl .colNameDsPhenEnd , MomentBinding .dataType ())),
495+ DSL .field ("ST_AsText(ST_ConvexHull(ST_Collect(?)))" , DSL .name (mdl .colNameDsObservedArea )))
496+ .from (tDs )
497+ .fetchOne ();
498+ } else {
499+ result = dslContext
500+ .select (
501+ DSL .min (tDs .field (mdl .colNameDsPhenStart , MomentBinding .dataType ())),
502+ DSL .max (tDs .field (mdl .colNameDsPhenEnd , MomentBinding .dataType ())),
503+ DSL .field ("ST_AsText(ST_ConvexHull(ST_Collect(?)))" , DSL .name (mdl .colNameDsObservedArea )))
504+ .from (tDs )
505+ .innerJoin (tDsDtst )
506+ .on (fieldDsId .equal (fieldDsDtstDatastreamId ))
507+ .where (fieldDsDtstDatasetId .eq (dataSetId ))
508+ .fetchOne ();
509+ }
510+
499511 if (result != null ) {
500512 Moment start = result .component1 ();
501513 Moment end = result .component2 ();
0 commit comments