<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Cascadia Mono";
panose-1:2 11 6 9 2 0 0 2 0 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I’m trying to use PointOnSurface but get (0, 0, 0) no matter what geometry I use. I’m using the MapServer libraries from gisinternals.com. One thing I’m seeing is osgeo::proj::io::FactoryException being thrown when I call SetWellKnownGeogCS(“WGS84”).
Any ideas what I’m doing wrong?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Scott<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">#include</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515"><iostream></span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">#include</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"ogrsf_frmts.h"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">#include</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"ogr_geometry.h"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">static</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">void</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#6F008A">CPL_STDCALL</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> CplErrorHandler(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">CPLErr</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">cplErr</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">,
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">int</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">nError</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">,
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">char</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">*
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">pszErrorTxt</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> std::cout
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"GDAL("</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">nError</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"): "</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:gray">pszErrorTxt</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"\n"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">int</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> main()<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">{<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> (</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">void</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">)_putenv(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"GDAL_DATA=D:\\Temp\\GeosTest\\gdal\\bin\\gdal-data"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> (</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">void</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">)_putenv(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"PROJ_DATA=D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:green">// PROJ 9.1</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> (</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">void</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">)_putenv(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"PROJ_LIB=D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:green">// pre PROJ 9.1</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> (</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">void</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">)_putenv(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"PROJ_DEBUG=3"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRErr</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> ogrErr;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> CPLSetConfigOption(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"GDAL_DATA"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">,
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"D:\\Temp\\GeosTest\\gdal\\bin\\gdal-data"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> CPLSetConfigOption(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"PROJ_DATA"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">,
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:green">// PROJ 9.1</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> CPLSetConfigOption(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"PROJ_LIB"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">,
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:green">// pre PROJ 9.1</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> CPLPushErrorHandler((</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">CPLErrorHandler</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">)CplErrorHandler);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> GDALAllRegister();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRSpatialReference</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">* pSrs =
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">new</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRSpatialReference</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pSrs->SetWellKnownGeogCS(</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"WGS84"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">const</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">char</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">* pszWkt =
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"POLYGON ((-5.0 5.0, 5.0 5.0, 5.0 -5.0, 3.0 -5.0, 3.0 3.0, -5.0 3.0, -5.0 5.0))"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRGeometry</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">* pGeom;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRGeometryFactory</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">::createFromWkt(pszWkt, pSrs, &pGeom);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRPoint</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pointOnSurface;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#2B91AF">OGRSurface</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">* pSurface = pGeom->toSurface();<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pSurface->PointOnSurface(&pointOnSurface);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:blue">char</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">* pszWkt2;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pGeom->exportToWkt(&pszWkt2);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> std::cout
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pszWkt2
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"\n"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> std::cout
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">"PointOnSurface = ("</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pointOnSurface.getX()
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">", "</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black"> pointOnSurface.getY()
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:teal"><<</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">
</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:#A31515">")\n"</span><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:"Cascadia Mono";color:black">}<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div id="footer" style="background-color:#D5EAFF; border:1px solid #003333; padding:.7em; ">
<span style="font-size:12pt;font-weight:bold; font-family: 'times new roman'; color:#ff0000;">Disclaimer</span><br>
<p style="font-size:10pt;text-align:justify; line-height:10pt; font-family: 'times roman';">
The information contained in this electronic message and any attachments to this message are intended only for the individual(s) addressed in the message and may contain proprietary and confidential information. If you are not the intended recipient, you should
not disseminate, distribute or copy this e-mail. Please notify the sender and delete this message. WARNING: Computer viruses can be transmitted via email. The recipient should scan this email before opening it. The company accepts no liability for any damage
caused by any virus transmitted by this email. </p>
</div>
</body>
</html>