------------------------------------------------------------------------------
| 65 | |
| 66 | //------------------------------------------------------------------------------ |
| 67 | void vtkGeoJSONReader::GeoJSONReaderInternal::ParseRoot(const Json::Value& root, |
| 68 | vtkPolyData* output, bool outlinePolygons, const char* serializedPropertiesArrayName) |
| 69 | { |
| 70 | // Initialize geometry containers |
| 71 | vtkNew<vtkPoints> points; |
| 72 | points->SetDataTypeToDouble(); |
| 73 | output->SetPoints(points); |
| 74 | vtkNew<vtkCellArray> verts; |
| 75 | output->SetVerts(verts); |
| 76 | vtkNew<vtkCellArray> lines; |
| 77 | output->SetLines(lines); |
| 78 | vtkNew<vtkCellArray> polys; |
| 79 | output->SetPolys(polys); |
| 80 | |
| 81 | // Initialize feature-id array |
| 82 | vtkStringArray* featureIdArray = vtkStringArray::New(); |
| 83 | featureIdArray->SetName("feature-id"); |
| 84 | output->GetCellData()->AddArray(featureIdArray); |
| 85 | featureIdArray->Delete(); |
| 86 | |
| 87 | // Initialize properties arrays |
| 88 | if (serializedPropertiesArrayName) |
| 89 | { |
| 90 | vtkStringArray* propertiesArray = vtkStringArray::New(); |
| 91 | propertiesArray->SetName(serializedPropertiesArrayName); |
| 92 | output->GetCellData()->AddArray(propertiesArray); |
| 93 | propertiesArray->Delete(); |
| 94 | } |
| 95 | |
| 96 | vtkAbstractArray* array; |
| 97 | std::vector<GeoJSONProperty>::iterator iter = this->PropertySpecs.begin(); |
| 98 | for (; iter != this->PropertySpecs.end(); ++iter) |
| 99 | { |
| 100 | array = nullptr; |
| 101 | switch (iter->Value.GetType()) |
| 102 | { |
| 103 | case VTK_BIT: |
| 104 | array = vtkBitArray::New(); |
| 105 | break; |
| 106 | |
| 107 | case VTK_INT: |
| 108 | array = vtkIntArray::New(); |
| 109 | break; |
| 110 | |
| 111 | case VTK_DOUBLE: |
| 112 | array = vtkDoubleArray::New(); |
| 113 | break; |
| 114 | |
| 115 | case VTK_STRING: |
| 116 | array = vtkStringArray::New(); |
| 117 | break; |
| 118 | |
| 119 | default: |
| 120 | vtkGenericWarningMacro("unexpected data type " << iter->Value.GetType()); |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | // Skip if array not created for some reason |
no test coverage detected