Changeset 68131


Ignore:
Timestamp:
Mar 24, 2016, 7:12:07 AM (8 years ago)
Author:
mmetz
Message:

libproj: fix mixing of projection name and coordinate system name

File:
1 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/lib/proj/convert.c

    r68128 r68131  
    142142    }
    143143    G_free(proj4mod);
     144    sysname = G_find_key_value("name", proj_info);
     145    if (sysname)
     146        OSRSetProjCS(hSRS, sysname);
    144147
    145148    if ((errcode = OSRExportToWkt(hSRS, &wkt)) != OGRERR_NONE) {
     
    153156    haveparams = GPJ__get_datum_params(proj_info, &datum, &params);
    154157
    155     if(ellpskv != NULL)
     158    if (ellpskv != NULL)
    156159        ellps = G_store(ellpskv);
    157160    else
     
    279282    char *pszProj4 = NULL, *pszRemaining;
    280283    char *pszProj = NULL;
     284    const char *pszProjCS = NULL;
    281285    char *datum = NULL;
    282286    struct gpj_datum dstruct;
     
    358362            pszValue = "defined";
    359363
    360 
     364        /* projection name */
    361365        if (G_strcasecmp(pszToken, "proj") == 0) {
    362366            /* The ll projection is known as longlat in PROJ.4 */
     
    365369
    366370            pszProj = pszValue;
    367             continue;
    368371        }
    369372
     
    384387        G_set_key_value(pszToken, pszValue, temp_projinfo);
    385388    }
     389    if (!pszProj)
     390        G_warning(_("No projection name! Projection parameters likely to be meaningless."));
    386391
    387392    *projinfo = G_create_key_value();
    388393
    389394    /* -------------------------------------------------------------------- */
    390     /*      Derive the user name for the projection.                        */
    391     /* -------------------------------------------------------------------- */
    392     if (pszProj) {
     395    /*      Derive the user name for the coordinate system.                 */
     396    /* -------------------------------------------------------------------- */
     397    pszProjCS = OSRGetAttrValue(hSRS, "PROJCS", 0);
     398    if (!pszProjCS)
     399        pszProjCS = OSRGetAttrValue(hSRS, "GEOGCS", 0);
     400
     401    if (pszProjCS) {
     402        G_set_key_value("name", pszProjCS, *projinfo);
     403    }
     404    else if (pszProj) {
    393405        char path[4095];
    394406        char name[80];
     407       
     408        /* use name of the projection as name for the coordinate system */
    395409
    396410        sprintf(path, "%s/etc/proj/projections", G_gisbase());
     
    400414        else
    401415            G_set_key_value("name", pszProj, *projinfo);
    402 
    403         G_set_key_value("proj", pszProj, *projinfo);
    404     }
    405     else
    406         G_warning(_("No projection name! Projection parameters likely to be meaningless."));
     416    }
    407417
    408418
Note: See TracChangeset for help on using the changeset viewer.