------------------------------------------------------------------------------
| 373 | |
| 374 | //------------------------------------------------------------------------------ |
| 375 | void 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); |
no test coverage detected