------------------------------------------------------------------------------
| 231 | |
| 232 | //------------------------------------------------------------------------------ |
| 233 | void vtkGeoJSONWriter::WriteData() |
| 234 | { |
| 235 | ostream* fp; |
| 236 | vtkPolyData* input = vtkPolyData::SafeDownCast(this->GetInput()); |
| 237 | |
| 238 | vtkDebugMacro(<< "Writing vtk polygonal data to geojson file..."); |
| 239 | fp = this->OpenFile(); |
| 240 | if (!fp) |
| 241 | { |
| 242 | return; |
| 243 | } |
| 244 | |
| 245 | this->WriterHelper->append("{\n"); |
| 246 | this->WriterHelper->append("\"type\": \"Feature\",\n"); |
| 247 | vtkDataArray* da = input->GetPointData()->GetScalars(); |
| 248 | if (!da) |
| 249 | { |
| 250 | da = input->GetPointData()->GetArray(0); |
| 251 | } |
| 252 | if (da) |
| 253 | { |
| 254 | switch (this->ScalarFormat) |
| 255 | { |
| 256 | case 0: |
| 257 | this->WriterHelper->append("\"properties\": {\"ScalarFormat\": \"none\"},\n"); |
| 258 | break; |
| 259 | case 1: |
| 260 | this->WriterHelper->append("\"properties\": {\"ScalarFormat\": \"rgb\"},\n"); |
| 261 | break; |
| 262 | case 2: |
| 263 | double rng[2]; |
| 264 | da->GetRange(rng); |
| 265 | this->WriterHelper->append( |
| 266 | "\"properties\": {\"ScalarFormat\": \"values\", \"ScalarRange\": ["); |
| 267 | this->WriterHelper->append(rng[0]); |
| 268 | this->WriterHelper->append(","); |
| 269 | this->WriterHelper->append(rng[1]); |
| 270 | this->WriterHelper->append("] },\n"); |
| 271 | break; |
| 272 | } |
| 273 | } |
| 274 | else |
| 275 | { |
| 276 | this->WriterHelper->append("\"properties\": {\"ScalarFormat\": \"none\"},\n"); |
| 277 | } |
| 278 | this->WriterHelper->append("\"geometry\":\n"); |
| 279 | this->WriterHelper->append("{\n"); |
| 280 | this->WriterHelper->append("\"type\": \"GeometryCollection\",\n"); |
| 281 | this->WriterHelper->append("\"geometries\":\n"); |
| 282 | this->WriterHelper->append("[\n"); |
| 283 | |
| 284 | const vtkIdType* cellPts = nullptr; |
| 285 | vtkIdType cellSize = 0; |
| 286 | vtkIdType numlines, numpolys; |
| 287 | numlines = input->GetLines()->GetNumberOfCells(); |
| 288 | numpolys = input->GetPolys()->GetNumberOfCells(); |
| 289 | |
| 290 | // VERTS |
nothing calls this directly
no test coverage detected