------------------------------------------------------------------------------
| 185 | |
| 186 | //------------------------------------------------------------------------------ |
| 187 | void vtkGeoJSONWriter::WriteScalar(vtkDataArray* da, vtkIdType ptId) |
| 188 | { |
| 189 | if (this->ScalarFormat == 0) |
| 190 | { |
| 191 | return; |
| 192 | } |
| 193 | if (da) |
| 194 | { |
| 195 | double b = da->GetTuple1(ptId); |
| 196 | if (this->ScalarFormat == 1) |
| 197 | { |
| 198 | vtkLookupTable* lut = this->GetLookupTable(); |
| 199 | if (!lut) |
| 200 | { |
| 201 | lut = vtkLookupTable::New(); |
| 202 | lut->SetNumberOfColors(256); |
| 203 | lut->SetHueRange(0.0, 0.667); |
| 204 | lut->SetRange(da->GetRange()); |
| 205 | lut->Build(); |
| 206 | this->SetLookupTable(lut); |
| 207 | lut->Delete(); |
| 208 | } |
| 209 | const unsigned char* color = lut->MapValue(b); |
| 210 | this->WriterHelper->append(","); |
| 211 | this->WriterHelper->append((double)color[0] / 255.0); |
| 212 | this->WriterHelper->append(","); |
| 213 | this->WriterHelper->append((double)color[1] / 255.0); |
| 214 | this->WriterHelper->append(","); |
| 215 | this->WriterHelper->append((double)color[2] / 255.0); |
| 216 | } |
| 217 | else |
| 218 | { |
| 219 | if (vtkMath::IsNan(b)) |
| 220 | { |
| 221 | this->WriterHelper->append(",null"); |
| 222 | } |
| 223 | else |
| 224 | { |
| 225 | this->WriterHelper->append(","); |
| 226 | this->WriterHelper->append(b); |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | //------------------------------------------------------------------------------ |
| 233 | void vtkGeoJSONWriter::WriteData() |
no test coverage detected