<html><head></head><body><div style="color:#000; background-color:#fff; font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1515768771710_97403"><br></div><div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" id="yui_3_16_0_ym19_1_1515768771710_97351" style="display: block;"><div style="font-family: Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1515768771710_97350"><div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;" id="yui_3_16_0_ym19_1_1515768771710_97349"> <div class="y_msg_container" id="yui_3_16_0_ym19_1_1515768771710_97354"><div id="yiv8288061063"><div id="yui_3_16_0_ym19_1_1515768771710_97353"><div style="color:#000;background-color:#fff;font-family:Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;" id="yui_3_16_0_ym19_1_1515768771710_97352"><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40725">Dear GDAL list,</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40726"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40727"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40728">I'm having problems using the standard way to convert coordinate points from a source to a target SRS. After updating to version 2.2.3, code that always worked started to leave the input coordinate unchanged, without giving any error or warning.</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40729">This is the code I use:</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40730"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40731"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40732">bool ConvertPoint(int InputEPSG, int OutputEPSG, double *x, double *y)</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40733">{</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40734"> bool res = false;<br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40735"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40736"> OGRSpatialReference oSourceSRS, oTargetSRS;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40737"> OGRCoordinateTransformation *poCT;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40738"> </div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40739"> if( oSourceSRS.importFromEPSG(InputEPSG) != OGRERR_NONE ) printf("OGRSpatialReference failed to importFromEPSG %d.\n",InputEPSG); </div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40740"> if( oTargetSRS.importFromEPSG(OutputEPSG) != OGRERR_NONE ) printf("OGRSpatialReference failed to importFromEPSG %d.\n",OutputEPSG); </div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40741"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40742"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40743"> poCT = OGRCreateCoordinateTransformation(&oSourceSRS, &oTargetSRS);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40744"> if( !poCT )</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40745"> {</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40746"> printf("OGRCreateCoordinateTransformation failed.\n");</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40747"> return false;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40748"> }</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40749"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40750"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40751"> double z = 0.0;<br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40752"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40753"> if( !poCT->Transform(1,x,y,&z) ) printf("Transformation failed.\n");</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40754"> else res = true;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40755"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40756"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40757"> delete poCT;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40758"> return res;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40759">}</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40760"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40761"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40762">If I call, for instance:</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40763"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40764"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40765">double x = 12.5;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40766">double y = 43.0;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40767">ConvertPoint(4326, 32633, &x, &y);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40768"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40769"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40770">x and y remain unchanged and no error or warning is printed.</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40771"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40772"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40773">I tried to change the function by looking at the code of gdaltransform app:</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40774"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40775"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40776"><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40777">bool ConvertPoint(int InputEPSG, int OutputEPSG, double *x, double *y)</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40778">{</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40779"> bool res = false;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40780"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40781"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40782"> GDALTransformerFunc pfnTransformer = nullptr;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40783"> void *hTransformArg;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40784"> int bInverse = FALSE;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40785"> char **papszTO = nullptr;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40786"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40787"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40788"> char fromBuffer[100], toBuffer[100];</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40789"> sprintf(fromBuffer,"EPSG:%d",InputEPSG);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40790"> sprintf(toBuffer, "EPSG:%d",OutputEPSG);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40791"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40792"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40793"> char *pszFROM = SanitizeSRS(fromBuffer);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40794"> papszTO = CSLSetNameValue(papszTO, "SRC_SRS", pszFROM);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40795"> CPLFree(pszFROM);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40796"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40797"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40798"> char *pszTO = SanitizeSRS(toBuffer);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40799"> papszTO = CSLSetNameValue(papszTO, "DST_SRS", pszTO);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40800"> CPLFree(pszTO);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40801"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40802"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40803"> pfnTransformer = GDALGenImgProjTransform;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40804"> hTransformArg = GDALCreateGenImgProjTransformer2(nullptr, nullptr, papszTO);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40805"> CSLDestroy(papszTO);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40806"> if( hTransformArg == nullptr )</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40807"> {</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40808"> printf("GDALCreateGenImgProjTransformer2 failed.\n");</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40809"> return false;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40810"> }</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40811"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40812"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40813"> double z = 0.0;<br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40814"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40815"> int bSuccess = TRUE;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40816"> if( pfnTransformer(hTransformArg, bInverse, 1, x, y, &z, &bSuccess ) && bSuccess ) res = true;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40817"> else printf("Transformation failed.\n");</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40818"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40819"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40820"> GDALDestroyGenImgProjTransformer(hTransformArg);</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40821"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40822"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40823"> return res;</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40824">}</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40825"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40826"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40827">In this case everything works well and the coordinates are transformed.</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40828"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40829"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40830">What I'm doing wrong in my first original function?</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40831">Any hints?</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40832"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40833"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40834">Thank you!</div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40835"><br id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40836"></div><div dir="ltr" id="yiv8288061063yui_3_16_0_ym19_1_1515768771710_40837">Davide De Marchi (JRC European Commission)</div></div></div></div></div><br><br></div> </div> </div> </div></div></body></html>