Extrapolate from NMEA file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cuba1@virgilio.it

    Extrapolate from NMEA file

    I have a file with thousands of these lines:

    $GPRMC,131334.0 0,A,4538.6259,N ,01021.4755,E,0 .43,0.0,021105, 1.3,E,A*0D
    $GPGGA,131334.0 0,4438.6259,N,0 1021.4755,E,1,0 0,7.8,29.8,M,40 .2,M,,*5C
    $GPRMC,131343.0 0,A,4538.6270,N ,01021.4789,E,2 .87,0.0,021105, 1.3,E,A*0F

    I must capture ONE line EVERY 10 LINES but only a block of 200 lines
    with the first columns begin with $GPGGA.

    I must to extrapolate the [column3] and the [column5]
    I must write new file with the rows like these:

    Point([column5],[column3]),
    Point([column5],[column3]),
    Point([column5],[column3]),

    and so on

    <?
    $file=file('fil e.txt');
    [FUNCTION]
    $fp = fopen("newfile. txt", "a");
    [WRITE THE CORRECT ROWS]
    fclose($fp);
    ?>

    can you help me ?

  • Samuel

    #2
    Re: Extrapolate from NMEA file

    What have you unsuccessfully tried so far?

    Greetings.

    Comment

    • cuba1@virgilio.it

      #3
      Re: Extrapolate from NMEA file

      Hi Samuel,

      thanks for your answer and sorry for my bad english.
      Up to now I have stopped myself where you have read.
      I do not have familiarity with the PHP language, but I must process the
      GPS log.
      I search someone that can help me to do this.
      thanks.
      Maggy

      Comment

      • Ian B

        #4
        Re: Extrapolate from NMEA file

        Hi Maggy,

        If I understand you correctly, then the following pseudocode might be a
        starting point

        Ian


        ////////////////////////////////////

        line_count=9 (assuming that you want the first line to count)

        Open input file
        Open output file

        Do while not EOF
        Read line from input file
        Split line into an array
        If col_1 is '$GPGGA'
        Add 1 to line_count
        If line count >9
        write data to output file
        set line_count to 0
        end if
        end if
        Loop

        At this point, if you want to capture the last record even if it's noth
        the tenth one
        if line_count <> 0 write data to output files

        Close files

        Comment

        • cuba1@virgilio.it

          #5
          Re: Extrapolate from NMEA file

          You have understand correctly the concept of my request, but now, I
          don't know how can continue and this afternoon is been born a new
          problem.
          It must add also one conversion of column 3 and 5 of $GPGGA lines:
          the value 4438.6259 will be convert in 44.38625 (latitude)

          Maggy

          Comment

          • Samuel

            #6
            Re: Extrapolate from NMEA file

            > Up to now I have stopped myself where you have read.[color=blue]
            >I do not have familiarity with the PHP language, but I must process the
            >GPS log.[/color]

            Hm, you'll need to read some things. Here's a handful of things that
            may help you. Just search for these keywords in php.net and it should
            be easy to learn some stuff and go from there...

            - file system
            - array
            - strings

            Greetings.

            Comment

            • Sergej Andrejev

              #7
              Re: Extrapolate from NMEA file

              cuba1@virgilio. it wrote:[color=blue]
              > I must capture ONE line EVERY 10 LINES but only a block of 200 lines
              > with the first columns begin with $GPGGA.
              >
              > I must to extrapolate the [column3] and the [column5]
              > I must write new file with the rows like these:[/color]

              I didn't realy understand what did you say but this is what could i
              write from Ian B pseudo-code:

              <?
              $file1 = fopen("input.tx t", "r");
              $file2 = fopen("output.t xt", "w");

              // read every line (until EOF) and split it wiht space
              while (($data = fgetcsv($file1, 1000, " ")) !== FALSE) {
              if($data[0] == '$GPGGA'){
              $row++;
              }
              if($row >= 10){
              // Write output if got more than 10 lines
              fwrite($file2, "Point($dat a[4],$data[2]\n");
              }
              }
              fclose($file1);
              fclose($file2);
              ?>

              Comment

              Working...