@@ -57,25 +57,18 @@ using pdal::DimType;
57
57
// / \param[in] dims JavaArray of DimTypes
58
58
// / \param[in] bufSize Dims sum size
59
59
// / \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 ) {
61
61
for (jint i = 0 ; i < env->GetArrayLength (dims); i++) {
62
62
jobject jDimType = reinterpret_cast <jobject>(env->GetObjectArrayElement (dims, i));
63
63
jclass cDimType = env->GetObjectClass (jDimType);
64
64
jfieldID fid = env->GetFieldID (cDimType, " id" , " Ljava/lang/String;" );
65
65
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" );
68
66
69
67
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 )));
73
69
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);
79
72
}
80
73
}
81
74
@@ -159,7 +152,7 @@ JNIEXPORT jbyteArray JNICALL Java_io_pdal_PointView_getPackedPoint
159
152
DimTypeList dimTypes;
160
153
161
154
// calculate result buffer length (for one point) and get dimTypes
162
- convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes);
155
+ convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes, pl );
163
156
164
157
char *buf = new char [pointSize];
165
158
@@ -186,7 +179,7 @@ JNIEXPORT jbyteArray JNICALL Java_io_pdal_PointView_getPackedPoints
186
179
DimTypeList dimTypes;
187
180
188
181
// calculate result buffer length (for one point) and get dimTypes
189
- convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes);
182
+ convertDimTypeJavaArrayToVector (env, dims, &pointSize, &dimTypes, pl );
190
183
191
184
// reading all points
192
185
std::size_t bufSize = pointSize * pv->size ();
0 commit comments