@@ -57,25 +57,18 @@ using pdal::DimType;
5757// / \param[in] dims JavaArray of DimTypes
5858// / \param[in] bufSize Dims sum size
5959// / \param[in] dimTypes Vector of DimTypes
60- void convertDimTypeJavaArrayToVector (JNIEnv *env, jobjectArray dims, std::size_t *pointSize, DimTypeList *dimTypes) {
60+ void convertDimTypeJavaArrayToVector (JNIEnv *env, jobjectArray dims, std::size_t *pointSize, DimTypeList *dimTypes, PointLayoutPtr pl ) {
6161 for (jint i = 0 ; i < env->GetArrayLength (dims); i++) {
6262 jobject jDimType = reinterpret_cast <jobject>(env->GetObjectArrayElement (dims, i));
6363 jclass cDimType = env->GetObjectClass (jDimType);
6464 jfieldID fid = env->GetFieldID (cDimType, " id" , " Ljava/lang/String;" );
6565 jfieldID ftype = env->GetFieldID (cDimType, " type" , " Ljava/lang/String;" );
66- jfieldID fscale = env->GetFieldID (cDimType, " scale" , " D" );
67- jfieldID foffset = env->GetFieldID (cDimType, " offset" , " D" );
6866
6967 jstring jid = reinterpret_cast <jstring>(env->GetObjectField (jDimType, fid));
70- jstring jtype = reinterpret_cast <jstring>(env->GetObjectField (jDimType, ftype));
71- jdouble jscale = env->GetDoubleField (jDimType, fscale);
72- jdouble joffset = env->GetDoubleField (jDimType, foffset);
68+ DimType dimType = pl->findDimType (std::string (env->GetStringUTFChars (jid, 0 )));
7369
74- Id id = pdal::Dimension::id (std::string (env->GetStringUTFChars (jid, 0 )));
75- Type type = pdal::Dimension::type (std::string (env->GetStringUTFChars (jtype, 0 )));
76-
77- *pointSize += pdal::Dimension::size (type);
78- dimTypes->insert (dimTypes->begin () + i, DimType (id, type, jscale, joffset));
70+ *pointSize += pl->dimSize (dimType.m_id );
71+ dimTypes->insert (dimTypes->begin () + i, dimType);
7972 }
8073}
8174
@@ -159,7 +152,7 @@ JNIEXPORT jbyteArray JNICALL Java_io_pdal_PointView_getPackedPoint
159152 DimTypeList dimTypes;
160153
161154 // calculate result buffer length (for one point) and get dimTypes
162- convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes);
155+ convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes, pl );
163156
164157 char *buf = new char [pointSize];
165158
@@ -186,7 +179,7 @@ JNIEXPORT jbyteArray JNICALL Java_io_pdal_PointView_getPackedPoints
186179 DimTypeList dimTypes;
187180
188181 // calculate result buffer length (for one point) and get dimTypes
189- convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes);
182+ convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes, pl );
190183
191184 // reading all points
192185 std::size_t bufSize = pointSize * pv->size ();
0 commit comments