Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type conversion error if properties instances have different numeric types in GeoJSON file #23

Open
dlutz2 opened this issue Jul 20, 2020 · 0 comments

Comments

@dlutz2
Copy link

dlutz2 commented Jul 20, 2020

If different instance of a property have different numeric types (integer, decimal) then a type conversion error results:

For instance:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          102.0,
          0.5
        ]
      },
      "properties": {
        "property1": 1.0
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          100.0,
          0.5
        ]
      },
      "properties": {
        "property1": 2
      }
    }
  ]
}

causes

2020/07/20 01:53:55 - GIS File input.0 - ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : Unexpected error
2020/07/20 01:53:55 - GIS File input.0 - ERROR (version 8.3.0.0-371, build 8.3.0.0-371 from 2019-06-11 11.09.08 by buildguy) : org.pentaho.di.core.exception.KettleValueException: 
2020/07/20 01:53:55 - GIS File input.0 - Unexpected conversion error while converting value [property Number] to a Number
2020/07/20 01:53:55 - GIS File input.0 - java.lang.Integer cannot be cast to java.lang.Double
2020/07/20 01:53:55 - GIS File input.0 - 
2020/07/20 01:53:55 - GIS File input.0 - 	at org.pentaho.di.core.row.value.ValueMetaBase.getNumber(ValueMetaBase.java:2035)
2020/07/20 01:53:55 - GIS File input.0 - 	at com.atolcd.pentaho.di.gis.io.features.FeatureConverter.getRow(FeatureConverter.java:217)
2020/07/20 01:53:55 - GIS File input.0 - 	at com.atolcd.pentaho.di.trans.steps.gisfileinput.GisFileInput.processRow(GisFileInput.java:106)
2020/07/20 01:53:55 - GIS File input.0 - 	at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62)
2020/07/20 01:53:55 - GIS File input.0 - 	at java.lang.Thread.run(Thread.java:748)

I believe the cause of this error is the assumption in the GeoJSONReader constructor (line 68):
org.wololo.geojson.Feature geoJsonfeature = ((FeatureCollection) json).getFeatures()[0];

which determines the structure of GeoJSON properties by looking at only the first feature. This will also cause any property that does not appear in the first record (or has a null value ) to be ignored. (see #22 for an issue handling null property values)

Using Kettle 8.3.0.0-371 and GIS Plugin V1.3.0

@dlutz2 dlutz2 changed the title Type conversion error if properties instances have different numeric types Type conversion error if properties instances have different numeric types in GeoJSON file Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant