Opened 7 years ago

Last modified 6 years ago

#5724 closed defect

wkt strings derived from loading via epsg code do not validate - esri_extra.wkt — at Initial Version

Reported by: Kurt Schwehr Owned by: warmerdam
Priority: normal Milestone: 2.0.0
Component: OGR_SRS Version: unspecified
Severity: normal Keywords: wkt epsg
Cc:

Description

I'm having a bit of trouble with EPSG:3857 in gdal 1.11.0, which got me looking at esri_extra.wkt. 3857 loaded up gives a WKT that was not validating.

OGRSpatialReference::Validate Parsing error : syntax error, unexpected ',', expecting ']'. Error occured around:
ts=m +nadgrids=@null +wktext  +no_defs"],AUTHORITY["EPSG","3857"]]

input_spatial_reference.Validate() -> OGRERR_CORRUPT_DATA

I made a quick c++ program with 1.10.0 to try to validate all of the epsg codes in esri_extra.wkt... sketched:

  string wkt_csv_path(CSVFilename("esri_extra.wkt")); 
  FILE *wkt_csv = VSIFOpen( wkt_csv_path.c_str(), "rb" );
  char **fields = nullptr;

  while (nullptr != (fields = CSVReadParseLine(wkt_csv))) {
    const int field_count = CSLCount(fields);
    if (field_count < 2) {
      continue;
    }
    const string wkt_str(fields[0]);
    if (wkt_str.size() == 0 || wkt_str[0] == '#') {
      continue;
    }
    int epsg = atoi(fields[0]);
    OGRSpatialReference srs;
    srs.importFromEPSG(epsg);
    if (srs.Validate()) {
      cerr << "epsg validated: " << epsg << "\n";
    } else {
      cerr << ">>>>>>>>>>>>>> epsg FAILED: " << epsg << "\n";
    }
  }
  // Missing a free call above

A snip of the output. Shouldn't everything validate?

>>>>>>>>>>>>>> epsg FAILED: 37254
>>>>>>>>>>>>>> epsg FAILED: 37255
>>>>>>>>>>>>>> epsg FAILED: 37257
>>>>>>>>>>>>>> epsg FAILED: 37259
>>>>>>>>>>>>>> epsg FAILED: 37260
epsg validated: 53001
>>>>>>>>>>>>>> epsg FAILED: 53002
epsg validated: 53003
epsg validated: 53004
epsg validated: 53008
>>>>>>>>>>>>>> epsg FAILED: 53009
>>>>>>>>>>>>>> epsg FAILED: 53010
>>>>>>>>>>>>>> epsg FAILED: 53011
>>>>>>>>>>>>>> epsg FAILED: 53012
>>>>>>>>>>>>>> epsg FAILED: 53013
>>>>>>>>>>>>>> epsg FAILED: 53014
>>>>>>>>>>>>>> epsg FAILED: 53015
>>>>>>>>>>>>>> epsg FAILED: 53016
epsg validated: 53017
epsg validated: 53018
epsg validated: 53019
>>>>>>>>>>>>>> epsg FAILED: 53021
epsg validated: 53022
epsg validated: 53023
>>>>>>>>>>>>>> epsg FAILED: 53024
epsg validated: 53025
>>>>>>>>>>>>>> epsg FAILED: 53026
>>>>>>>>>>>>>> epsg FAILED: 53027
epsg validated: 53028
>>>>>>>>>>>>>> epsg FAILED: 53029

Change History (0)

Note: See TracTickets for help on using tickets.