MCPcopy Create free account
hub / github.com/PDAL/PDAL / set

Method set

pdal/SpatialReference.cpp:197–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195
196
197void SpatialReference::set(std::string v)
198{
199 m_wkt.clear();
200 m_wkt2.clear();
201 m_horizontalWkt.clear();
202 if (v.empty())
203 {
204 return;
205 }
206
207 if (isWKT2(v))
208 {
209 m_wkt = v;
210 m_wkt2 = v;
211 return;
212 }
213 else if (isWKT1(v))
214 {
215 m_wkt = v;
216 OGRScopedSpatialReference srs = ogrCreateSrs(m_wkt);
217 if (srs)
218 m_wkt2 = exportToWkt(srs.get(), {"FORMAT=WKT2_2018"});
219 return;
220 }
221
222 OGRSpatialReference srs(NULL);
223
224 CPLErrorReset();
225 const char* input = v.c_str();
226 OGRErr err = srs.SetFromUserInput(const_cast<char *>(input));
227 if (err != OGRERR_NONE)
228 {
229 std::ostringstream oss;
230 std::string msg = CPLGetLastErrorMsg();
231 if (msg.empty())
232 msg = "(unknown reason)";
233 oss << "Could not import coordinate system '" << input << "': " <<
234 msg << ".";
235 throw pdal_error(oss.str());
236 }
237
238 m_epoch = srs.GetCoordinateEpoch();
239
240 m_wkt = exportToWkt(&srs);
241
242 m_wkt2 = exportToWkt(&srs, {"FORMAT=WKT2_2018"});
243}
244
245
246std::string SpatialReference::getProj4() const

Callers 1

Calls 6

ogrCreateSrsFunction · 0.85
exportToWktFunction · 0.85
strMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected