------------------------------------------------------------------------------
| 192 | |
| 193 | //------------------------------------------------------------------------------ |
| 194 | int vtkGeoJSONReader::GeoJSONReaderInternal::CanParseFile(const char* filename, Json::Value& root) |
| 195 | { |
| 196 | if (!filename) |
| 197 | { |
| 198 | vtkGenericWarningMacro(<< "Input filename not specified"); |
| 199 | return VTK_ERROR; |
| 200 | } |
| 201 | |
| 202 | vtksys::ifstream file; |
| 203 | file.open(filename); |
| 204 | |
| 205 | if (!file.is_open()) |
| 206 | { |
| 207 | vtkGenericWarningMacro(<< "Unable to Open File " << filename); |
| 208 | return VTK_ERROR; |
| 209 | } |
| 210 | |
| 211 | Json::CharReaderBuilder builder; |
| 212 | builder["collectComments"] = false; |
| 213 | |
| 214 | std::string formattedErrors; |
| 215 | |
| 216 | // parse the entire geoJSON data into the Json::Value root |
| 217 | bool parsedSuccess = parseFromStream(builder, file, &root, &formattedErrors); |
| 218 | |
| 219 | if (!parsedSuccess) |
| 220 | { |
| 221 | // Report failures and their locations in the document |
| 222 | vtkGenericWarningMacro(<< "Failed to parse JSON" << endl << formattedErrors); |
| 223 | return VTK_ERROR; |
| 224 | } |
| 225 | |
| 226 | return VTK_OK; |
| 227 | } |
| 228 | |
| 229 | //------------------------------------------------------------------------------ |
| 230 | int vtkGeoJSONReader::GeoJSONReaderInternal::CanParseString(char* input, Json::Value& root) |
no test coverage detected