Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

sOgrInput and NULL geometries (TOS Spatial 5.1.1)

Hi,
I don't know if this forum is the correct place to post bug reports or patches (haven't seen a project in TalendForge's JIRA specifically for the SDI plugin), please inform me if this should go somewhere else.
I've encountered an issue while using the sOgrInput component in a job, when trying to read a MapInfo TAB file containing a NULL geometry. The job fails with a NullPointerException when reading the offending record. NULL geometries are a admittedly an uncommon and odd occurrence, but in this case I have no control over the TAB file contents.
I've been able to work around the problem and pass a NULL value by modifying the component's sOgrInput_begin.javajet code, to check when the call to org.gdal.ogr.Feature.GetGeometryRef() returns null and pass a null value instead of trying to invoke the ExportToWkt() method on the null ogrGeometry (and skip assigning the SRID as well).
Please find a patch with the fix below.
Thanks!
Etienne
----------------------------------------
.../components/sOgrInput/sOgrInput_begin.javajet | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/org.talend.sdi.designer.components.sandbox/components/sOgrInput/sOgrInput_begin.javajet b/org.talend.sdi.designer.components.sandbox/components/sOgrInput/sOgrInput_begin.javajet
index 9a23ea5..c71c259 100755
--- a/org.talend.sdi.designer.components.sandbox/components/sOgrInput/sOgrInput_begin.javajet
+++ b/org.talend.sdi.designer.components.sandbox/components/sOgrInput/sOgrInput_begin.javajet
@@ -169,10 +169,13 @@ while ((poFeature_<%=cid %> = poLayer_<%=cid %>.GetNextFeature()) != null) {

if (typeToGenerate.equals("Geometry")) {
%>
- org.talend.sdi.geometry.Geometry geometry_<%=cid %> =
- new org.talend.sdi.geometry.Geometry(
- poFeature_<%=cid %>.GetGeometryRef().ExportToWkt());
- geometry_<%=cid %>.setSRID(pszWKT_<%=cid %>);
+ org.gdal.ogr.Geometry ogrGeometry = poFeature_<%=cid %>.GetGeometryRef();
+ org.talend.sdi.geometry.Geometry geometry_<%=cid %> = ogrGeometry != null ?
+ new org.talend.sdi.geometry.Geometry(ogrGeometry.ExportToWkt()) : null;
+
+ if (geometry_<%=cid %> != null) {
+ geometry_<%=cid %>.setSRID(pszWKT_<%=cid %>);
+ }
<%=conn.getName() %>.<%=column.getLabel() %> = geometry_<%=cid %>;
<%
} else if (typeToGenerate.equals("String")) {
Labels (3)
2 Replies
Anonymous
Not applicable
Author

Hello Etienne, thanks for reporting and the patch.
You could add an issue to the new code repository issue tracker:
https://github.com/talend-spatial/talend-spatial/issues
Thanks.
Francois
Anonymous
Not applicable
Author

https://github.com/talend-spatial/talend-spatial/issues/3
Fixed thanks for the patch.
Cheers.
Francois