27 #include "../../../../core/logger/Logger.h" 28 #include "../../../../core/translator/Translator.h" 29 #include "../../../../geometry/Point.h" 30 #include "../../../../geometry/PointM.h" 31 #include "../../../../geometry/PointZ.h" 32 #include "../../../../geometry/PointZM.h" 33 #include "../../common/Utils.h" 36 ::v8::Handle<::v8::Value>
Point_GetX(const ::v8::Arguments& args)
40 if(args.Holder().IsEmpty())
41 return ::v8::ThrowException(::v8::String::New(
"Point getX method must use object notation!"));
43 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
45 return ::v8::Number::New(pt->
getX());
48 ::v8::Handle<::v8::Value>
Point_SetX(const ::v8::Arguments& args)
52 if(args.Holder().IsEmpty())
53 return ::v8::ThrowException(::v8::String::New(
"Point setX method must use object notation!"));
55 if((args.Length() != 1) || !args[0]->IsNumber())
56 return ::v8::ThrowException(::v8::String::New(
"Missing parameter or wrong type in Point setX method!"));
58 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
60 pt->
setX(args[0]->ToNumber()->Value());
62 return ::v8::Undefined();
65 ::v8::Handle<::v8::Value>
Point_GetY(const ::v8::Arguments& args)
69 if(args.Holder().IsEmpty())
70 return ::v8::ThrowException(::v8::String::New(
"Point getY method must use object notation!"));
72 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
74 return ::v8::Number::New(pt->
getY());
77 ::v8::Handle<::v8::Value>
Point_SetY(const ::v8::Arguments& args)
81 if(args.Holder().IsEmpty())
82 return ::v8::ThrowException(::v8::String::New(
"Point setY method must use object notation!"));
84 if((args.Length() != 1) || !args[0]->IsNumber())
85 return ::v8::ThrowException(::v8::String::New(
"Missing parameter or wrong type in Point setX method!"));
87 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
89 pt->
setY(args[0]->ToNumber()->Value());
91 return ::v8::Undefined();
94 ::v8::Handle<::v8::Value>
Point_GetZ(const ::v8::Arguments& args)
98 if(args.Holder().IsEmpty())
99 return ::v8::ThrowException(::v8::String::New(
"Point getZ method must use object notation!"));
101 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
103 return ::v8::Number::New(pt->
getZ());
106 ::v8::Handle<::v8::Value>
Point_SetZ(const ::v8::Arguments& args)
108 ::v8::HandleScope hs;
110 if(args.Holder().IsEmpty())
111 return ::v8::ThrowException(::v8::String::New(
"Point setZ method must use object notation!"));
113 if((args.Length() != 1) || !args[0]->IsNumber())
114 return ::v8::ThrowException(::v8::String::New(
"Missing parameter or wrong type in Point setZ method!"));
116 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
118 pt->
setZ(args[0]->ToNumber()->Value());
120 return ::v8::Undefined();
123 ::v8::Handle<::v8::Value>
Point_GetM(const ::v8::Arguments& args)
125 ::v8::HandleScope hs;
127 if(args.Holder().IsEmpty())
128 return ::v8::ThrowException(::v8::String::New(
"Point getX method must use object notation!"));
130 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
132 return ::v8::Number::New(pt->
getM());
135 ::v8::Handle<::v8::Value>
Point_SetM(const ::v8::Arguments& args)
137 ::v8::HandleScope hs;
139 if(args.Holder().IsEmpty())
140 return ::v8::ThrowException(::v8::String::New(
"Point setM method must use object notation!"));
142 if((args.Length() != 1) || !args[0]->IsNumber())
143 return ::v8::ThrowException(::v8::String::New(
"Missing parameter or wrong type in Point setM method!"));
145 te::gm::Point* pt = te::v8::common::Unwrap<te::gm::Point>(args.Holder());
147 pt->
setM(args[0]->ToNumber()->Value());
149 return ::v8::Undefined();
154 ::v8::HandleScope hs;
156 if(!args.IsConstructCall())
157 return ::v8::ThrowException(::v8::String::New(
"In order to create a point you need call its constructor like: var mypt = new TePoint(1.0, 2.0, 4326)."));
159 if(args.Holder().IsEmpty())
160 return ::v8::ThrowException(::v8::String::New(
"Point constructor must use object notation!"));
162 double x = args[0]->ToNumber()->Value();
163 double y = args[1]->ToNumber()->Value();
164 int srid = args[2]->ToInt32()->Int32Value();
166 std::auto_ptr<te::gm::Point> pt(
new te::gm::Point(x, y, srid));
172 return hs.Close(jpt);
177 ::v8::HandleScope hs;
179 if(!args.IsConstructCall())
180 return ::v8::ThrowException(::v8::String::New(
"In order to create a point you need call its constructor like: var mypt = new TePointZ(1.0, 2.0, 3.0, 4326)."));
182 if(args.Holder().IsEmpty())
183 return ::v8::ThrowException(::v8::String::New(
"Point constructor must use object notation!"));
185 double x = args[0]->ToNumber()->Value();
186 double y = args[1]->ToNumber()->Value();
187 double z = args[2]->ToNumber()->Value();
188 int srid = args[3]->ToInt32()->Int32Value();
190 std::auto_ptr<te::gm::PointZ> pt(
new te::gm::PointZ(x, y, z, srid));
196 return hs.Close(jpt);
201 ::v8::HandleScope hs;
203 if(!args.IsConstructCall())
204 return ::v8::ThrowException(::v8::String::New(
"In order to create a point you need call its constructor like: var mypt = new TePointM(1.0, 2.0, 3.0, 4326)."));
206 if(args.Holder().IsEmpty())
207 return ::v8::ThrowException(::v8::String::New(
"Point constructor must use object notation!"));
209 double x = args[0]->ToNumber()->Value();
210 double y = args[1]->ToNumber()->Value();
211 double m = args[2]->ToNumber()->Value();
212 int srid = args[3]->ToInt32()->Int32Value();
214 std::auto_ptr<te::gm::PointM> pt(
new te::gm::PointM(x, y, m, srid));
220 return hs.Close(jpt);
225 ::v8::HandleScope hs;
227 if(!args.IsConstructCall())
228 return ::v8::ThrowException(::v8::String::New(
"In order to create a point you need call its constructor like: var mypt = new TePointZM(1.0, 2.0, 3.0, 4.0, 4326)."));
230 if(args.Holder().IsEmpty())
231 return ::v8::ThrowException(::v8::String::New(
"Point constructor must use object notation!"));
233 double x = args[0]->ToNumber()->Value();
234 double y = args[1]->ToNumber()->Value();
235 double z = args[2]->ToNumber()->Value();
236 double m = args[3]->ToNumber()->Value();
237 int srid = args[4]->ToInt32()->Int32Value();
239 std::auto_ptr<te::gm::PointZM> pt(
new te::gm::PointZM(x, y, z, m, srid));
245 return hs.Close(jpt);
250 ::v8::HandleScope hs;
252 ::v8::Local<::v8::FunctionTemplate> jspt = ::v8::FunctionTemplate::New(
Point_Constructor);
253 ::v8::Local<::v8::FunctionTemplate> jsptz = ::v8::FunctionTemplate::New(
PointZ_Constructor);
254 ::v8::Local<::v8::FunctionTemplate> jsptm = ::v8::FunctionTemplate::New(
PointM_Constructor);
255 ::v8::Local<::v8::FunctionTemplate> jsptzm = ::v8::FunctionTemplate::New(
PointZM_Constructor);
257 global->Set(::v8::String::New(
"TePoint"), jspt->GetFunction());
258 global->Set(::v8::String::New(
"TePointZ"), jsptz->GetFunction());
259 global->Set(::v8::String::New(
"TePointM"), jsptm->GetFunction());
260 global->Set(::v8::String::New(
"TePointZM"), jsptzm->GetFunction());
270 ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
271 result->Inherit(geomTpl);
273 ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
275 prototype->Set(::v8::String::NewSymbol(
"getX"), ::v8::FunctionTemplate::New(
Point_GetX));
276 prototype->Set(::v8::String::NewSymbol(
"setX"), ::v8::FunctionTemplate::New(
Point_SetX));
277 prototype->Set(::v8::String::NewSymbol(
"getY"), ::v8::FunctionTemplate::New(
Point_GetY));
278 prototype->Set(::v8::String::NewSymbol(
"setY"), ::v8::FunctionTemplate::New(
Point_SetY));
279 prototype->Set(::v8::String::NewSymbol(
"getZ"), ::v8::FunctionTemplate::New(
Point_GetZ));
280 prototype->Set(::v8::String::NewSymbol(
"setZ"), ::v8::FunctionTemplate::New(
Point_SetZ));
281 prototype->Set(::v8::String::NewSymbol(
"getM"), ::v8::FunctionTemplate::New(
Point_GetM));
282 prototype->Set(::v8::String::NewSymbol(
"setM"), ::v8::FunctionTemplate::New(
Point_SetM));
::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.
::v8::Handle<::v8::Value > Point_SetX(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Point_GetX(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Point_GetM(const ::v8::Arguments &args)
void RegisterPoint(::v8::Local<::v8::Object > &global)
It register the Point class.
::v8::Handle<::v8::Value > Point_GetY(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > PointM_Constructor(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Point_GetZ(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Point_Constructor(const ::v8::Arguments &args)
const double & getY() const
It returns the Point y-coordinate value.
A point with x and y coordinate values.
void setM(const double &m)
It sets the Point m-coordinate value.
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
::v8::Persistent<::v8::FunctionTemplate > & GetGeometryTemplate()
It returns a reference to the persistent template of a Geometry object.
void setX(const double &x)
It sets the Point x-coordinate value.
::v8::Handle<::v8::Value > Point_SetZ(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > Point_SetY(const ::v8::Arguments &args)
::v8::Handle<::v8::Value > PointZM_Constructor(const ::v8::Arguments &args)
const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
::v8::Handle<::v8::Value > Point_SetM(const ::v8::Arguments &args)
void setY(const double &y)
It sets the Point y-coordinate value.
static::v8::Persistent<::v8::FunctionTemplate > sg_point_template
const double & getX() const
It returns the Point x-coordinate value.
::v8::Handle<::v8::Value > PointZ_Constructor(const ::v8::Arguments &args)
void setZ(const double &z)
It sets the Point z-coordinate value.