You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The DatastreamParser currently does NOT support parsing Datastream resources in SWE Common format, despite the assessment claiming "Schema extraction from SWE" support. When attempting to parse Datastream data in SWE format, the parser throws an error: "SWE format not applicable for Datastream resources". This prevents extraction of observation schemas from SWE DataRecord/DataStream definitions, limiting the parser's ability to handle sensor data definitions encoded in SWE Common.
Current Behavior:
exportclassDatastreamParserextendsCSAPIParser<DatastreamFeature>{parseGeoJSON(data: Feature|FeatureCollection): DatastreamFeature{// ✅ Works}parseSensorML(data: Record<string,unknown>): DatastreamFeature{thrownewCSAPIParseError('Datastreams not defined in SensorML format');}parseSWE(data: Record<string,unknown>): DatastreamFeature{thrownewCSAPIParseError('SWE format not applicable for Datastream resources');// ❌ THROWS ERROR - Should extract schema}}
Expected Behavior:
parseSWE() should extract schema information from SWE Common DataStream or DataRecord definitions
Should convert SWE schema to GeoJSON Feature with schema properties
Should handle nested SWE components (DataRecord with fields, DataArray, etc.)
Context
This issue was identified during the comprehensive validation conducted January 27-28, 2026.
Validated Commit:a71706b9592cad7a5ad06e6cf8ddc41fa5387732 File:src/ogc-api/csapi/parsers/resources.ts (494 lines) Specific Commit:e83292af5bb7933793bb5e95aab43ffb33431904
Current Test Coverage:
Total parser tests: 166 (31 base + 79 resources + 56 swe-common)
DatastreamParser tests: 3 (all GeoJSON format)
No SWE format tests for Datastream
Detailed Findings
1. Assessment Claim vs. Reality
From Validation Report - Parser Classes Matrix:
Parser
GeoJSON
SensorML
SWE
Notes
DatastreamParser
✅
❌
⚠️
Claimed: "Schema extraction from SWE" Actual: Throws error "not applicable"
Validation Verdict:⚠️PARTIALLY CONFIRMED
Evidence from Validation Report:
✅ DatastreamParser (GeoJSON ✓, SensorML ✗, SWE ✗)
Verdict:⚠️PARTIALLY CONFIRMED - Assessment claims SWE support, but code says "not applicable"
Evidence from resources.ts:
exportclassDatastreamParserextendsCSAPIParser<DatastreamFeature>{parseGeoJSON(data: Feature|FeatureCollection): DatastreamFeature{if(data.type==='FeatureCollection'){thrownewCSAPIParseError('Expected single Feature, got FeatureCollection');}returndataasDatastreamFeature;}parseSensorML(data: Record<string,unknown>): DatastreamFeature{thrownewCSAPIParseError('Datastreams not defined in SensorML format');}parseSWE(data: Record<string,unknown>): DatastreamFeature{thrownewCSAPIParseError('SWE format not applicable for Datastream resources');}}
✅ GeoJSON parsing works
❌ DISCREPANCY: Assessment claims SWE support ("Schema extraction from SWE"), but implementation throws error ⚠️ This appears to be a TODO or future feature not yet implemented
2. What SWE Format Support Should Provide
OGC API - Connected Systems defines Datastreams with schema information that describes the structure of observations. In SWE Common format, this schema is represented as:
DataStream Component - Top-level SWE DataStream with:
elementType: DataRecord or other component describing observation structure
encoding: How data is encoded (TextEncoding, BinaryEncoding, JSONEncoding)
We just need to integrate this into DatastreamParser.parseSWE()!
4. Use Cases That Are Currently Broken
Scenario 1: Fetching Datastream schema from CSAPI server
// User wants to understand what fields are in a datastreamconstresponse=awaitfetch('https://api.example.com/datastreams/temp-humidity',{headers: {'Accept': 'application/swe+json'}});constdatastreamParser=newDatastreamParser();constresult=datastreamParser.parse(awaitresponse.json());// ❌ THROWS: "SWE format not applicable for Datastream resources"// ✅ SHOULD: Return GeoJSON Feature with schema information
Scenario 2: Converting SWE schema to GeoJSON for storage
// User wants to store SWE schema in GeoJSON-based databaseconstsweSchema={/* SWE DataStream definition */};constdatastreamParser=newDatastreamParser();constgeojsonFeature=datastreamParser.parseSWE(sweSchema);// ❌ THROWS: "SWE format not applicable for Datastream resources"// ✅ SHOULD: Return GeoJSON Feature with schema as properties
Scenario 3: Building observation submission client
// User needs to know what fields to submit for observationsconstschema=awaitgetDatastreamSchema(datastreamId);constfields=schema.properties.schema.fields;// ❌ FAILS: Cannot parse SWE schema// ✅ SHOULD: Get field list with types and constraints
5. Impact on Users
Why This Matters:
Schema Discovery: Users cannot programmatically discover observation schema from SWE definitions
Format Interoperability: Cannot convert between SWE and GeoJSON representations
Client Development: Building observation submission clients requires manual schema parsing
Validation: Cannot validate observations against SWE schema without parsing it first
Documentation Generation: Cannot auto-generate documentation from SWE schema
Incomplete Implementation: Assessment claims SWE support but it doesn't exist
Current Workarounds:
Parse SWE format manually using swe-common-parser.ts functions directly
Only use GeoJSON format for Datastreams (requires server support)
Hardcode schema information instead of extracting from SWE
Proposed Solution
1. Implement DatastreamParser.parseSWE()
Update resources.ts DatastreamParser:
import{parseDataStreamComponent,parseDataRecordComponent,parseDataComponent}from'./swe-common-parser.js';exportclassDatastreamParserextendsCSAPIParser<DatastreamFeature>{parseGeoJSON(data: Feature|FeatureCollection): DatastreamFeature{if(data.type==='FeatureCollection'){thrownewCSAPIParseError('Expected single Feature, got FeatureCollection');}returndataasDatastreamFeature;}parseSensorML(data: Record<string,unknown>): DatastreamFeature{thrownewCSAPIParseError('Datastreams not defined in SensorML format');}parseSWE(data: Record<string,unknown>): DatastreamFeature{try{// Parse SWE DataStream or DataRecord componentletparsedComponent: any;if(data.type==='DataStream'){parsedComponent=parseDataStreamComponent(data);}elseif(data.type==='DataRecord'){// Some servers may return DataRecord directly as schemaparsedComponent=parseDataRecordComponent(data);}else{// Try generic component parserparsedComponent=parseDataComponent(data);}// Extract schema informationconstproperties: Record<string,unknown>={featureType: 'Datastream',definition: parsedComponent.definition,name: parsedComponent.label,description: parsedComponent.description,schema: this.extractSchema(parsedComponent),};// Add encoding information if presentif('encoding'inparsedComponent&&parsedComponent.encoding){properties.encoding=parsedComponent.encoding;}// Add elementCount if present (for DataStream)if('elementCount'inparsedComponent&&parsedComponent.elementCount!==undefined){properties.elementCount=parsedComponent.elementCount;}// Build GeoJSON Featurereturn{type: 'Feature',id: (parsedComponentasany).id||(parsedComponentasany).uniqueId,geometry: null,// Datastreams don't have geometry
properties,}asunknownasDatastreamFeature;}catch(error){if(errorinstanceofError){thrownewCSAPIParseError(`Failed to parse SWE Datastream schema: ${error.message}`,'swe',error);}throwerror;}}/** * Extract schema structure from SWE component * Handles DataStream (with elementType) and DataRecord (with fields) */privateextractSchema(component: any): Record<string,unknown>{constschema: Record<string,unknown>={type: component.type,definition: component.definition,label: component.label,};// For DataStream, extract elementType schemaif(component.type==='DataStream'&&component.elementType){schema.elementType=this.extractSchema(component.elementType);}// For DataRecord, extract field schemasif(component.type==='DataRecord'&&component.fields){schema.fields=component.fields.map((field: any)=>({name: field.name,definition: field.component?.definition,label: field.component?.label,type: field.component?.type,uom: field.component?.uom,constraint: field.component?.constraint,}));}// For DataArray, extract elementTypeif(component.type==='DataArray'){schema.elementCount=component.elementCount;if(component.elementType){schema.elementType=this.extractSchema(component.elementType);}}// For Vector, extract coordinatesif(component.type==='Vector'&&component.coordinates){schema.referenceFrame=component.referenceFrame;schema.coordinates=component.coordinates.map((coord: any)=>({name: coord.name,component: {type: coord.component?.type,definition: coord.component?.definition,label: coord.component?.label,uom: coord.component?.uom,},}));}// Add UoM for quantity-based componentsif('uom'incomponent&&component.uom){schema.uom=component.uom;}// Add constraint informationif('constraint'incomponent&&component.constraint){schema.constraint=component.constraint;}returnschema;}}
Key Implementation Details:
Leverage Existing Parser: Use parseDataStreamComponent() and parseDataRecordComponent() from swe-common-parser.ts
Handle Multiple Input Types: Support DataStream, DataRecord, or generic component
Handle both DataStream (with elementType) and DataRecord (with fields)
Error Handling Pattern:
try{constparsedComponent=parseDataStreamComponent(data);// ... conversion ...}catch(error){if(errorinstanceofError){thrownewCSAPIParseError(`Failed to parse SWE Datastream schema: ${error.message}`,'swe',error);}throwerror;}
Problem
The
DatastreamParsercurrently does NOT support parsing Datastream resources in SWE Common format, despite the assessment claiming "Schema extraction from SWE" support. When attempting to parse Datastream data in SWE format, the parser throws an error:"SWE format not applicable for Datastream resources". This prevents extraction of observation schemas from SWE DataRecord/DataStream definitions, limiting the parser's ability to handle sensor data definitions encoded in SWE Common.Current Behavior:
Expected Behavior:
parseSWE()should extract schema information from SWE Common DataStream or DataRecord definitionsContext
This issue was identified during the comprehensive validation conducted January 27-28, 2026.
Related Validation Issues: #10 - Validate: Multi-Format Parsers
Work Item ID: 26 from Remaining Work Items
Repository: https://github.com/OS4CSAPI/ogc-client-CSAPI
Validated Commit:
a71706b9592cad7a5ad06e6cf8ddc41fa5387732File:
src/ogc-api/csapi/parsers/resources.ts(494 lines)Specific Commit:
e83292af5bb7933793bb5e95aab43ffb33431904Current Test Coverage:
Detailed Findings
1. Assessment Claim vs. Reality
From Validation Report - Parser Classes Matrix:
Actual: Throws error "not applicable"
Validation Verdict:⚠️ PARTIALLY CONFIRMED
Evidence from Validation Report:
2. What SWE Format Support Should Provide
OGC API - Connected Systems defines Datastreams with schema information that describes the structure of observations. In SWE Common format, this schema is represented as:
DataStream Component - Top-level SWE DataStream with:
elementType: DataRecord or other component describing observation structureencoding: How data is encoded (TextEncoding, BinaryEncoding, JSONEncoding)values: The actual observation dataDataRecord Component - Describes observation structure with:
fields: Array of field definitions (Quantity, Count, Text, etc.)Example SWE DataStream:
{ "type": "DataStream", "definition": "http://example.org/datastreams/temperature-humidity", "label": "Temperature and Humidity Observations", "elementType": { "type": "DataRecord", "definition": "http://example.org/observation-schema", "label": "Observation", "fields": [ { "name": "timestamp", "component": { "type": "Time", "definition": "http://www.opengis.net/def/property/OGC/0/SamplingTime", "label": "Sampling Time", "uom": { "code": "http://www.opengis.net/def/uom/ISO-8601/0/Gregorian" } } }, { "name": "temperature", "component": { "type": "Quantity", "definition": "http://example.org/def/temperature", "label": "Temperature", "uom": { "code": "Cel" } } }, { "name": "humidity", "component": { "type": "Quantity", "definition": "http://example.org/def/humidity", "label": "Relative Humidity", "uom": { "code": "%" } } } ] }, "encoding": { "type": "JSONEncoding" } }What
parseSWE()should do:elementType(DataRecord or other component)3. Existing SWE Common Parser Infrastructure
Good News: The codebase already has a comprehensive SWE Common parser!
From Validation Report - Bonus Discovery:
This means we can leverage existing infrastructure:
parseDataStreamComponent()already existsparseDataRecordComponent()handles nested fieldsWe just need to integrate this into
DatastreamParser.parseSWE()!4. Use Cases That Are Currently Broken
Scenario 1: Fetching Datastream schema from CSAPI server
Scenario 2: Converting SWE schema to GeoJSON for storage
Scenario 3: Building observation submission client
5. Impact on Users
Why This Matters:
Current Workarounds:
swe-common-parser.tsfunctions directlyProposed Solution
1. Implement DatastreamParser.parseSWE()
Update
resources.tsDatastreamParser:Key Implementation Details:
parseDataStreamComponent()andparseDataRecordComponent()fromswe-common-parser.tsextractSchema()helper handles nested structures2. Add Comprehensive Tests
Add to
resources.spec.ts:Test Coverage Goals:
3. Update Documentation
Add JSDoc to parseSWE():
Acceptance Criteria
DatastreamParser.parseSWE()successfully parses SWE DataStream componentsDatastreamParser.parseSWE()successfully parses SWE DataRecord components (direct schema)Implementation Notes
Files to Modify
src/ogc-api/csapi/parsers/resources.ts(494 lines):DatastreamParser.parseSWE()methodextractSchema()private helper methodswe-common-parser.tssrc/ogc-api/csapi/parsers/resources.spec.ts:Dependencies
Imports Required:
Existing Infrastructure to Leverage:
swe-common-parser.ts- Comprehensive SWE parser (540 lines, 56 tests)parseDataStreamComponent()- Handles DataStream with validationparseDataRecordComponent()- Handles nested fields recursivelyparseDataComponent()- Generic component dispatcherCode Patterns to Follow
Schema Extraction Pattern:
Error Handling Pattern:
Feature Structure:
Testing Requirements
Test Categories:
Basic Parsing (2 tests):
Nested Structures (2 tests):
Complex ElementTypes (2 tests):
Metadata Preservation (2 tests):
Error Handling (1 test):
Integration Testing:
Special Considerations
DataStream vs DataRecord:
elementTypeproperty (schema for observations)Encoding Information:
Schema Depth:
Constraint Information:
Compatibility:
src/ogc-api/csapi/types/geojson/datastream.tsPriority Justification
Priority Level: Low
Why Low Priority:
swe-common-parser.tsfunctions directlyShould Be Higher Priority If:
Dependencies:
swe-common-parser.tsinfrastructure (already exists)Quick Win Analysis:
swe-common-parser.ts)Effort Estimate: 3-4 hours
Risk of Not Implementing:
When This Should Be Prioritized:
Labels:
priority: lowenhancementparserswe-formattodoEstimated Effort: 3-4 hours
Related Work Items: #27 (ControlStream SWE support)
Depends On: None
Blocks: None