MCPcopy Create free account
hub / github.com/OSGeo/gdal / CPL_STDCALL GDALLoadOziMapFile

Function CPL_STDCALL GDALLoadOziMapFile

gcore/gdal_misc.cpp:2042–2234  ·  view source on GitHub ↗

Helper function for translator implementer wanting support for OZI .map * * @param pszFilename filename of .tab file * @param padfGeoTransform output geotransform. Must hold 6 doubles. * @param ppszWKT output pointer to a string that will be allocated with * CPLMalloc(). * @param pnGCPCount output pointer to GCP count. * @param ppasGCPs outputer pointer to an array of GCPs. * @return TRUE

Source from the content-addressed store, hash-verified

2040 * @return TRUE in case of success, FALSE otherwise.
2041 */
2042int CPL_STDCALL GDALLoadOziMapFile(const char *pszFilename,
2043 double *padfGeoTransform, char **ppszWKT,
2044 int *pnGCPCount, GDAL_GCP **ppasGCPs)
2045
2046{
2047 VALIDATE_POINTER1(pszFilename, "GDALLoadOziMapFile", FALSE);
2048 VALIDATE_POINTER1(padfGeoTransform, "GDALLoadOziMapFile", FALSE);
2049 VALIDATE_POINTER1(pnGCPCount, "GDALLoadOziMapFile", FALSE);
2050 VALIDATE_POINTER1(ppasGCPs, "GDALLoadOziMapFile", FALSE);
2051
2052 char **papszLines = CSLLoad2(pszFilename, 1000, 200, nullptr);
2053
2054 if (!papszLines)
2055 return FALSE;
2056
2057 int nLines = CSLCount(papszLines);
2058
2059 // Check the OziExplorer Map file signature
2060 if (nLines < 5 ||
2061 !STARTS_WITH_CI(papszLines[0], "OziExplorer Map Data File Version "))
2062 {
2063 CPLError(CE_Failure, CPLE_AppDefined,
2064 "GDALLoadOziMapFile(): file \"%s\" is not in OziExplorer Map "
2065 "format.",
2066 pszFilename);
2067 CSLDestroy(papszLines);
2068 return FALSE;
2069 }
2070
2071 OGRSpatialReference oSRS;
2072 OGRErr eErr = OGRERR_NONE;
2073
2074 /* The Map Scale Factor has been introduced recently on the 6th line */
2075 /* and is a trick that is used to just change that line without changing */
2076 /* the rest of the MAP file but providing an imagery that is smaller or
2077 * larger */
2078 /* so we have to correct the pixel/line values read in the .MAP file so they
2079 */
2080 /* match the actual imagery dimension. Well, this is a bad summary of what
2081 */
2082 /* is explained at
2083 * http://tech.groups.yahoo.com/group/OziUsers-L/message/12484 */
2084 double dfMSF = 1;
2085
2086 for (int iLine = 5; iLine < nLines; iLine++)
2087 {
2088 if (STARTS_WITH_CI(papszLines[iLine], "MSF,"))
2089 {
2090 dfMSF = CPLAtof(papszLines[iLine] + 4);
2091 if (dfMSF <= 0.01) /* Suspicious values */
2092 {
2093 CPLDebug("OZI", "Suspicious MSF value : %s", papszLines[iLine]);
2094 dfMSF = 1;
2095 }
2096 }
2097 }
2098
2099 eErr = oSRS.importFromOzi(papszLines);

Callers

nothing calls this directly

Calls 15

CSLLoad2Function · 0.85
CSLCountFunction · 0.85
CPLErrorFunction · 0.85
CPLAtofFunction · 0.85
CPLDebugFunction · 0.85
CSLTokenizeString2Function · 0.85
CPLAtofMFunction · 0.85
CPL_TO_BOOLFunction · 0.85
CPLTestBoolFunction · 0.85
CPLCallocFunction · 0.85
importFromOziMethod · 0.80

Tested by

no test coverage detected