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

Method loadParquetGeoMetadata

plugins/arrow/io/ArrowReader.cpp:154–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void ArrowReader::loadParquetGeoMetadata(const std::shared_ptr<const arrow::KeyValueMetadata> &kv_metadata)
155{
156 if (!kv_metadata)
157 return;
158 auto geo = kv_metadata->Get("geo");
159 NL::json metadata;
160
161 if (geo.ok())
162 {
163 // load up the JSON and set our stuff
164 try
165 {
166 metadata = NL::json::parse(*geo);
167 } catch (NL::json::parse_error& e)
168 {
169 log()->get(LogLevel::Warning) << "unable to parse GeoParquet 'geo' metadata with error '"
170 << e.what() << "'" << std::endl;
171 return;
172 }
173
174 if (!metadata.contains("primary_column"))
175 {
176 log()->get(LogLevel::Warning) << "GeoParquet metadata does not contain 'primary_column' entry"
177 << std::endl;
178 return;
179
180 }
181
182 if (!metadata.contains("columns"))
183 {
184 log()->get(LogLevel::Warning) << "GeoParquet metadata does not contain 'columns' entry"
185 << std::endl;
186 return;
187 }
188 NL::json columns = metadata["columns"];
189
190 std::string primary_column = metadata["primary_column"];
191 NL::json column = metadata["columns"][primary_column];
192
193 log()->get(LogLevel::Info) << "primary column is " << primary_column << std::endl;
194
195 if (!column.contains("crs"))
196 {
197 log()->get(LogLevel::Warning) << "no 'crs' key available to fetch spatial reference information, setting to 4326" << std::endl;
198 setSpatialReference("EPSG:4326");
199 return;
200 }
201
202 SpatialReference ref;
203 NL::json crs = column["crs"];
204 if (crs.is_object())
205 {
206 ref.set(crs.dump());
207 }
208 else if (crs.is_string())
209 {
210
211 ref.set(column["crs"].get<std::string>());

Callers

nothing calls this directly

Calls 9

setEpochMethod · 0.80
parseFunction · 0.50
logFunction · 0.50
setSpatialReferenceFunction · 0.50
getMethod · 0.45
whatMethod · 0.45
containsMethod · 0.45
setMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected