Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nonscalar parsing #26

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from
Open

Add nonscalar parsing #26

wants to merge 3 commits into from

Conversation

dkirkeby
Copy link
Collaborator

No description provided.

@dkirkeby dkirkeby requested a review from intarga August 13, 2024 08:29
@intarga
Copy link
Member

intarga commented Aug 13, 2024

@dkirkeby please provide an explanation of this PR.

Also please rebase it, your branch is out of date and has conflicts. Conflicts should ideally be solved before code review.

Comment on lines -74 to +119
let station_id = parse_meta_field(parts.next().ok_or_else(next_err)?, "nationalnr")?;
let type_id = parse_meta_field(parts.next().ok_or_else(next_err)?, "type")?;
let message_id = parse_meta_field(parts.next().ok_or_else(next_err)?, "messageid")?;
let mut header = ObsinnHeader::default();
for field in parts.by_ref() {
if field.starts_with("nationalnr") {
header.station_id = parse_meta_field(field)?;
continue;
}
if field.starts_with("type") {
header.type_id = parse_meta_field(field)?;
continue;
}
if field.starts_with("messageid") {
header.message_id = parse_meta_field(field)?;
continue;
}
if field.starts_with("add") {
// NOTE: this field has to do with data deletion/update in kvalobs, we do not use it
header.add = true;
continue;
}
if field.starts_with("received_time") {
header.received_time = Some(parse_meta_field(field)?);
continue;
}
return Err(Error::Parse(format!(
"unexpected field in kldata header format: {field}",
)));
}

if header.station_id == 0 {
return Err(Error::Parse(
"missing field `nationalnr` in kldata header".to_string(),
));
}

// TODO: type_id == 0 is present in stinfosys, so might be a bit dangerous to use here
if header.type_id == 0 {
return Err(Error::Parse(
"missing field `type` in kldata header".to_string(),
));
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote this part, but it shouldn't really be a thing. I need to speak with Søren again, there's no way the fields in the header can come in any order

@dkirkeby dkirkeby changed the title Added nonscalar parsing Add nonscalar parsing Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants