CasterRecord.java

  1. /* Copyright 2002-2024 CS GROUP
  2.  * Licensed to CS GROUP (CS) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * CS licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *   http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.orekit.gnss.metric.ntrip;

  18. import org.hipparchus.util.FastMath;

  19. /** Caster record in source table.
  20.  * @author Luc Maisonobe
  21.  * @since 11.0
  22.  */
  23. public class CasterRecord extends Record {

  24.     /** Port number. */
  25.     private final int port;

  26.     /** Fallback port number. */
  27.     private final int fallbackPort;

  28.     /** Indicator for NMEA reception. */
  29.     private final boolean canReceiveNMEA;

  30.     /** Latitude (rad). */
  31.     private final double latitude;

  32.     /** Longitude (rad). */
  33.     private final double longitude;

  34.     /** Build a caster record by parsing a source table line.
  35.      * @param line source table line
  36.      */
  37.     public CasterRecord(final String line) {
  38.         super(line);
  39.         this.port           = Integer.parseInt(getField(2));
  40.         this.canReceiveNMEA = Integer.parseInt(getField(5)) != 0;
  41.         this.latitude       = FastMath.toRadians(Double.parseDouble(getField(7)));
  42.         this.longitude      = FastMath.toRadians(Double.parseDouble(getField(8)));
  43.         this.fallbackPort   = Integer.parseInt(getField(10));
  44.     }

  45.     /** {@inheritDoc} */
  46.     @Override
  47.     public RecordType getRecordType() {
  48.         return RecordType.CAS;
  49.     }

  50.     /** Get the host or IP address.
  51.      * @return host or IP address
  52.      */
  53.     public String getHostOrIPAddress() {
  54.         return getField(1);
  55.     }

  56.     /** Get the port number.
  57.      * @return port number
  58.      */
  59.     public int getPort() {
  60.         return port;
  61.     }

  62.     /** Get the source identifier.
  63.      * @return source identifier
  64.      */
  65.     public String getSourceIdentifier() {
  66.         return getField(3);
  67.     }

  68.     /** Get the institution/agency/company operating the caster.
  69.      * @return institution/agency/company operating the caster
  70.      */
  71.     public String getOperator() {
  72.         return getField(4);
  73.     }

  74.     /** Check if caster can receive NMEA messages.
  75.      * @return true if caster can receive NMEA messages
  76.      */
  77.     public boolean canReceiveNMEA() {
  78.         return canReceiveNMEA;
  79.     }

  80.     /** Get the country.
  81.      * @return country
  82.      */
  83.     public String getCountry() {
  84.         return getField(6);
  85.     }

  86.     /** Get the latitude.
  87.      * @return latitude (rad)
  88.      */
  89.     public double getLatitude() {
  90.         return latitude;
  91.     }

  92.     /** Get the longitude.
  93.      * @return longitude (rad)
  94.      */
  95.     public double getLongitude() {
  96.         return longitude;
  97.     }

  98.     /** Get the fallback host or IP address.
  99.      * @return fallback host or IP address
  100.      */
  101.     public String getFallbackHostOrIPAddress() {
  102.         return getField(9);
  103.     }

  104.     /** Get the fallback port number.
  105.      * @return fallback port number
  106.      */
  107.     public int getFallbackPort() {
  108.         return fallbackPort;
  109.     }

  110. }