RtcmMsmGalileoHeader.java

/* Copyright 2022-2026 Thales Alenia Space
 * Licensed to CS GROUP (CS) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * CS licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.orekit.gnss.metric.messages.rtcm.msm.headers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.orekit.gnss.SatInSystem;
import org.orekit.gnss.SatelliteSystem;

/**
 * RTCM MSM header for Galileo observations.
 * @author Nathan Schiffmacher
 * @since 14.0
 */
public class RtcmMsmGalileoHeader extends RtcmMsmHeader {

    /** Mapping of RTCM MSM signal identifiers to Galileo MSM signal IDs. */
    private static final Map<Integer, RtcmMsmSignalId> SIGNAL_ID_MAP = new HashMap<>();
    static {
        // Reserved IDs are not mapped
        SIGNAL_ID_MAP.put( 2, RtcmMsmSignalId.GAL_1C);
        SIGNAL_ID_MAP.put( 3, RtcmMsmSignalId.GAL_1A);
        SIGNAL_ID_MAP.put( 4, RtcmMsmSignalId.GAL_1B);
        SIGNAL_ID_MAP.put( 5, RtcmMsmSignalId.GAL_1X);
        SIGNAL_ID_MAP.put( 6, RtcmMsmSignalId.GAL_1Z);
        SIGNAL_ID_MAP.put( 8, RtcmMsmSignalId.GAL_6C);
        SIGNAL_ID_MAP.put( 9, RtcmMsmSignalId.GAL_6A);
        SIGNAL_ID_MAP.put(10, RtcmMsmSignalId.GAL_6B);
        SIGNAL_ID_MAP.put(11, RtcmMsmSignalId.GAL_6X);
        SIGNAL_ID_MAP.put(12, RtcmMsmSignalId.GAL_6Z);
        SIGNAL_ID_MAP.put(14, RtcmMsmSignalId.GAL_7I);
        SIGNAL_ID_MAP.put(15, RtcmMsmSignalId.GAL_7Q);
        SIGNAL_ID_MAP.put(16, RtcmMsmSignalId.GAL_7X);
        SIGNAL_ID_MAP.put(18, RtcmMsmSignalId.GAL_8I);
        SIGNAL_ID_MAP.put(19, RtcmMsmSignalId.GAL_8Q);
        SIGNAL_ID_MAP.put(20, RtcmMsmSignalId.GAL_8X);
        SIGNAL_ID_MAP.put(22, RtcmMsmSignalId.GAL_5I);
        SIGNAL_ID_MAP.put(23, RtcmMsmSignalId.GAL_5Q);
        SIGNAL_ID_MAP.put(24, RtcmMsmSignalId.GAL_5X);
    }

    /** {@inheritDoc} */
    @Override
    public List<SatInSystem> convertSatellitesMask() {
        final List<SatInSystem> satellites = new ArrayList<>();
        for (int satId = 1; satId <= 64; satId++) {
            if ((this.getSatellitesMask() >> (64 - satId) & 1) == 1) {
                // IDs 51 & 52 are for GIOVE-A and B
                // IDs 53-64 are reserved
                satellites.add(new SatInSystem(SatelliteSystem.GALILEO, satId < 53 ? satId : -1));
            }
        }
        return satellites;
    }

    /** {@inheritDoc} */
    @Override
    public List<RtcmMsmSignalId> convertSignalsMask() {
        final List<RtcmMsmSignalId> signals = new ArrayList<>();
        for (int signalId = 1; signalId <= 32; signalId++) {
            if ((this.getSignalsMask() >> (32 - signalId) & 1) == 1) {
                signals.add(SIGNAL_ID_MAP.getOrDefault(signalId, RtcmMsmSignalId.RESERVED));
            }
        }
        return signals;
    }

}