27 #include "../../../../geometry/Curve.h" 28 #include "../../../../geometry/Point.h" 29 #include "../../common/Utils.h" 36 if(args.Holder().IsEmpty())
37 return ::v8::ThrowException(::v8::String::New(
"In order to use getLength method you must use object notation: \"len = obj.getLength();\""));
39 te::gm::Curve* g = te::v8::common::Unwrap<te::gm::Curve>(args.Holder());
42 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getLength method!"));
46 ::v8::Local<::v8::Number> jlen = ::v8::Number::New(len);
48 return hs.Close(jlen);
55 if(args.Holder().IsEmpty())
56 return ::v8::ThrowException(::v8::String::New(
"In order to use getStartPoint method you must use object notation: \"pt = obj.getStartPoint();\""));
58 te::gm::Curve* g = te::v8::common::Unwrap<te::gm::Curve>(args.Holder());
61 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getStartPoint method!"));
67 return hs.Close(jsgeom);
74 if(args.Holder().IsEmpty())
75 return ::v8::ThrowException(::v8::String::New(
"In order to use getEndPoint method you must use object notation: \"pt = obj.getEndPoint();\""));
77 te::gm::Curve* g = te::v8::common::Unwrap<te::gm::Curve>(args.Holder());
80 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in getEndPoint method!"));
86 return hs.Close(jsgeom);
93 if(args.Holder().IsEmpty())
94 return ::v8::ThrowException(::v8::String::New(
"In order to use isClosed method you must use object notation: \"isclosed = obj.isClosed();\""));
96 te::gm::Curve* g = te::v8::common::Unwrap<te::gm::Curve>(args.Holder());
99 return ::v8::ThrowException(::v8::String::New(
"Invalid geometry in isClosed method!"));
103 ::v8::Handle<::v8::Boolean> jis = ::v8::Boolean::New(is);
105 return hs.Close(jis);
115 ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
116 result->Inherit(geomTpl);
118 ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
120 prototype->Set(::v8::String::NewSymbol(
"getLength"), ::v8::FunctionTemplate::New(
Curve_GetLength));
121 prototype->Set(::v8::String::NewSymbol(
"getStartPoint"), ::v8::FunctionTemplate::New(
Curve_GetStartPoint));
122 prototype->Set(::v8::String::NewSymbol(
"getEndPoint"), ::v8::FunctionTemplate::New(
Curve_GetEndPoint));
123 prototype->Set(::v8::String::NewSymbol(
"isClosed"), ::v8::FunctionTemplate::New(
Curve_IsClosed));
::v8::Handle<::v8::Value > Curve_GetLength(const ::v8::Arguments &args)
::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.
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
::v8::Handle<::v8::Value > Curve_GetEndPoint(const ::v8::Arguments &args)
virtual double getLength() const
The length of this curve in the unit associated to its spatial reference system.
::v8::Handle<::v8::Value > Curve_GetStartPoint(const ::v8::Arguments &args)
virtual bool isClosed() const =0
It returns true if the curve is closed (startPoint = endPoint).
static::v8::Persistent<::v8::FunctionTemplate > sg_curve_template
virtual std::unique_ptr< Point > getStartPoint() const =0
It returns the curve start point.
::v8::Handle<::v8::Value > Curve_IsClosed(const ::v8::Arguments &args)
A point with x and y coordinate values.
::v8::Persistent<::v8::FunctionTemplate > & GetGeometryTemplate()
It returns a reference to the persistent template of a Geometry object.
virtual std::unique_ptr< Point > getEndPoint() const =0
It returns the curve end point.
::v8::Persistent<::v8::FunctionTemplate > & GetCurveTemplate()
It returns a reference to the persistent template of a Curve object.