/*
 * Class:     mapnik_FeatureSet
 * Method:    getEnvelope
 * Signature: ()Lmapnik/Box2d;
 */
JNIEXPORT jobject JNICALL Java_mapnik_FeatureSet_getEnvelope
(JNIEnv *env, jobject fsobj)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	return box2dFromNative(env, (*fp)->envelope());
	TRAILER(0);
}
/*
 * Class:     mapnik_FeatureSet
 * Method:    getId
 * Signature: ()I
 */
JNIEXPORT jint JNICALL Java_mapnik_FeatureSet_getId
  (JNIEnv *env, jobject fsobj)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	return (*fp)->id();
	TRAILER(0);
}
Beispiel #3
0
/*
 * Class:     mapnik_FeatureSet
 * Method:    getProperty
 * Signature: (Ljava/lang/String;)Ljava/lang/Object;
 */
JNIEXPORT jobject JNICALL Java_mapnik_FeatureSet_getProperty
  (JNIEnv *env, jobject fsobj, jstring namej)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	refjavastring name(env,namej);

	// Convert the value
	mapnik::value_type const& value= (*fp)->get(name.stringz);
	return mapnik::value_type::visit(value, value_to_java(env));
	TRAILER(0);
}
/*
 * Class:     mapnik_FeatureSet
 * Method:    getProperty
 * Signature: (Ljava/lang/String;)Ljava/lang/Object;
 */
JNIEXPORT jobject JNICALL Java_mapnik_FeatureSet_getProperty
  (JNIEnv *env, jobject fsobj, jstring namej)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	refjavastring name(env,namej);
	std::map<std::string,mapnik::value>::iterator iter=(*fp)->props().find(name.stringz);
	if (iter==(*fp)->end()) return 0;

	// Convert the value
	mapnik::value_base const& value=iter->second.base();
	return boost::apply_visitor(value_to_java(env), value);
	TRAILER(0);
}
/*
 * Class:     mapnik_FeatureSet
 * Method:    getPropertyNames
 * Signature: ()Ljava/util/Set;
 */
JNIEXPORT jobject JNICALL Java_mapnik_FeatureSet_getPropertyNames
(JNIEnv *env, jobject fsobj)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	jobject ret=env->NewObject(CLASS_HASHSET, CTOR_HASHSET);
	for (std::map<std::string,mapnik::value>::iterator iter=(*fp)->begin(); iter!=(*fp)->end(); iter++) {
		std::string const& name(iter->first);
		env->CallBooleanMethod(ret, METHOD_HASHSET_ADD, env->NewStringUTF(name.c_str()));
	}

	return ret;
	TRAILER(0);
}
/*
 * Class:     mapnik_FeatureSet
 * Method:    _loadGeometries
 * Signature: ()[Lmapnik/Geometry;
 */
JNIEXPORT jobjectArray JNICALL Java_mapnik_FeatureSet__1loadGeometries
	(JNIEnv *env, jobject fsobj)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	unsigned count=(*fp)->num_geometries();
	jobjectArray ret=env->NewObjectArray(count, CLASS_GEOMETRY, (jobject)0);
	for (unsigned index=0; index<count; index++) {
		mapnik::geometry_type &g((*fp)->get_geometry(index));
		jobject gobject=env->NewObject(CLASS_GEOMETRY, CTOR_NATIVEOBJECT);
		env->SetLongField(gobject, FIELD_PTR, FROM_POINTER(&g));
		env->SetObjectArrayElement(ret, index, gobject);
	}

	return ret;
	TRAILER(0);
}
/*
 * Class:     mapnik_FeatureSet
 * Method:    _next
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_mapnik_FeatureSet__1next
	(JNIEnv *env, jobject fsobj)
{
	PREAMBLE;
	mapnik::featureset_ptr* fsp=LOAD_FEATURESET_POINTER(fsobj);
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (fp) delete fp;

	mapnik::feature_ptr next=(*fsp)->next();
	if (!next) {
		// End
		env->SetLongField(fsobj, FIELD_FEATURESET_FEATURE_PTR, 0);
		return false;
	} else {
		// Another
		fp=new mapnik::feature_ptr(next);
		env->SetLongField(fsobj, FIELD_FEATURESET_FEATURE_PTR, FROM_POINTER(fp));
		return true;
	}

	TRAILER(false);
}
Beispiel #8
0
/*
 * Class:     mapnik_FeatureSet
 * Method:    _loadGeometries
 * Signature: ()[Lmapnik/Geometry;
 */
JNIEXPORT jobjectArray JNICALL Java_mapnik_FeatureSet__1loadGeometries
	(JNIEnv *env, jobject fsobj)
{
	PREAMBLE;
	mapnik::feature_ptr* fp=LOAD_FEATURE_POINTER(fsobj);
	if (!fp) {
		throw_runtime_exception(env, "No feature loaded");
		return 0;
	}

	// Mapnik 3.x only holds one geometry<> per feature_impl.
	// (In Mapnik 2.x this used to be a variable-length vector of geometries.)
	unsigned count=1;
	jobjectArray ret=env->NewObjectArray(count, CLASS_GEOMETRY, (jobject)0);
	for (unsigned index=0; index<count; index++) {
		mapnik::geometry::geometry<double> const &g((*fp)->get_geometry());
		jobject gobject=env->NewObject(CLASS_GEOMETRY, CTOR_NATIVEOBJECT);
		env->SetLongField(gobject, FIELD_PTR, FROM_POINTER(&g));
		env->SetObjectArrayElement(ret, index, gobject);
	}

	return ret;
	TRAILER(0);
}