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

Method createFeature

kernels/TIndexKernel.cpp:545–608  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

543
544
545bool TIndexKernel::createFeature(const FieldIndexes& indexes,
546 FileInfo& fileInfo)
547{
548 using namespace gdal;
549
550 OGRFeatureH hFeature = OGR_F_Create(OGR_L_GetLayerDefn(m_layer));
551
552 // Set the creation time into the feature.
553 setDate(hFeature, fileInfo.m_ctime, indexes.m_ctime);
554
555 // Set the file mod time into the feature.
556 setDate(hFeature, fileInfo.m_mtime, indexes.m_mtime);
557
558 // Set the filename into the feature.
559 setStringField(hFeature, indexes.m_filename,
560 fileInfo.m_filename.c_str());
561
562 // Set the SRS into the feature.
563 // We override if m_assignSrsString is set
564 if (fileInfo.m_srs.empty() || m_overrideASrs)
565 fileInfo.m_srs = m_assignSrsString;
566
567 if (fileInfo.m_srs.empty())
568 {
569 std::ostringstream oss;
570
571 oss << "Unable to import source spatial reference '" <<
572 fileInfo.m_srs << "' for file '" <<
573 fileInfo.m_filename << "'.";
574 OGR_F_Destroy(hFeature);
575 throw pdal_error(oss.str());
576 }
577 if (fileInfo.m_srs != m_originalSrs)
578 {
579 m_log->get(LogLevel::Warning) << "SRS value for " << fileInfo.m_filename <<
580 " does not match the SRS of other files in the tileindex." <<
581 (m_skipMultiSrs ? " Skipping this file" : "") << std::endl;
582 if (m_skipMultiSrs)
583 {
584 OGR_F_Destroy(hFeature);
585 return false;
586 }
587 }
588 std::string wkt =
589 SpatialReference(fileInfo.m_srs).getWKT();
590
591 setStringField(hFeature, indexes.m_srs, wkt.data());
592
593 // Set the geometry in the feature
594 Polygon g = prepareGeometry(fileInfo);
595 OGR_F_SetGeometry(hFeature, g.getOGRHandle());
596
597 const bool bRet = (OGR_L_CreateFeature(m_layer, hFeature) == OGRERR_NONE);
598 OGR_F_Destroy(hFeature);
599
600 if (bRet)
601 m_log->get(LogLevel::Info) << "Indexed file " << fileInfo.m_filename <<
602 std::endl;

Callers

nothing calls this directly

Calls 7

setDateFunction · 0.85
strMethod · 0.80
getWKTMethod · 0.80
SpatialReferenceClass · 0.50
emptyMethod · 0.45
getMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected