| 61 | } |
| 62 | |
| 63 | AddonList Addon::store(const connector::Connector& connector, const NL::json& spec, |
| 64 | const PointLayout& layout) |
| 65 | { |
| 66 | AddonList addons; |
| 67 | std::string filename; |
| 68 | try |
| 69 | { |
| 70 | for (auto it : spec.items()) |
| 71 | { |
| 72 | std::string filename = it.key(); |
| 73 | std::string dimName = it.value().get<std::string>(); |
| 74 | if (!Utils::endsWith(filename, "ept-addon.json")) |
| 75 | filename += "/ept-addon.json"; |
| 76 | |
| 77 | Dimension::Id id = layout.findDim(dimName); |
| 78 | if (id == Dimension::Id::Unknown) |
| 79 | throw pdal_error("Invalid dimension '" + dimName + "' in " |
| 80 | "addon specification. Does not exist in source data."); |
| 81 | Dimension::Type type = layout.dimType(id); |
| 82 | std::string typestring = Dimension::toName(Dimension::base(type)); |
| 83 | size_t size = Dimension::size(type); |
| 84 | |
| 85 | Addon addon(dimName, filename, type); |
| 86 | |
| 87 | NL::json meta; |
| 88 | meta["type"] = typestring; |
| 89 | meta["size"] = size; |
| 90 | meta["version"] = "1.0.0"; |
| 91 | meta["dataType"] = "binary"; |
| 92 | |
| 93 | connector.makeDir(FileUtils::getDirectory(filename)); |
| 94 | connector.put(filename, meta.dump()); |
| 95 | |
| 96 | addons.emplace_back(dimName, filename, type); |
| 97 | addons.back().setExternalId(id); |
| 98 | } |
| 99 | } |
| 100 | catch (NL::json::parse_error&) |
| 101 | { |
| 102 | throw pdal_error("Unable to parse EPT addon file '" + filename + "'."); |
| 103 | } |
| 104 | return addons; |
| 105 | } |
| 106 | |
| 107 | AddonList Addon::load(const connector::Connector& connector, const NL::json& spec) |
| 108 | { |
nothing calls this directly
no test coverage detected