当前位置: 首页>>代码示例>>C++>>正文


C++ LineString::get方法代码示例

本文整理汇总了C++中LineString::get方法的典型用法代码示例。如果您正苦于以下问题:C++ LineString::get方法的具体用法?C++ LineString::get怎么用?C++ LineString::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LineString的用法示例。


在下文中一共展示了LineString::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

Handle<Value> LineStringPoints::count(const Arguments& args)
{
	HandleScope scope;

	Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
	LineString *geom = ObjectWrap::Unwrap<LineString>(parent);

	return scope.Close(Integer::New(geom->get()->getNumPoints()));
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:9,代码来源:linestring_points.cpp

示例2: OGRPoint

Handle<Value> LineStringPoints::get(const Arguments& args)
{
	HandleScope scope;

	Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
	LineString *geom = ObjectWrap::Unwrap<LineString>(parent);

	OGRPoint *pt = new OGRPoint();
	int i;

	NODE_ARG_INT(0, "index", i);
	if(i < 0 || i >= geom->get()->getNumPoints()) {
		return scope.Close(Null());
	}

	geom->get()->getPoint(i, pt);

	return scope.Close(Point::New(pt));
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:19,代码来源:linestring_points.cpp

示例3: Undefined

Handle<Value> LineStringPoints::reverse(const Arguments& args)
{
	HandleScope scope;

	Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
	LineString *geom = ObjectWrap::Unwrap<LineString>(parent);

	geom->get()->reversePoints();

	return Undefined();
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:11,代码来源:linestring_points.cpp

示例4: NODE_THROW

Handle<Value> LineStringPoints::add(const Arguments& args)
{
	HandleScope scope;

	Handle<Object> parent = args.This()->GetHiddenValue(String::NewSymbol("parent_"))->ToObject();
	LineString *geom = ObjectWrap::Unwrap<LineString>(parent);

	int n = args.Length();

	if(n == 0) {
		return NODE_THROW("Point must be given");
	} else if(n == 1) {
		if(!args[0]->IsObject()) {
			return NODE_THROW("Point, object, or array of points expected");
		}
		if(IS_WRAPPED(args[0], Point)){
			//set from Point object
			Point* pt = ObjectWrap::Unwrap<Point>(args[0]->ToObject());
			geom->get()->addPoint(pt->get());
		} else if (args[0]->IsArray()) {
			//set from array of points
			Handle<Array> array = Handle<Array>::Cast(args[0]);
			int length = array->Length();
			for (int i = 0; i < length; i++){
				Handle<Value> element = array->Get(i);
				if(!element->IsObject()) {
					return NODE_THROW("All points must be Point objects or objects");
				}
				Handle<Object> element_obj = element->ToObject();
				if(IS_WRAPPED(element_obj, Point)){
					//set from Point object
					Point* pt = ObjectWrap::Unwrap<Point>(element_obj);
					geom->get()->addPoint(pt->get());
				} else {
					//set from object {x: 0, y: 5}
					double x, y;
					NODE_DOUBLE_FROM_OBJ(element_obj, "x", x);
					NODE_DOUBLE_FROM_OBJ(element_obj, "y", y);

					Handle<String> z_prop_name = String::NewSymbol("z");
					if (element_obj->HasOwnProperty(z_prop_name)) {
						Handle<Value> z_val = element_obj->Get(z_prop_name);
						if (!z_val->IsNumber()) {
							return NODE_THROW("z property must be number");
						}
						geom->get()->addPoint(x, y, z_val->NumberValue());
					} else {
						geom->get()->addPoint(x, y);
					}
				}
			}
		} else {
			//set from object {x: 0, y: 5}
			Handle<Object> obj = args[0]->ToObject();
			double x, y;
			NODE_DOUBLE_FROM_OBJ(obj, "x", x);
			NODE_DOUBLE_FROM_OBJ(obj, "y", y);

			Handle<String> z_prop_name = String::NewSymbol("z");
			if (obj->HasOwnProperty(z_prop_name)) {
				Handle<Value> z_val = obj->Get(z_prop_name);
				if (!z_val->IsNumber()) {
					return NODE_THROW("z property must be number");
				}
				geom->get()->addPoint(x, y, z_val->NumberValue());
			} else {
				geom->get()->addPoint(x, y);
			}
		}
	} else {
		//set x, y, z from numeric arguments
		if(!args[0]->IsNumber()){
			return NODE_THROW("Number expected for first argument");
		}
		if(!args[1]->IsNumber()){
			return NODE_THROW("Number expected for second argument");
		}
		if(n == 2){
			geom->get()->addPoint(args[0]->NumberValue(), args[1]->NumberValue());
		} else {
			if(!args[2]->IsNumber()){
				return NODE_THROW("Number expected for third argument");
			}

			geom->get()->addPoint(args[0]->NumberValue(), args[1]->NumberValue(), args[2]->NumberValue());
		}
	}

	return Undefined();
}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:90,代码来源:linestring_points.cpp


注:本文中的LineString::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。