MCPcopy Create free account
hub / github.com/Kitware/VTK / ExtractGeoJSONFeature

Method ExtractGeoJSONFeature

IO/GeoJSON/vtkGeoJSONFeature.cxx:312–372  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

310
311//------------------------------------------------------------------------------
312void vtkGeoJSONFeature::ExtractGeoJSONFeature(const Json::Value& root, vtkPolyData* outputData)
313{
314 this->featureRoot = root;
315
316 // Check that type is Feature
317 Json::Value const& typeNode = root["type"];
318 if (typeNode.isNull() || "Feature" != typeNode.asString())
319 {
320 vtkErrorMacro(<< "Unknown type. \"Feature\" expected");
321 return;
322 }
323
324 // Check for geometry node
325 Json::Value const& geometryNode = root["geometry"];
326 if (geometryNode.isNull())
327 {
328 vtkErrorMacro(<< "Missing geometry node");
329 return;
330 }
331
332 // Check for properties node
333 Json::Value const& propertiesNode = root["properties"];
334 if (propertiesNode.isNull())
335 {
336 vtkErrorMacro(<< "Missing properties node");
337 return;
338 }
339
340 // Check for feature id
341 std::string featureString;
342 Json::Value const& idNode = root["id"];
343 // No Json::Value::toString() method, so homebrew one here
344 std::stringstream oss;
345 switch (idNode.type())
346 {
347 case Json::nullValue:
348 break;
349
350 case Json::intValue:
351 case Json::uintValue:
352 oss << idNode.asInt();
353 featureString = oss.str();
354 break;
355
356 case Json::realValue:
357 oss << idNode.asDouble();
358 featureString = oss.str();
359 break;
360
361 case Json::stringValue:
362 featureString = idNode.asString();
363 break;
364
365 default:
366 vtkWarningMacro(<< "Unsupported \"id\" type: " << idNode.type());
367 break;
368 }
369

Callers 1

ParseRootMethod · 0.80

Calls 9

strdupFunction · 0.85
asStringMethod · 0.80
asIntMethod · 0.80
isNullMethod · 0.45
typeMethod · 0.45
strMethod · 0.45
asDoubleMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected