Exemplo n.º 1
0
Handle<Value> Expression::toString(const Arguments& args)
{
    HandleScope scope;

    Expression* e = node::ObjectWrap::Unwrap<Expression>(args.This());
    return scope.Close(String::New( mapnik::to_expression_string(*e->get()).c_str() ));
}
Exemplo n.º 2
0
Handle<Value> Expression::evaluate(const Arguments& args)
{
    HandleScope scope;

    if (args.Length() < 1) {
        return ThrowException(Exception::Error(
                                  String::New("requires a mapnik.Feature as an argument")));
    }

    Local<Object> obj = args[0]->ToObject();
    if (obj->IsNull() || obj->IsUndefined()) {
        return ThrowException(Exception::TypeError(String::New("first argument is invalid, must be a mapnik.Feature not null/undefined")));
    }

    if (!Feature::constructor->HasInstance(obj)) {
        return ThrowException(Exception::TypeError(String::New("first argument is invalid, must be a mapnik.Feature")));
    }

    Feature* f = node::ObjectWrap::Unwrap<Feature>(obj);

    Expression* e = node::ObjectWrap::Unwrap<Expression>(args.This());
    mapnik::value value_obj = boost::apply_visitor(mapnik::evaluate<mapnik::Feature,mapnik::value>(*(f->get())),*(e->get()));
    return scope.Close(boost::apply_visitor(node_mapnik::value_converter(),value_obj.base()));
}