Skip to content

Commit

Permalink
Merge pull request #335 from NOAA-OWP/issue334
Browse files Browse the repository at this point in the history
Fix a transposition error in the retrieval of baseline time-series fr…
  • Loading branch information
james-d-brown authored Oct 10, 2024
2 parents 574dd54 + 1484abc commit 4b4cdd1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public Supplier<Stream<TimeSeries<Ensemble>>> getBaselineRetriever( Set<Feature>
.setMeasurementUnitsCache( this.getMeasurementUnitsCache() )
.setProjectId( this.project.getId() )
.setFeatures( features )
.setVariable( this.project.getRightVariable() )
.setVariable( this.project.getBaselineVariable() )
.setDatasetOrientation( DatasetOrientation.BASELINE )
.setDeclaredExistingTimeScale( this.getDeclaredExistingTimeScale( baselineDataset ) )
.setDesiredTimeScale( this.desiredTimeScale )
Expand Down
12 changes: 7 additions & 5 deletions wres-reading/src/wres/reading/wrds/geography/FeatureFiller.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,11 @@ private static EvaluationDeclaration fillFeatures( EvaluationDeclaration evaluat
// Set the features and feature groups, preserving any declared offsets, but using the new tuples
Map<GeometryTuple, Offset> singletonOffsets = null;
Map<GeometryTuple, Offset> groupOffsets = null;
if ( Objects.nonNull( evaluation.features()
.offsets() ) )
{

if ( Objects.nonNull( evaluation.features() )
&& Objects.nonNull( evaluation.features()
.offsets() ) )
{
singletonOffsets = FeatureFiller.getOffsets( filledSingletonFeatures, evaluation.features()
.offsets() );
}
Expand Down Expand Up @@ -346,8 +347,9 @@ private static Set<GeometryTuple> fillSingletonFeatures( EvaluationDeclaration e
Set<GeometryTuple> consolidatedFeatures = new HashSet<>( filledFeatures );

// Add any implicitly declared features
if ( Objects.nonNull( featureService ) && !featureService.featureGroups()
.isEmpty() )
if ( Objects.nonNull( featureService )
&& !featureService.featureGroups()
.isEmpty() )
{
LOGGER.debug( "Discovered implicitly declared singleton features." );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;

import wres.config.yaml.components.BaselineDataset;
Expand All @@ -26,6 +27,7 @@
import wres.config.yaml.components.EvaluationDeclaration;
import wres.config.yaml.components.EvaluationDeclarationBuilder;
import wres.config.yaml.components.FeatureAuthority;
import wres.config.yaml.components.FeatureGroups;
import wres.config.yaml.components.FeatureServiceGroup;
import wres.config.yaml.components.Features;
import wres.config.yaml.components.FeaturesBuilder;
Expand Down Expand Up @@ -470,6 +472,41 @@ expectedTwo, new Offset( 0.0, 2.0, 0.0 ),
}
}

@Test
void testFillFeaturesDoesNotThrowNPEWhenNoFeaturesExistAndFeatureGroupExists() throws URISyntaxException
{
URI uri = new URI( "https://some_fake_uri" );
wres.config.yaml.components.FeatureService
featureService = new wres.config.yaml.components.FeatureService( uri, Set.of() );

EvaluationDeclaration evaluation
= FeatureFillerTest.getBoilerplateEvaluationWith( null,
featureService,
BOILERPLATE_DATASOURCE_USGS_SITE_CODE_AUTHORITY,
BOILERPLATE_DATASOURCE_NWS_LID_AUTHORITY,
null );

// Add a feature group
GeometryGroup group =
GeometryGroup.newBuilder()
.addAllGeometryTuples( Set.of( GeometryTuple.newBuilder()
.setLeft( Geometry.newBuilder()
.setName( "bar" ) )
.setRight( Geometry.newBuilder()
.setName( "baz" ) )
.build() ) )
.setRegionName( "AL" )
.build();

FeatureGroups groups = new FeatureGroups( Set.of( group ), null );
EvaluationDeclaration adjusted = EvaluationDeclarationBuilder.builder( evaluation )
.features( null )
.featureGroups( groups )
.build();

assertDoesNotThrow( () -> FeatureFiller.fillFeatures( adjusted ) );
}

/**
* Generates a boilerplate evaluation declaration with the inputs.
* @param features the features
Expand Down

0 comments on commit 4b4cdd1

Please sign in to comment.