OGRSpatialReference oSRS; oSRS.SetWellKnownGeogCS("WGS84"); // set geographic coordinate system
OGRSpatialReference oSRS; oSRS.SetProjCS("Custom Projection"); // set projected coordinate system oSRS.SetProjection("PROJCS[\"Custom Projection\",GEOGCS[\"WGS 84\",...],PROJECTION[\"Mercator\"],...]");
OGRSpatialReference oSrcSRS, oDstSRS; oSrcSRS.SetFromUserInput("EPSG:4326"); // set source SRS to WGS84 oDstSRS.SetFromUserInput("EPSG:3857"); // set destination SRS to Web Mercator OGRCoordinateTransformation* pTransform = OGRCreateCoordinateTransformation(&oSrcSRS, &oDstSRS); double x = -122.419416, y = 37.77493; // San Francisco coordinates in WGS84 pTransform->Transform(1, &x, &y); // transform coordinates to Web MercatorIn summary, the OGRSpatialReference library in the OGR package provides C++ programmers with a way to manage spatial reference systems for GIS applications. It includes methods for creating and setting coordinate systems, projections, and datum transformations, as well as transforming points from one coordinate system to another.