private void parseFeatures ( JsonParser jp ) throws IOException , SQLException { jp . nextToken ( ) ; // FIELD_NAME features // Passes all the properties until "Feature" object is found while ( ! jp . getText ( ) . equalsIgnoreCase ( GeoJsonField . FEATURES ) && ! jp . getText ( ) . equalsIgnoreCase ( GeoJsonField . CRS ) ) { jp . nextToken ( ) ; if ( jp . getCurrentToken ( ) . equals ( JsonToken . START_ARRAY ) || jp . getCurrentToken ( ) . equals ( JsonToken . START_OBJECT ) ) { jp . skipChildren ( ) ; } jp . nextToken ( ) ; } String firstParam = jp . getText ( ) ; if ( firstParam . equalsIgnoreCase ( GeoJsonField . CRS ) ) { firstParam = skipCRS ( jp ) ; } if ( firstParam . equalsIgnoreCase ( GeoJsonField . FEATURES ) ) { jp . nextToken ( ) ; // START_ARRAY [ JsonToken token = jp . nextToken ( ) ; // START_OBJECT { long batchSize = 0 ; while ( token != JsonToken . END_ARRAY ) { jp . nextToken ( ) ; // FIELD_NAME type jp . nextToken ( ) ; // VALUE_STRING Feature String geomType = jp . getText ( ) ; if ( geomType . equalsIgnoreCase ( GeoJsonField . FEATURE ) ) { if ( progress . isCanceled ( ) ) { throw new SQLException ( "Canceled by user" ) ; } Object [ ] values = parseFeature ( jp ) ; for ( int i = 0 ; i < values . length ; i ++ ) { preparedStatement . setObject ( i + 1 , values [ i ] ) ; } preparedStatement . addBatch ( ) ; batchSize ++ ; if ( batchSize >= BATCH_MAX_SIZE ) { preparedStatement . executeBatch ( ) ; preparedStatement . clearBatch ( ) ; batchSize = 0 ; } token = jp . nextToken ( ) ; //START_OBJECT new feature featureCounter ++ ; if ( nodeCountProgress ++ % readFileSizeEachNode == 0 ) { // Update Progress try { progress . setStep ( ( int ) ( ( ( double ) fc . position ( ) / fileSize ) * 100 ) ) ; } catch ( IOException ex ) { // Ignore } } if ( batchSize > 0 ) { preparedStatement . executeBatch ( ) ; } } else { throw new SQLException ( "Malformed GeoJSON file. Expected 'Feature', found '" + geomType + "'" ) ; } } //LOOP END_ARRAY ] log . info ( featureCounter + " geojson features have been imported." ) ; } else { throw new SQLException ( "Malformed GeoJSON file. Expected 'features', found '" + firstParam + "'" ) ; } }
Parses the featureCollection