Handle<Value> Projection::New(const Arguments& args) { HandleScope scope; if (!args.IsConstructCall()) return ThrowException(String::New("Cannot call constructor as function, you need to use 'new' keyword")); if (!args.Length() > 0 || !args[0]->IsString()) { return ThrowException(Exception::TypeError( String::New("please provide a proj4 intialization string"))); } try { Projection* p = new Projection(TOSTR(args[0])); p->Wrap(args.This()); return args.This(); } catch (const mapnik::proj_init_error & ex ) { return ThrowException(Exception::Error( String::New(ex.what()))); } }
Handle<Value> Projection::New(const Arguments& args) { Projection *proj; HandleScope scope; if (args.Length() == 1 && args[0]->IsString()) { String::Utf8Value init(args[0]->ToString()); proj = new Projection(*init); if (!proj->IsValid()) { int *errno = pj_get_errno_ref(); char *description = pj_strerrno(*errno); return ThrowException(String::New(description)); } } else { return ThrowException(String::New("No valid arguments passed for projection initialization string.")); } proj->Wrap(args.This()); return args.This(); }