Removed nodejs

Seems like my local build is ok, but in CI
the references to engine are still there
so I am reverting code in /nodejs to master
This commit is contained in:
Mugr Rex 2023-04-24 19:16:27 +02:00
parent 5b23b11129
commit 1107a14a2c
4 changed files with 1811 additions and 5 deletions

View File

@ -21,11 +21,11 @@
#include <napi.h> #include <napi.h>
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/optional.hpp>
#include <algorithm> #include <algorithm>
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <optional>
#include <sstream> #include <sstream>
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
@ -345,11 +345,11 @@ inline engine_config_ptr argumentsToEngineConfig(const Napi::CallbackInfo &args)
return engine_config; return engine_config;
} }
inline std::optional<std::vector<osrm::Coordinate>> inline boost::optional<std::vector<osrm::Coordinate>>
parseCoordinateArray(const Napi::Array &coordinates_array) parseCoordinateArray(const Napi::Array &coordinates_array)
{ {
Napi::HandleScope scope(coordinates_array.Env()); Napi::HandleScope scope(coordinates_array.Env());
std::optional<std::vector<osrm::Coordinate>> resulting_coordinates; boost::optional<std::vector<osrm::Coordinate>> resulting_coordinates;
std::vector<osrm::Coordinate> temp_coordinates; std::vector<osrm::Coordinate> temp_coordinates;
for (uint32_t i = 0; i < coordinates_array.Length(); ++i) for (uint32_t i = 0; i < coordinates_array.Length(); ++i)
@ -400,7 +400,7 @@ parseCoordinateArray(const Napi::Array &coordinates_array)
osrm::util::FloatLatitude{std::move(lat)}); osrm::util::FloatLatitude{std::move(lat)});
} }
resulting_coordinates = std::make_optional(std::move(temp_coordinates)); resulting_coordinates = boost::make_optional(std::move(temp_coordinates));
return resulting_coordinates; return resulting_coordinates;
} }
@ -968,7 +968,7 @@ inline bool parseCommonParameters(const Napi::Object &obj, ParamType &params)
inline PluginParameters argumentsToPluginParameters( inline PluginParameters argumentsToPluginParameters(
const Napi::CallbackInfo &args, const Napi::CallbackInfo &args,
const std::optional<osrm::engine::api::BaseParameters::OutputFormatType> &output_format = {}) const boost::optional<osrm::engine::api::BaseParameters::OutputFormatType> &output_format = {})
{ {
if (args.Length() < 3 || !args[1].IsObject()) if (args.Length() < 3 || !args[1].IsObject())
{ {

View File

@ -0,0 +1,68 @@
#ifndef OSRM_BINDINGS_NODE_JSON_V8_RENDERER_HPP
#define OSRM_BINDINGS_NODE_JSON_V8_RENDERER_HPP
#include "osrm/json_container.hpp"
#include <napi.h>
#include <functional>
namespace node_osrm
{
struct V8Renderer
{
explicit V8Renderer(const Napi::Env &env, Napi::Value &out) : env(env), out(out) {}
void operator()(const osrm::json::String &string) const
{
out = Napi::String::New(env, string.value);
}
void operator()(const osrm::json::Number &number) const
{
out = Napi::Number::New(env, number.value);
}
void operator()(const osrm::json::Object &object) const
{
Napi::Object obj = Napi::Object::New(env);
for (const auto &keyValue : object.values)
{
Napi::Value child;
mapbox::util::apply_visitor(V8Renderer(env, child), keyValue.second);
obj.Set(keyValue.first, child);
}
out = obj;
}
void operator()(const osrm::json::Array &array) const
{
Napi::Array a = Napi::Array::New(env, array.values.size());
for (auto i = 0u; i < array.values.size(); ++i)
{
Napi::Value child;
mapbox::util::apply_visitor(V8Renderer(env, child), array.values[i]);
a.Set(i, child);
}
out = a;
}
void operator()(const osrm::json::True &) const { out = Napi::Boolean::New(env, true); }
void operator()(const osrm::json::False &) const { out = Napi::Boolean::New(env, false); }
void operator()(const osrm::json::Null &) const { out = env.Null(); }
private:
const Napi::Env &env;
Napi::Value &out;
};
inline void renderToV8(const Napi::Env &env, Napi::Value &out, const osrm::json::Object &object)
{
V8Renderer renderer(env, out);
renderer(object);
}
} // namespace node_osrm
#endif // JSON_V8_RENDERER_HPP

32
src/nodejs/node_osrm.hpp Normal file
View File

@ -0,0 +1,32 @@
#ifndef OSRM_BINDINGS_NODE_HPP
#define OSRM_BINDINGS_NODE_HPP
#include "osrm/osrm_fwd.hpp"
#include <napi.h>
#include <memory>
namespace node_osrm
{
class Engine final : public Napi::ObjectWrap<Engine>
{
public:
static Napi::Object Init(Napi::Env env, Napi::Object exports);
Engine(const Napi::CallbackInfo &info);
std::shared_ptr<osrm::OSRM> this_;
private:
Napi::Value route(const Napi::CallbackInfo &info);
Napi::Value nearest(const Napi::CallbackInfo &info);
Napi::Value table(const Napi::CallbackInfo &info);
Napi::Value tile(const Napi::CallbackInfo &info);
Napi::Value match(const Napi::CallbackInfo &info);
Napi::Value trip(const Napi::CallbackInfo &info);
};
} // namespace node_osrm
#endif

File diff suppressed because it is too large Load Diff