Hi,
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?
Thanks,
Scott
#include <iostream>
#include "ogrsf_frmts.h"
#include "ogr_geometry.h"
static void CPL_STDCALL CplErrorHandler(CPLErr cplErr, int nError, char*
pszErrorTxt) {
std::cout << "GDAL(" << nError << "): " << pszErrorTxt << "\n";
}
int main()
{
(void)_putenv("GDAL_DATA=D:\\Temp\\GeosTest\\gdal\\bin\\gdal-data");
(void)_putenv("PROJ_DATA=D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"); //
PROJ 9.1
(void)_putenv("PROJ_LIB=D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"); //
pre PROJ 9.1
(void)_putenv("PROJ_DEBUG=3");
OGRErr ogrErr;
CPLSetConfigOption("GDAL_DATA", "D:\\Temp\\GeosTest\\gdal\\bin\\gdal-data");
CPLSetConfigOption("PROJ_DATA",
"D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"); // PROJ 9.1
CPLSetConfigOption("PROJ_LIB",
"D:\\Temp\\GeosTest\\gdal\\bin\\proj9\\share"); // pre PROJ 9.1
CPLPushErrorHandler((CPLErrorHandler)CplErrorHandler);
GDALAllRegister();
OGRSpatialReference* pSrs = new OGRSpatialReference();
pSrs->SetWellKnownGeogCS("WGS84");
const char* pszWkt = "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))";
OGRGeometry* pGeom;
OGRGeometryFactory::createFromWkt(pszWkt, pSrs, &pGeom);
OGRPoint pointOnSurface;
OGRSurface* pSurface = pGeom->toSurface();
pSurface->PointOnSurface(&pointOnSurface);
char* pszWkt2;
pGeom->exportToWkt(&pszWkt2);
std::cout << pszWkt2 << "\n";
std::cout << "PointOnSurface = (" << pointOnSurface.getX() << ", " <<
pointOnSurface.getY() << ")\n";
}
Disclaimer
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.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev