27 #include "../../../../geometry/Coord2D.h" 28 #include "../../../../geometry/Point.h" 29 #include "../../../../geometry/Surface.h" 30 #include "../../common/Utils.h" 37 if(args.Holder().IsEmpty())
38 return ::v8::ThrowException(::v8::String::New(
"In order to use getArea method you must use object notation: \"area = obj.getArea();\""));
40 te::gm::Surface* g = te::v8::common::Unwrap<te::gm::Surface>(args.Holder());
43 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getArea method!"));
47 ::v8::Local<::v8::Number> ja = ::v8::Number::New(a);
56 if(args.Holder().IsEmpty())
57 return ::v8::ThrowException(::v8::String::New(
"In order to use getCentroid method you must use object notation: \"pt = obj.getCentroid();\""));
59 te::gm::Surface* g = te::v8::common::Unwrap<te::gm::Surface>(args.Holder());
62 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getCentroid method!"));
70 return hs.Close(jsgeom);
77 if(args.Holder().IsEmpty())
78 return ::v8::ThrowException(::v8::String::New(
"In order to use getCentroidCoord method you must use object notation: \"c = obj.getCentroidCoord();\""));
80 te::gm::Surface* g = te::v8::common::Unwrap<te::gm::Surface>(args.Holder());
83 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getCentroidCoord method!"));
91 return hs.Close(jsgeom);
98 if(args.Holder().IsEmpty())
99 return ::v8::ThrowException(::v8::String::New(
"In order to use getPointOnSurface method you must use object notation: \"pt = obj.getPointOnSurface();\""));
101 te::gm::Surface* g = te::v8::common::Unwrap<te::gm::Surface>(args.Holder());
104 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getPointOnSurface method!"));
112 return hs.Close(jsgeom);
117 ::v8::HandleScope hs;
119 if(args.Holder().IsEmpty())
120 return ::v8::ThrowException(::v8::String::New(
"In order to use getCoordOnSurface method you must use object notation: \"c = obj.getCoordOnSurface();\""));
122 te::gm::Surface* g = te::v8::common::Unwrap<te::gm::Surface>(args.Holder());
125 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getCoordOnSurface method!"));
133 return hs.Close(jsgeom);
143 ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
144 result->Inherit(geomTpl);
146 ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
148 prototype->Set(::v8::String::NewSymbol(
"getArea"), ::v8::FunctionTemplate::New(
Surface_GetArea));
149 prototype->Set(::v8::String::NewSymbol(
"getCentroid"), ::v8::FunctionTemplate::New(
Surface_GetCentroid));
::v8::Local<::v8::Object > Make(T *obj, TF tfunc, const bool isOwner)
It creates a new JavaScript object from a C++ object (obj).
::v8::Persistent<::v8::FunctionTemplate > & GetPointTemplate()
It returns a reference to the persistent template of a Point object.
virtual Point * getCentroid() const =0
It returns the mathematical centroid for the surface as a point.
::v8::Persistent<::v8::FunctionTemplate > & GetCoord2DTemplate()
It returns a reference to the persistent template of a Coord2D object.
virtual Coord2D * getCentroidCoord() const =0
It returns the mathematical centroid for this surface as a coordinate.
static::v8::Persistent<::v8::FunctionTemplate > sg_surface_template
virtual double getArea() const =0
It returns the area of the surface measured in the spatial reference system of the surface...
::v8::Handle<::v8::Value > Surface_GetCoordOnSurface(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Surface_GetCentroidCoord(const ::v8::Arguments &args)
virtual Point * getPointOnSurface() const =0
It returns a point guaranteed to be on this surface.
::v8::Handle<::v8::Value > Surface_GetCentroid(const ::v8::Arguments &args)
virtual Coord2D * getCoordOnSurface() const =0
It returns a coordinate guaranteed to be on this surface.
::v8::Persistent<::v8::FunctionTemplate > & GetGeometryTemplate()
It returns a reference to the persistent template of a Geometry object.
::v8::Handle<::v8::Value > Surface_GetArea(const ::v8::Arguments &args)
::v8::Persistent<::v8::FunctionTemplate > & GetSurfaceTemplate()
It returns a reference to the persistent template of a Surface object.
::v8::Handle<::v8::Value > Surface_GetPointOnSurface(const ::v8::Arguments &args)
Surface is an abstract class that represents a 2-dimensional geometric objects.