Exemple #1
0
void PrecisionModel::New(const FunctionCallbackInfo<Value>& args) {
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);

    PrecisionModel *model;
    if (args.Length() == 0) {
        model = new PrecisionModel();
    } else {
        if (args[0]->IsString()) {
            //type
            if(args[0]->ToString()->Equals(String::NewFromUtf8(isolate, "FIXED"))) {
                model = new PrecisionModel(geos::geom::PrecisionModel::FIXED);
            } else if (args[0]->ToString()->Equals(String::NewFromUtf8(isolate, "FLOATING"))) {
                model = new PrecisionModel(geos::geom::PrecisionModel::FLOATING);
            } else {
                model = new PrecisionModel(geos::geom::PrecisionModel::FLOATING_SINGLE);
            }
        } else {
            //double
            model = new PrecisionModel(args[0]->NumberValue());
        }
    }
    model->Wrap(args.This());
    args.GetReturnValue().Set(args.This());
}
Exemple #2
0
Handle<Value> PrecisionModel::New(const geos::geom::PrecisionModel *m) {
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);

    PrecisionModel *model = new PrecisionModel(m);
    Handle<Value> ext = External::New(isolate, model);
    Local<Function> cons = Local<Function>::New(isolate, constructor);
    Handle<Object> obj = cons->NewInstance(1, &ext);
    model->Wrap(obj);
    return obj;
}