public NunaliitGeometry getOriginalGometry ( ) throws Exception { NunaliitGeometryImpl result = null ; JSONObject jsonDoc = getJSONObject ( ) ; JSONObject nunalitt_geom = jsonDoc . optJSONObject ( CouchNunaliitConstants . DOC_KEY_GEOMETRY ) ; if ( null != nunalitt_geom ) { // By default, the wkt is the geometry String wkt = nunalitt_geom . optString ( "wkt" , null ) ; // Check if a simplified structure is specified JSONObject simplified = nunalitt_geom . optJSONObject ( "simplified" ) ; if ( null == simplified ) { logger . trace ( "Simplified structure is not available" ) ; } else { logger . trace ( "Accessing simplified structure" ) ; String originalAttachmentName = simplified . optString ( "original" , null ) ; if ( null == originalAttachmentName ) { throw new Exception ( "Original attachment name not found in simplified structure" ) ; } else { // The original geometry is in the specified attachment Attachment attachment = getAttachmentByName ( originalAttachmentName ) ; if ( null == attachment ) { throw new Exception ( "Named original attachment not found: " + getId ( ) + "/" + originalAttachmentName ) ; } else { InputStream is = null ; InputStreamReader isr = null ; try { is = attachment . getInputStream ( ) ; isr = new InputStreamReader ( is , "UTF-8" ) ; StringWriter sw = new StringWriter ( ) ; StreamUtils . copyStream ( isr , sw ) ; sw . flush ( ) ; wkt = sw . toString ( ) ; isr . close ( ) ; isr = null ; is . close ( ) ; is = null ; } catch ( Exception e ) { logger . error ( "Error obtaining attachment " + getId ( ) + "/" + originalAttachmentName , e ) ; if ( null != isr ) { try { isr . close ( ) ; isr = null ; } catch ( Exception e1 ) { // ignore } } if ( null != is ) { try { is . close ( ) ; is = null ; } catch ( Exception e1 ) { // ignore } } throw new Exception ( "Error obtaining attachment " + getId ( ) + "/" + originalAttachmentName , e ) ; } } } } if ( null != wkt ) { result = new NunaliitGeometryImpl ( ) ; result . setWKT ( wkt ) ; } } return result ; }
Return the original geometry associated with the document . This is the geometry that was first submitted with the document . If the document does not contain a geometry then null is returned .