本文整理汇总了C++中Local::IntegerValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Local::IntegerValue方法的具体用法?C++ Local::IntegerValue怎么用?C++ Local::IntegerValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Local
的用法示例。
在下文中一共展示了Local::IntegerValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThrowException
Handle<Value> Feature::addAttributes(const Arguments& args)
{
HandleScope scope;
Feature* fp = ObjectWrap::Unwrap<Feature>(args.This());
if (args.Length() > 0 ) {
Local<Value> value = args[0];
if (value->IsNull() || value->IsUndefined()) {
return ThrowException(Exception::TypeError(String::New("object expected")));
} else {
Local<Object> attr = value->ToObject();
try
{
Local<Array> names = attr->GetPropertyNames();
uint32_t i = 0;
uint32_t a_length = names->Length();
boost::scoped_ptr<mapnik::transcoder> tr(new mapnik::transcoder("utf8"));
while (i < a_length) {
Local<Value> name = names->Get(i)->ToString();
Local<Value> value = attr->Get(name);
if (value->IsString()) {
UnicodeString ustr = tr->transcode(TOSTR(value));
boost::put(*fp->get(),TOSTR(name),ustr);
} else if (value->IsNumber()) {
double num = value->NumberValue();
// todo - round
if (num == value->IntegerValue()) {
int integer = value->IntegerValue();
boost::put(*fp->get(),TOSTR(name),integer);
} else {
double dub_val = value->NumberValue();
boost::put(*fp->get(),TOSTR(name),dub_val);
}
} else {
std::clog << "unhandled type for property: " << TOSTR(name) << "\n";
}
i++;
}
}
catch (const std::exception & ex )
{
return ThrowException(Exception::Error(
String::New(ex.what())));
}
catch (...) {
return ThrowException(Exception::Error(
String::New("Unknown exception happended - please report bug")));
}
}
}
return Undefined();
}
示例2: TryConvertToJavaLong
bool ArgConverter::TryConvertToJavaLong(const Local<Value>& value, jlong& javaLong)
{
bool success = false;
if (!value.IsEmpty())
{
if (value->IsNumber() || value->IsNumberObject())
{
javaLong = (jlong)value->IntegerValue();
success = true;
}
else if (value->IsObject())
{
auto obj = Local<Object>::Cast(value);
auto isJavaLongValue = obj->GetHiddenValue(V8StringConstants::GetJavaLong());
if (!isJavaLongValue.IsEmpty() && isJavaLongValue->BooleanValue())
{
javaLong = (jlong)ConvertToJavaLong(value);
success = true;
}
}
}
return success;
}
示例3:
static void
gum_v8_stalker_on_set_queue_capacity (Local<String> property,
Local<Value> value,
const PropertyCallbackInfo<void> & info)
{
GumV8Stalker * self = static_cast<GumV8Stalker *> (
info.Data ().As<External> ()->Value ());
(void) property;
self->queue_capacity = value->IntegerValue ();
}
示例4: styleIgnoredSetter
void FeatureDefn::styleIgnoredSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
HandleScope scope;
FeatureDefn *def = ObjectWrap::Unwrap<FeatureDefn>(info.This());
if(!value->IsBoolean()){
NODE_THROW("styleIgnored must be a boolean");
return;
}
def->this_->SetStyleIgnored(value->IntegerValue());
}
示例5: geomTypeSetter
void FeatureDefn::geomTypeSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
HandleScope scope;
FeatureDefn *def = ObjectWrap::Unwrap<FeatureDefn>(info.This());
if(!value->IsInt32()){
NODE_THROW("geomType must be an integer");
return;
}
def->this_->SetGeomType(OGRwkbGeometryType(value->IntegerValue()));
}
示例6: precisionSetter
void FieldDefn::precisionSetter(Local<String> property, Local<Value> value, const AccessorInfo &info)
{
HandleScope scope;
FieldDefn *def = ObjectWrap::Unwrap<FieldDefn>(info.This());
if(!value->IsInt32()){
NODE_THROW("precision must be an integer");
return;
}
def->this_->SetPrecision(value->IntegerValue());
}
示例7: set_prop
void Color::set_prop(Local<String> property,
Local<Value> value,
const AccessorInfo& info)
{
HandleScope scope;
Color* c = ObjectWrap::Unwrap<Color>(info.This());
std::string a = TOSTR(property);
if (!value->IsNumber())
ThrowException(Exception::TypeError(
String::New("color channel value must be an integer")));
if (a == "a") {
c->get()->set_alpha(value->IntegerValue());
} else if (a == "r") {
c->get()->set_red(value->IntegerValue());
} else if (a == "g") {
c->get()->set_green(value->IntegerValue());
} else if (a == "b") {
c->get()->set_blue(value->IntegerValue());
}
}
示例8: PlatformLengthSet
void ArrayType::PlatformLengthSet(Local<String> property, Local<Value> value, const AccessorInfo& info) {
HandleScope scope;
jobject ob = (jobject)info.This()->GetPointerFromInternalField(0);
ArrayType *arr = (ArrayType *)info.This()->GetPointerFromInternalField(1);
JNIEnv *jniEnv = arr->env->getVM()->getJNIEnv();
if(value.IsEmpty()) {
ThrowException(Exception::ReferenceError(String::New("No value specified")));
return;
}
jint length = (jint)value->IntegerValue();
jniEnv->CallVoidMethod(ob, arr->setLength, length);
arr->env->getConv()->CheckForException(jniEnv);
}
示例9: SetArrayElement
void ArrayElementAccessor::SetArrayElement(const Local<Object>& array, uint32_t index, const string& arraySignature, Local<Value>& value)
{
JEnv env;
Isolate* isolate = Isolate::GetCurrent();
HandleScope handleScope(isolate);
jweak arr = objectManager->GetJavaObjectByJsObject(array);
const string elementSignature = arraySignature.substr(1);
jboolean isCopy = false;
if (elementSignature == "Z") //bool
{
jboolean boolElementValue = (jboolean) value->BooleanValue();
jbooleanArray boolArr = reinterpret_cast<jbooleanArray>(arr);
env.SetBooleanArrayRegion(boolArr, index, 1, &boolElementValue);
}
else if (elementSignature == "B") //byte
{
jbyte byteElementValue = (jbyte) value->Int32Value();
jbyteArray byteArr = reinterpret_cast<jbyteArray>(arr);
env.SetByteArrayRegion(byteArr, index, 1, &byteElementValue);
}
else if (elementSignature == "C") //char
{
String::Utf8Value utf8(value->ToString());
JniLocalRef s(env.NewString((jchar*) *utf8, 1));
const char* singleChar = env.GetStringUTFChars(s, &isCopy);
jchar charElementValue = *singleChar;
env.ReleaseStringUTFChars(s, singleChar);
jcharArray charArr = reinterpret_cast<jcharArray>(arr);
env.SetCharArrayRegion(charArr, index, 1, &charElementValue);
}
else if (elementSignature == "S") //short
{
jshort shortElementValue = (jshort) value->Int32Value();
jshortArray shortArr = reinterpret_cast<jshortArray>(arr);
env.SetShortArrayRegion(shortArr, index, 1, &shortElementValue);
}
else if (elementSignature == "I") //int
{
jint intElementValue = value->Int32Value();
jintArray intArr = reinterpret_cast<jintArray>(arr);
env.SetIntArrayRegion(intArr, index, 1, &intElementValue);
}
else if (elementSignature == "J") //long
{
jlong longElementValue;
if (value->IsObject())
{
longElementValue = (jlong) ArgConverter::ConvertToJavaLong(value);
}
else
{
longElementValue = (jlong) value->IntegerValue();
}
jlongArray longArr = reinterpret_cast<jlongArray>(arr);
env.SetLongArrayRegion(longArr, index, 1, &longElementValue);
}
else if (elementSignature == "F") //float
{
jfloat floatElementValue = (jfloat) value->NumberValue();
jfloatArray floatArr = reinterpret_cast<jfloatArray>(arr);
env.SetFloatArrayRegion(floatArr, index, 1, &floatElementValue);
}
else if (elementSignature == "D") //double
{
jdouble doubleElementValue = (jdouble) value->NumberValue();
jdoubleArray doubleArr = reinterpret_cast<jdoubleArray>(arr);
env.SetDoubleArrayRegion(doubleArr, index, 1, &doubleElementValue);
}
else //string or object
{
bool isReferenceType = value->IsObject() || value->IsString();
if (isReferenceType)
{
auto object = value.As<Object>();
JsArgToArrayConverter argConverter(value, false, (int)Type::Null);
if (argConverter.IsValid())
{
jobjectArray objArr = reinterpret_cast<jobjectArray>(arr);
jobject objectElementValue = argConverter.GetConvertedArg();
env.SetObjectArrayElement(objArr, index, objectElementValue);
}
else
{
JsArgToArrayConverter::Error err = argConverter.GetError();
throw NativeScriptException(string(err.msg));
}
}
else
{
throw NativeScriptException(string("Cannot assign primitive value to array of objects."));
}
}
}
示例10: ThrowException
Handle<Value> MemoryDatasource::add(const Arguments& args)
{
HandleScope scope;
if ((args.Length() != 1) || !args[0]->IsObject())
{
return ThrowException(Exception::Error(
String::New("accepts one argument: an object including x and y (or wkt) and properties")));
}
MemoryDatasource* d = node::ObjectWrap::Unwrap<MemoryDatasource>(args.This());
Local<Object> obj = args[0]->ToObject();
if (obj->Has(String::New("wkt")) || (obj->Has(String::New("x")) && obj->Has(String::New("y"))))
{
if (obj->Has(String::New("wkt")))
return ThrowException(Exception::Error(
String::New("wkt not yet supported")));
Local<Value> x = obj->Get(String::New("x"));
Local<Value> y = obj->Get(String::New("y"));
if (!x->IsUndefined() && x->IsNumber() && !y->IsUndefined() && y->IsNumber())
{
mapnik::geometry_type * pt = new mapnik::geometry_type(MAPNIK_POINT);
pt->move_to(x->NumberValue(),y->NumberValue());
#if MAPNIK_VERSION >= 200100
mapnik::context_ptr ctx = MAPNIK_MAKE_SHARED<mapnik::context_type>();
mapnik::feature_ptr feature(mapnik::feature_factory::create(ctx,d->feature_id_));
#else
mapnik::feature_ptr feature(mapnik::feature_factory::create(d->feature_id_));
#endif
++(d->feature_id_);
feature->add_geometry(pt);
if (obj->Has(String::New("properties")))
{
Local<Value> props = obj->Get(String::New("properties"));
if (props->IsObject())
{
Local<Object> p_obj = props->ToObject();
Local<Array> names = p_obj->GetPropertyNames();
unsigned int i = 0;
unsigned int a_length = names->Length();
while (i < a_length)
{
Local<Value> name = names->Get(i)->ToString();
// if name in q.property_names() ?
Local<Value> value = p_obj->Get(name);
if (value->IsString()) {
mapnik::value_unicode_string ustr = d->tr_->transcode(TOSTR(value));
#if MAPNIK_VERSION >= 200100
feature->put_new(TOSTR(name),ustr);
#else
boost::put(*feature,TOSTR(name),ustr);
#endif
} else if (value->IsNumber()) {
double num = value->NumberValue();
// todo - round
if (num == value->IntegerValue()) {
#if MAPNIK_VERSION >= 200100
feature->put_new(TOSTR(name),static_cast<node_mapnik::value_integer>(value->IntegerValue()));
#else
boost::put(*feature,TOSTR(name),static_cast<int>(value->IntegerValue()));
#endif
} else {
double dub_val = value->NumberValue();
#if MAPNIK_VERSION >= 200100
feature->put_new(TOSTR(name),dub_val);
#else
boost::put(*feature,TOSTR(name),dub_val);
#endif
}
} else if (value->IsNull()) {
#if MAPNIK_VERSION >= 200100
feature->put_new(TOSTR(name),mapnik::value_null());
#else
boost::put(*feature,TOSTR(name),mapnik::value_null());
#endif
} else {
std::clog << "unhandled type for property: " << TOSTR(name) << "\n";
}
i++;
}
}
}
mapnik::memory_datasource *cache = dynamic_cast<mapnik::memory_datasource *>(d->datasource_.get());
cache->push(feature);
}
}
return scope.Close(False());
}
示例11: GetParametersFromArray
Parameter* ODBC::GetParametersFromArray (Local<Array> values, int *paramCount) {
DEBUG_PRINTF("ODBC::GetParametersFromArray\n");
*paramCount = values->Length();
Parameter* params = NULL;
if (*paramCount > 0) {
params = (Parameter *) malloc(*paramCount * sizeof(Parameter));
}
for (int i = 0; i < *paramCount; i++) {
Local<Value> value = values->Get(i);
params[i].ColumnSize = 0;
params[i].StrLen_or_IndPtr = SQL_NULL_DATA;
params[i].BufferLength = 0;
params[i].DecimalDigits = 0;
DEBUG_PRINTF("ODBC::GetParametersFromArray - param[%i].length = %lli\n",
i, params[i].StrLen_or_IndPtr);
if (value->IsString()) {
Local<String> string = value->ToString();
int length = string->Length();
params[i].ValueType = SQL_C_TCHAR;
params[i].ColumnSize = 0; //SQL_SS_LENGTH_UNLIMITED
#ifdef UNICODE
params[i].ParameterType = SQL_WVARCHAR;
params[i].BufferLength = (length * sizeof(uint16_t)) + sizeof(uint16_t);
#else
params[i].ParameterType = SQL_VARCHAR;
params[i].BufferLength = string->Utf8Length() + 1;
#endif
params[i].ParameterValuePtr = malloc(params[i].BufferLength);
params[i].StrLen_or_IndPtr = SQL_NTS;//params[i].BufferLength;
#ifdef UNICODE
string->Write((uint16_t *) params[i].ParameterValuePtr);
#else
string->WriteUtf8((char *) params[i].ParameterValuePtr);
#endif
DEBUG_PRINTF("ODBC::GetParametersFromArray - IsString(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli value=%s\n",
i, params[i].ValueType, params[i].ParameterType,
params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr,
(char*) params[i].ParameterValuePtr);
}
else if (value->IsNull()) {
params[i].ValueType = SQL_C_DEFAULT;
params[i].ParameterType = SQL_VARCHAR;
params[i].StrLen_or_IndPtr = SQL_NULL_DATA;
DEBUG_PRINTF("ODBC::GetParametersFromArray - IsNull(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli\n",
i, params[i].ValueType, params[i].ParameterType,
params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr);
}
else if (value->IsInt32()) {
int64_t *number = new int64_t(value->IntegerValue());
params[i].ValueType = SQL_C_SBIGINT;
params[i].ParameterType = SQL_BIGINT;
params[i].ParameterValuePtr = number;
params[i].StrLen_or_IndPtr = 0;
DEBUG_PRINTF("ODBC::GetParametersFromArray - IsInt32(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli value=%lld\n",
i, params[i].ValueType, params[i].ParameterType,
params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr,
*number);
}
else if (value->IsNumber()) {
double *number = new double(value->NumberValue());
params[i].ValueType = SQL_C_DOUBLE;
params[i].ParameterType = SQL_DECIMAL;
params[i].ParameterValuePtr = number;
params[i].BufferLength = sizeof(double);
params[i].StrLen_or_IndPtr = params[i].BufferLength;
params[i].DecimalDigits = 7;
params[i].ColumnSize = sizeof(double);
DEBUG_PRINTF("ODBC::GetParametersFromArray - IsNumber(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli value=%f\n",
i, params[i].ValueType, params[i].ParameterType,
params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr,
*number);
}
else if (value->IsBoolean()) {
bool *boolean = new bool(value->BooleanValue());
params[i].ValueType = SQL_C_BIT;
params[i].ParameterType = SQL_BIT;
params[i].ParameterValuePtr = boolean;
params[i].StrLen_or_IndPtr = 0;
DEBUG_PRINTF("ODBC::GetParametersFromArray - IsBoolean(): params[%i] c_type=%i type=%i buffer_length=%lli size=%lli length=%lli\n",
i, params[i].ValueType, params[i].ParameterType,
params[i].BufferLength, params[i].ColumnSize, params[i].StrLen_or_IndPtr);
}
}
return params;
}
示例12: ThrowException
Handle<Value> Feature::addAttributes(const Arguments& args)
{
HandleScope scope;
Feature* fp = node::ObjectWrap::Unwrap<Feature>(args.This());
if (args.Length() > 0 ) {
Local<Value> val = args[0];
if (val->IsNull() || val->IsUndefined()) {
return ThrowException(Exception::TypeError(String::New("object expected")));
} else {
Local<Object> attr = val->ToObject();
try
{
Local<Array> names = attr->GetPropertyNames();
unsigned int i = 0;
unsigned int a_length = names->Length();
boost::scoped_ptr<mapnik::transcoder> tr(new mapnik::transcoder("utf8"));
while (i < a_length) {
Local<Value> name = names->Get(i)->ToString();
Local<Value> value = attr->Get(name);
if (value->IsString()) {
mapnik::value_unicode_string ustr = tr->transcode(TOSTR(value));
#if MAPNIK_VERSION >= 200100
fp->get()->put_new(TOSTR(name),ustr);
#else
boost::put(*fp->get(),TOSTR(name),ustr);
#endif
} else if (value->IsNumber()) {
double num = value->NumberValue();
// todo - round
if (num == value->IntegerValue()) {
#if MAPNIK_VERSION >= 200100
fp->get()->put_new(TOSTR(name),static_cast<node_mapnik::value_integer>(value->IntegerValue()));
#else
boost::put(*fp->get(),TOSTR(name),static_cast<int>(value->IntegerValue()));
#endif
} else {
double dub_val = value->NumberValue();
#if MAPNIK_VERSION >= 200100
fp->get()->put_new(TOSTR(name),dub_val);
#else
boost::put(*fp->get(),TOSTR(name),dub_val);
#endif
}
} else if (value->IsNull()) {
#if MAPNIK_VERSION >= 200100
fp->get()->put_new(TOSTR(name),mapnik::value_null());
#else
boost::put(*fp->get(),TOSTR(name),mapnik::value_null());
#endif
} else {
std::clog << "unhandled type for property: " << TOSTR(name) << "\n";
}
i++;
}
}
catch (std::exception const& ex )
{
return ThrowException(Exception::Error(
String::New(ex.what())));
}
}
}
return Undefined();
}
示例13: TransformParameter
bool CQueryParameter::TransformParameter( Isolate* isolate, Local< Value > value, sBindParameter** pOutParam )
{
HandleScope scope( isolate );
Local< Context > context = isolate->GetCurrentContext( );
sBindParameter* pParameter = *pOutParam;
if( value->IsNull( ) )
{
pParameter->SetNull( );
}
else if( value->IsString( ) )
{
pParameter->SetString( value.As<String>( ) );
}
else if( value->IsBoolean( ) )
{
pParameter->SetBool( value->BooleanValue( context ).FromJust( ) );
}
else if( value->IsInt32( ) )
{
pParameter->SetInt( value->Int32Value( context ).FromJust( ) );
}
else if( value->IsUint32( ) )
{
pParameter->SetUInt( value->Uint32Value( context ).FromJust( ) );
}
else if( value->IsNumber( ) )
{
double d = value->NumberValue( context ).FromJust( );
if( _isnan( d ) || !_finite( d ) )
{
return false;
}
else if( d == floor( d ) &&
d >= std::numeric_limits<int64_t>::min( ) &&
d <= std::numeric_limits<int64_t>::max( )
)
{
pParameter->SetInt64( value->IntegerValue( context ).FromJust( ) );
}
else
{
pParameter->SetDouble( value->NumberValue( context ).FromJust( ) );
}
}
else if( value->IsDate( ) )
{
Local<Date> dateObject = value.As<Date>( );
pParameter->SetDate( dateObject->NumberValue( context ).FromJust( ) );
}
else if( value->IsObject( ) )
{
Local<Object> objValue = value.As<Object>( );
if( node::Buffer::HasInstance( value ) )
{
pParameter->SetBuffer( isolate, objValue );
}
else
{
Local< String > strId = String::NewFromUtf8( isolate, "_objId", NewStringType::kNormal ).ToLocalChecked( );
if( objValue->HasRealNamedProperty( context, strId ).FromJust( ) )
{
Local< Uint32 > numTypeId = objValue->Get( context, strId ).ToLocalChecked( ).As< Uint32 >( );
uint32_t nType = numTypeId->Int32Value( context ).FromJust( );
switch( nType )
{
case ID_INPUT_STREAM:
{
Local<Value> type = objValue->Get(
context, String::NewFromUtf8( isolate, "type", NewStringType::kNormal ).ToLocalChecked( )
).ToLocalChecked( );
Local<Value> stream = objValue->Get(
context, String::NewFromUtf8( isolate, "stream", NewStringType::kNormal ).ToLocalChecked( )
).ToLocalChecked( );
Local<Value> length = objValue->Get(
context, String::NewFromUtf8( isolate, "length", NewStringType::kNormal ).ToLocalChecked( )
).ToLocalChecked( );
pParameter->SetStream( isolate, type->Uint32Value( context ).FromJust( ), stream, static_cast< SQLUINTEGER >( length->IntegerValue( context ).FromJust( ) ) );
break;
}
case ID_NUMERIC_VALUE:
{
Local< Value > precision = objValue->Get(
context, String::NewFromUtf8( isolate, "precision", NewStringType::kNormal ).ToLocalChecked( )
).ToLocalChecked( );
Local<Value> scale = objValue->Get(
context, String::NewFromUtf8( isolate, "scale", NewStringType::kNormal ).ToLocalChecked( )
).ToLocalChecked( );
//.........这里部分代码省略.........
示例14: ThrowException
Handle<Value> MemoryDatasource::add(const Arguments& args)
{
HandleScope scope;
if ((args.Length() != 1) || !args[0]->IsObject())
{
return ThrowException(Exception::Error(
String::New("accepts one argument: an object including x and y (or wkt) and properties")));
}
MemoryDatasource* d = ObjectWrap::Unwrap<MemoryDatasource>(args.This());
Local<Object> obj = args[0]->ToObject();
if (obj->Has(String::New("wkt")) || (obj->Has(String::New("x")) && obj->Has(String::New("y"))))
{
if (obj->Has(String::New("wkt")))
return ThrowException(Exception::Error(
String::New("wkt not yet supported")));
Local<Value> x = obj->Get(String::New("x"));
Local<Value> y = obj->Get(String::New("y"));
if (!x->IsUndefined() && x->IsNumber() && !y->IsUndefined() && y->IsNumber())
{
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(x->NumberValue(),y->NumberValue());
mapnik::feature_ptr feature(new mapnik::Feature(d->feature_id_));
++(d->feature_id_);
feature->add_geometry(pt);
if (obj->Has(String::New("properties")))
{
Local<Value> props = obj->Get(String::New("properties"));
if (props->IsObject())
{
Local<Object> p_obj = props->ToObject();
Local<Array> names = p_obj->GetPropertyNames();
uint32_t i = 0;
uint32_t a_length = names->Length();
while (i < a_length)
{
Local<Value> name = names->Get(i)->ToString();
// if name in q.property_names() ?
Local<Value> value = p_obj->Get(name);
if (value->IsString()) {
UnicodeString ustr = d->tr_->transcode(TOSTR(value));
boost::put(*feature,TOSTR(name),ustr);
} else if (value->IsNumber()) {
double num = value->NumberValue();
// todo - round
if (num == value->IntegerValue()) {
int integer = value->IntegerValue();
boost::put(*feature,TOSTR(name),integer);
} else {
double dub_val = value->NumberValue();
boost::put(*feature,TOSTR(name),dub_val);
}
} else {
std::clog << "unhandled type for property: " << TOSTR(name) << "\n";
}
i++;
}
}
}
mapnik::memory_datasource *cache = dynamic_cast<mapnik::memory_datasource *>(d->datasource_.get());
cache->push(feature);
}
}
return scope.Close(Boolean::New(false));
}
示例15: next
mapnik::feature_ptr next()
{
HandleScope scope;
TryCatch try_catch;
Local<Value> argv[2] = { Integer::New(feature_id_), obj_ };
Local<Value> val = ds_->cb_->Call(Context::GetCurrent()->Global(), 2, argv);
if (try_catch.HasCaught()) {
FatalException(try_catch);
}
else
{
if (!val->IsUndefined())
{
if (val->IsObject())
{
Local<Object> obj = val->ToObject();
if (obj->Has(String::New("x")) && obj->Has(String::New("y")))
{
Local<Value> x = obj->Get(String::New("x"));
Local<Value> y = obj->Get(String::New("y"));
if (!x->IsUndefined() && x->IsNumber() && !y->IsUndefined() && y->IsNumber())
{
mapnik::geometry_type * pt = new mapnik::geometry_type(mapnik::Point);
pt->move_to(x->NumberValue(),y->NumberValue());
mapnik::feature_ptr feature(mapnik::feature_factory::create(feature_id_));
++feature_id_;
feature->add_geometry(pt);
if (obj->Has(String::New("properties")))
{
Local<Value> props = obj->Get(String::New("properties"));
if (props->IsObject())
{
Local<Object> p_obj = props->ToObject();
Local<Array> names = p_obj->GetPropertyNames();
uint32_t i = 0;
uint32_t a_length = names->Length();
while (i < a_length)
{
Local<Value> name = names->Get(i)->ToString();
// if name in q.property_names() ?
Local<Value> value = p_obj->Get(name);
if (value->IsString()) {
UnicodeString ustr = tr_->transcode(TOSTR(value));
boost::put(*feature,TOSTR(name),ustr);
} else if (value->IsNumber()) {
double num = value->NumberValue();
// todo - round
if (num == value->IntegerValue()) {
int integer = value->IntegerValue();
boost::put(*feature,TOSTR(name),integer);
} else {
double dub_val = value->NumberValue();
boost::put(*feature,TOSTR(name),dub_val);
}
}
i++;
}
}
}
return feature;
}
}
}
}
}
return mapnik::feature_ptr();
}