Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Calculate gradient and azimuth of a profile.

Aperta
#8,565 5 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Esteban82 ci sta già lavorando.

Dal 12/8/2024.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

feature request

For the work I am going to present at the AGU I made a small software (in C) that from a profile (with XYZ data) calculates the intermediate position between two successive data (Xm, Ym), and gradient and azimuth (Xm, Ym, Az, Grad). This way I can use it as input for greenspline (-A+f2). I think it would be nice to add it as a feature for GMT.

What do you think? My idea is to do it but I probably need help.

I think it should be added as a new argument for mapproject? Do you agree? What letter should I use?

This is the code:

#include <math.h>
#include <stdio.h>

int main() {
    // Definir los nombres de los archivos de entrada y salida
    const char* trackFileName = "Bad_Track";
    const char* outFileName = "Track_Gradient.txt";

    // Abrir los archivos de entrada y salida
    FILE *trackFile = fopen(trackFileName, "r");
    FILE *outFile = fopen(outFileName, "w");

    if (trackFile == NULL || outFile == NULL) {
        perror("Error al abrir archivos");
        return 1;
    }

    // Variables para almacenar los puntos medios
    double Xm, Ym, DX, DY, DZ, Distance, Gradient, Azimuth, Radianes;

    // Variables para leer las coordenadas de cada línea
    double x1, y1, z1, x2, y2, z2;

    // Leer las coordenadas de la primera línea
    if (fscanf(trackFile, "%lf %lf %lf", &x1, &y1, &z1 ) != 3) {
        perror("Error al leer el archivo de entrada");
        return 1;
    }

    // Loop para procesar cada línea
    while (fscanf(trackFile, "%lf %lf %lf" , &x2, &y2, &z2) == 3) {
        // 1. Calcular el punto medio
        Xm = (x1 + x2) / 2.0;
        Ym = (y1 + y2) / 2.0;

        // 2. Gradiente
        DX= (x2-x1);
        DY= (y2-y1);
        Distance= sqrt(pow(DX, 2) + pow(DY, 2));
        DZ = (z2-z1);
        Gradient= (DZ / Distance);
       
        // 3. Azimuth
        Radianes = atan2 (DX, DY);
        Azimuth = fmod ((Radianes * (180/M_PI)+360),360);
        //Azimuth = fmod (Azimuth * (180 /  M_PI) + 180, 360);

        // Escribir el punto medio en el archivo de salida
        fprintf(outFile, "%.2f %.2f %.5f %.4f\n", Xm, Ym, Gradient, Azimuth);

        // Actualizar las coordenadas anteriores
        x1 = x2;
        y1 = y2;
        z1 = z2;
    }

    // Cerrar los archivos
    fclose(trackFile);
    fclose(outFile);

    printf("Proceso completado con éxito.\n");

    return 0;
}
Lingua principale
C
Stelle
984
Fork
413
Merge medio
21h 18m
PR unite (30g)
39

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GenericMappingTools/gmt

Tutte le issue di GenericMappingTools/gmt

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.