Example #1
0
Handle<Value> Geometry::New(const Arguments& args)
{
	HandleScope scope;
	Geometry *f;

	if (!args.IsConstructCall()) {
		return NODE_THROW("Cannot call constructor as function, you need to use 'new' keyword");
	}

	if (args[0]->IsExternal()) {
		Local<External> ext = Local<External>::Cast(args[0]);
		void* ptr = ext->Value();
		f = static_cast<Geometry *>(ptr);

	} else {
		return NODE_THROW("Geometry doesnt have a constructor, use Geometry.createFromWkt(), Geometry.create() or type-specific constructor. ie. new ogr.Point()");
		OGRwkbGeometryType geometry_type;
		NODE_ARG_ENUM(0, "geometry type", OGRwkbGeometryType, geometry_type);
		OGRGeometry *geom = OGRGeometryFactory::createGeometry(geometry_type);
		f = new Geometry(geom);
	}

	f->Wrap(args.This());
	return args.This();
}
Example #2
0
Handle<Value> Geometry::New(const Arguments& args) {
    Geometry *geom;
    HandleScope scope;
    geom = new Geometry();
    geom->Wrap(args.This());
    return args.This();
}
Example #3
0
Handle<Value> Geometry::New(geos::geom::Geometry *geometry) {
    HandleScope scope;
    Geometry *geom = new Geometry(geometry);
    Handle<Value> ext = External::New(geom);
    Handle<Object> obj = constructor->GetFunction()->NewInstance(1, &ext);
    geom->Wrap(obj);
    return scope.Close(obj);
}
Example #4
0
Handle<Object> Geometry::WrapNewGEOSGeometry(GEOSGeometry *geos_geom)
{
    HandleScope scope;
    Local<Object> geom_obj = geometry_template_->InstanceTemplate()->NewInstance();
    Geometry *geom = new Geometry(geos_geom);
    geom->Wrap(geom_obj);
    return scope.Close(geom_obj);
}
Example #5
0
Handle<Value> Geometry::New(const Arguments& args)
{
    Geometry *geom;
    HandleScope scope;
    if (args.Length() == 0) {
        geom = new Geometry();
    } else if (args.Length() == 1 && args[0]->IsString()) {
        String::Utf8Value wkt(args[0]->ToString());
        geom = new Geometry(*wkt);
    }
    geom->Wrap(args.This());
    return args.This();
}
Example #6
0
Handle<Value> Geometry::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[0]->IsExternal()) {
    Local<External> ext = Local<External>::Cast(args[0]);
    void* ptr = ext->Value();
    Geometry *f = static_cast<Geometry *>(ptr);
    f->Wrap(args.This());
    return args.This();
  }

  return args.This();
}
Handle<Value> Geometry::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[0]->IsExternal())
    {
        //std::clog << "external!\n";
        Local<External> ext = Local<External>::Cast(args[0]);
        void* ptr = ext->Value();
        Geometry* g =  static_cast<Geometry*>(ptr);
        g->Wrap(args.This());
        return args.This();
    }
    else
    {
        return ThrowException(Exception::Error(
                                  String::New("a mapnik.Geometry cannot be created directly - rather you should create mapnik.Path objects which can contain one or more geometries")));
    }
    return args.This();
}