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

Method ExtractGeoJSONFeatureGeometry

IO/GeoJSON/vtkGeoJSONFeature.cxx:375–434  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

373
374//------------------------------------------------------------------------------
375void vtkGeoJSONFeature::ExtractGeoJSONFeatureGeometry(
376 const Json::Value& geometryRoot, vtkPolyData* outputData)
377{
378 // Check for geometry-type node
379 Json::Value const& geometryTypeNode = geometryRoot["type"];
380 if (geometryTypeNode.isNull())
381 {
382 vtkErrorMacro(<< "Missing geometry-type node");
383 return;
384 }
385 if (!geometryTypeNode.isString())
386 {
387 vtkErrorMacro(<< "Invalid geometry-type node");
388 return;
389 }
390
391 std::string typeString = geometryTypeNode.asString();
392 if (typeString == GeoJSON_GEOMETRY_COLLECTION)
393 {
394 // For GeometryCollection
395 const Json::Value& geometries = geometryRoot["geometries"];
396 for (Json::Value::ArrayIndex i = 0; i < geometries.size(); i++)
397 {
398 const Json::Value& child = geometries[i];
399 this->ExtractGeoJSONFeatureGeometry(child, outputData);
400 }
401 return;
402 }
403
404 // (else)
405 Json::Value const& coordinates = geometryRoot["coordinates"];
406 if (typeString == GeoJSON_POINT)
407 {
408 this->ExtractPoint(coordinates, outputData);
409 }
410 else if (typeString == GeoJSON_MULTI_POINT)
411 {
412 this->ExtractMultiPoint(coordinates, outputData);
413 }
414 else if (typeString == GeoJSON_LINE_STRING)
415 {
416 this->ExtractLineString(coordinates, outputData);
417 }
418 else if (typeString == GeoJSON_MULTI_LINE_STRING)
419 {
420 this->ExtractMultiLineString(coordinates, outputData);
421 }
422 else if (typeString == GeoJSON_POLYGON)
423 {
424 this->ExtractPolygon(coordinates, outputData);
425 }
426 else if (typeString == GeoJSON_MULTI_POLYGON)
427 {
428 this->ExtractMultiPolygon(coordinates, outputData);
429 }
430 else
431 {
432 vtkErrorMacro(<< "Unknown or unsupported geometry type " << geometryTypeNode);

Callers 1

ExtractGeoJSONFeatureMethod · 0.95

Calls 10

ExtractPointMethod · 0.95
ExtractMultiPointMethod · 0.95
ExtractLineStringMethod · 0.95
ExtractPolygonMethod · 0.95
ExtractMultiPolygonMethod · 0.95
isStringMethod · 0.80
asStringMethod · 0.80
isNullMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected