Example usage for android.media ExifInterface ExifInterface

List of usage examples for android.media ExifInterface ExifInterface

Introduction

In this page you can find the example usage for android.media ExifInterface ExifInterface.

Prototype

public ExifInterface(InputStream inputStream) throws IOException 

Source Link

Document

Reads Exif tags from the specified image input stream.

Usage

From source file:com.wots.lutmaar.CustomView.imagechooser.threads.MediaProcessorThread.java

private String compressAndSaveImage(String fileImage, int scale) throws Exception {
    try {/*from w w  w. jav  a  2 s  . c o m*/
        ExifInterface exif = new ExifInterface(fileImage);
        String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
        String length = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        int rotate = 0;
        if (BuildConfig.DEBUG) {
            Log.i(TAG, "Before: " + width + "x" + length);
        }

        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
            rotate = -90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            rotate = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            rotate = 90;
            break;
        }

        int w = Integer.parseInt(width);
        int l = Integer.parseInt(length);

        int what = w > l ? w : l;

        Options options = new Options();
        if (what > 1500) {
            options.inSampleSize = scale * 4;
        } else if (what > 1000 && what <= 1500) {
            options.inSampleSize = scale * 3;
        } else if (what > 400 && what <= 1000) {
            options.inSampleSize = scale * 2;
        } else {
            options.inSampleSize = scale;
        }
        if (BuildConfig.DEBUG) {
            Log.i(TAG, "Scale: " + (what / options.inSampleSize));
            Log.i(TAG, "Rotate: " + rotate);
        }
        Bitmap bitmap = BitmapFactory.decodeFile(fileImage, options);
        File original = new File(fileImage);
        File file = new File((original.getParent() + File.separator
                + original.getName().replace(".", "_fact_" + scale + ".")));
        FileOutputStream stream = new FileOutputStream(file);
        if (rotate != 0) {
            Matrix matrix = new Matrix();
            matrix.setRotate(rotate);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);

        }
        /* if (scale == 1)
        bitmap = Bitmap.createScaledBitmap(bitmap, 240, 260, true);*/
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);

        if (BuildConfig.DEBUG) {
            ExifInterface exifAfter = new ExifInterface(file.getAbsolutePath());
            String widthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
            String lengthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "After: " + widthAfter + "x" + lengthAfter);
            }
        }
        stream.flush();
        stream.close();
        return file.getAbsolutePath();

    } catch (IOException e) {
        e.printStackTrace();
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Corrupt or deleted file???");
    }
}

From source file:com.amytech.android.library.views.imagechooser.threads.MediaProcessorThread.java

private String compressAndSaveImage(String fileImage, int scale) throws Exception {
    try {/*ww  w . jav  a 2 s. c om*/
        ExifInterface exif = new ExifInterface(fileImage);
        String width = exif.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
        String length = exif.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
        int rotate = 0;
        if (BuildConfig.DEBUG) {
            Log.i(TAG, "Before: " + width + "x" + length);
        }

        switch (orientation) {
        case ExifInterface.ORIENTATION_ROTATE_270:
            rotate = -90;
            break;
        case ExifInterface.ORIENTATION_ROTATE_180:
            rotate = 180;
            break;
        case ExifInterface.ORIENTATION_ROTATE_90:
            rotate = 90;
            break;
        }

        int w = Integer.parseInt(width);
        int l = Integer.parseInt(length);

        int what = w > l ? w : l;

        Options options = new Options();
        if (what > 1500) {
            options.inSampleSize = scale * 4;
        } else if (what > 1000 && what <= 1500) {
            options.inSampleSize = scale * 3;
        } else if (what > 400 && what <= 1000) {
            options.inSampleSize = scale * 2;
        } else {
            options.inSampleSize = scale;
        }
        if (BuildConfig.DEBUG) {
            Log.i(TAG, "Scale: " + (what / options.inSampleSize));
            Log.i(TAG, "Rotate: " + rotate);
        }
        Bitmap bitmap = BitmapFactory.decodeFile(fileImage, options);
        File original = new File(fileImage);
        File file = new File((original.getParent() + File.separator
                + original.getName().replace(".", "_fact_" + scale + ".")));
        FileOutputStream stream = new FileOutputStream(file);
        if (rotate != 0) {
            Matrix matrix = new Matrix();
            matrix.setRotate(rotate);
            bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
        }
        bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);

        if (BuildConfig.DEBUG) {
            ExifInterface exifAfter = new ExifInterface(file.getAbsolutePath());
            String widthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_WIDTH);
            String lengthAfter = exifAfter.getAttribute(ExifInterface.TAG_IMAGE_LENGTH);
            if (BuildConfig.DEBUG) {
                Log.i(TAG, "After: " + widthAfter + "x" + lengthAfter);
            }
        }
        stream.flush();
        stream.close();
        return file.getAbsolutePath();

    } catch (IOException e) {
        e.printStackTrace();
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Corrupt or deleted file???");
    }
}

From source file:com.pdftron.pdf.utils.ViewerUtils.java

public static Map readImageIntent(Intent data, Context context, Uri outputFileUri)
        throws FileNotFoundException, Exception {
    final boolean isCamera;
    if (data == null || data.getData() == null) {
        isCamera = true;/* w  w w  .jav  a2s.  c o  m*/
    } else {
        final String action = data.getAction();
        if (action == null) {
            isCamera = false;
        } else {
            isCamera = action.equals(MediaStore.ACTION_IMAGE_CAPTURE);
        }
    }

    Uri imageUri;
    if (isCamera) {
        imageUri = outputFileUri;
        AnalyticsHandlerAdapter.getInstance().sendEvent(AnalyticsHandlerAdapter.CATEGORY_FILEBROWSER,
                "Create new document from camera selected");
    } else {
        imageUri = data.getData();
        AnalyticsHandlerAdapter.getInstance().sendEvent(AnalyticsHandlerAdapter.CATEGORY_FILEBROWSER,
                "Create new document from local image file selected");
    }

    String filePath;
    if (isCamera) {
        filePath = imageUri.getPath();
    } else {
        filePath = Utils.getRealPathFromImageURI(context, imageUri);
        if (Utils.isNullOrEmpty(filePath)) {
            filePath = imageUri.getPath();
        }
    }

    // try to get bitmap
    Bitmap bitmap = Utils.getBitmapFromImageUri(context, imageUri, filePath);

    // if a file is selected, check if it is an image file
    if (!isCamera) {
        // if type is null
        if (context.getContentResolver().getType(imageUri) == null) {
            String extension = MimeTypeMap.getFileExtensionFromUrl(imageUri.getPath());
            final String[] extensions = { "jpeg", "jpg", "tiff", "tif", "gif", "png", "bmp" };

            // if file extension is not an image extension
            if (!Arrays.asList(extensions).contains(extension) && extension != null && !extension.equals("")) {
                throw new FileNotFoundException("file extension is not an image extension");
            }
            // if type is not an image
        } else if (!context.getContentResolver().getType(imageUri).startsWith("image/")) {
            throw new FileNotFoundException("type is not an image");
        }
    }

    //////////////////  Determine if image needs to be rotated   ///////////////////
    File imageFile = new File(imageUri.getPath());
    ExifInterface exif = new ExifInterface(imageFile.getAbsolutePath());
    int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_UNDEFINED);

    int imageRotation = 0;
    switch (orientation) {
    case ExifInterface.ORIENTATION_ROTATE_270:
        imageRotation = 270;
        break;
    case ExifInterface.ORIENTATION_ROTATE_180:
        imageRotation = 180;
        break;
    case ExifInterface.ORIENTATION_ROTATE_90:
        imageRotation = 90;
        break;
    }

    // in some devices (mainly Samsung), the EXIF is not saved with the image so look at the content
    // resolver as a second source of the image's rotation
    if (imageRotation == 0) {
        String[] orientationColumn = { MediaStore.Images.Media.ORIENTATION };
        Cursor cur = context.getContentResolver().query(imageUri, orientationColumn, null, null, null);
        orientation = -1;
        if (cur != null && cur.moveToFirst()) {
            orientation = cur.getInt(cur.getColumnIndex(orientationColumn[0]));
        }

        if (orientation > 0) {
            imageRotation = orientation;
        }
    }

    if (imageRotation != 0) {
        Matrix matrix = new Matrix();
        matrix.postRotate(imageRotation);
        bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    }

    Map<String, Object> output = new HashMap<>();
    output.put("bitmap", bitmap);
    output.put("uri", imageUri);
    output.put("path", filePath);
    output.put("camera", isCamera);
    return output;
}

From source file:ir.rasen.charsoo.controller.image_loader.core.decode.BaseImageDecoder.java

protected ExifInfo defineExifOrientation(String imageUri) {
    int rotation = 0;
    boolean flip = false;
    try {//from  www .j  av a2s.c o  m
        ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
        int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                ExifInterface.ORIENTATION_NORMAL);
        switch (exifOrientation) {
        case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
            flip = true;
        case ExifInterface.ORIENTATION_NORMAL:
            rotation = 0;
            break;
        case ExifInterface.ORIENTATION_TRANSVERSE:
            flip = true;
        case ExifInterface.ORIENTATION_ROTATE_90:
            rotation = 90;
            break;
        case ExifInterface.ORIENTATION_FLIP_VERTICAL:
            flip = true;
        case ExifInterface.ORIENTATION_ROTATE_180:
            rotation = 180;
            break;
        case ExifInterface.ORIENTATION_TRANSPOSE:
            flip = true;
        case ExifInterface.ORIENTATION_ROTATE_270:
            rotation = 270;
            break;
        }
    } catch (IOException e) {
        L.w("Can't read EXIF tags from file [%s]", imageUri);
    }
    return new ExifInfo(rotation, flip);
}

From source file:com.oxgcp.photoList.PhotolistModule.java

@Kroll.method
public TiBlob getThumbnail(String fileName) {
    try {//from   www .j  a v  a  2 s. c  om
        ExifInterface exif = new ExifInterface(fileName);

        byte[] thumbnail = exif.getThumbnail();

        Log.d("TiAPI", "thumbnail's length: " + thumbnail.length);

        return TiBlob.blobFromImage(BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length));
    } catch (Exception e) {
        return null;
    }
}

From source file:kr.wdream.ui.Components.AvatarUpdater.java

public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
        if (requestCode == 13) {
            PhotoViewer.getInstance().setParentActivity(parentFragment.getParentActivity());
            int orientation = 0;
            try {
                ExifInterface ei = new ExifInterface(currentPicturePath);
                int exif = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
                switch (exif) {
                case ExifInterface.ORIENTATION_ROTATE_90:
                    orientation = 90;//from ww  w.  j a  v a 2  s. c  o  m
                    break;
                case ExifInterface.ORIENTATION_ROTATE_180:
                    orientation = 180;
                    break;
                case ExifInterface.ORIENTATION_ROTATE_270:
                    orientation = 270;
                    break;
                }
            } catch (Exception e) {
                FileLog.e("tmessages", e);
            }
            final ArrayList<Object> arrayList = new ArrayList<>();
            arrayList.add(new MediaController.PhotoEntry(0, 0, 0, currentPicturePath, orientation, false));
            PhotoViewer.getInstance().openPhotoForSelect(arrayList, 0, 1,
                    new PhotoViewer.EmptyPhotoViewerProvider() {
                        @Override
                        public void sendButtonPressed(int index) {
                            String path = null;
                            MediaController.PhotoEntry photoEntry = (MediaController.PhotoEntry) arrayList
                                    .get(0);
                            if (photoEntry.imagePath != null) {
                                path = photoEntry.imagePath;
                            } else if (photoEntry.path != null) {
                                path = photoEntry.path;
                            }
                            Bitmap bitmap = ImageLoader.loadBitmap(path, null, 800, 800, true);
                            processBitmap(bitmap);
                        }

                        @Override
                        public boolean allowCaption() {
                            return false;
                        }
                    }, null);
            AndroidUtilities.addMediaToGallery(currentPicturePath);
            currentPicturePath = null;
        } else if (requestCode == 14) {
            if (data == null || data.getData() == null) {
                return;
            }
            startCrop(null, data.getData());
        }
    }
}

From source file:om.sstvencoder.MainActivity.java

public int getOrientation(ContentResolver resolver, Uri uri) {
    int orientation = 0;
    try {//from w ww . ja v  a 2 s.c  om
        Cursor cursor = resolver.query(uri, new String[] { MediaStore.Images.ImageColumns.ORIENTATION }, null,
                null, null);
        if (cursor.moveToFirst())
            orientation = cursor.getInt(0);
        cursor.close();
    } catch (Exception ignore) {
        try {
            ExifInterface exif = new ExifInterface(uri.getPath());
            orientation = Utility.convertToDegrees(exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0));
        } catch (Exception ex) {
            showOrientationErrorMessage(uri, ex);
        }
    }
    return orientation;
}

From source file:com.cpjd.roblu.ui.images.ImageGalleryActivity.java

/**
 * Receives the picture that was taken by the user
 * @param requestCode the request code of the child activity
 * @param resultCode the result code of the child activity
 * @param data the picture that was taken
 *//*from w ww .j a v a2  s  .c  o m*/
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == Constants.GENERAL && resultCode == FragmentActivity.RESULT_OK) {
        // fetch file from storage
        Bitmap bitmap = BitmapFactory.decodeFile(tempPictureFile.getPath());
        // fix rotation
        try {
            ExifInterface ei = new ExifInterface(tempPictureFile.getPath());
            int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
                    ExifInterface.ORIENTATION_UNDEFINED);

            switch (orientation) {
            case ExifInterface.ORIENTATION_ROTATE_90:
                bitmap = rotateImage(bitmap, 90);
                break;
            case ExifInterface.ORIENTATION_ROTATE_180:
                bitmap = rotateImage(bitmap, 180);
                break;
            case ExifInterface.ORIENTATION_ROTATE_270:
                bitmap = rotateImage(bitmap, 270);
                break;
            default:
                break;
            }
        } catch (IOException e) {
            Log.d("RBS", "Failed to remove EXIF rotation data from the picture.");
        }

        /*
         * Convert the image into a byte[] and save it to the gallery
         */

        // Convert the bitmap to a byte array
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bitmap.compress(Bitmap.CompressFormat.JPEG, 30, stream);
        byte[] array = stream.toByteArray();

        int newID = new IO(getApplicationContext()).savePicture(eventID, array);

        // Add the image to the current array
        if (IMAGES == null)
            IMAGES = new ArrayList<>();
        IMAGES.add(array);

        // save the ID to the gallery
        for (int i = 0; i < TeamViewer.team.getTabs().get(rTabIndex).getMetrics().size(); i++) {
            if (TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i).getID() == galleryID) {
                if (((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i))
                        .getPictureIDs() == null) {
                    ((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i))
                            .setPictureIDs(new ArrayList<Integer>());
                }
                ((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i)).getPictureIDs()
                        .add(newID);
                break;
            }
        }
        TeamViewer.team.setLastEdit(System.currentTimeMillis());

        new IO(getApplicationContext()).saveTeam(eventID, TeamViewer.team);
        imageGalleryAdapter.notifyDataSetChanged();
    }
    /*
     * User edited an image
     */
    else if (resultCode == Constants.IMAGE_EDITED) {
        TeamViewer.team.setLastEdit(System.currentTimeMillis());

        /*
         * Update the image in the gallery
         */
        for (int i = 0; i < TeamViewer.team.getTabs().get(rTabIndex).getMetrics().size(); i++) {
            if (TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i).getID() == galleryID) {
                if (((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i))
                        .getPictureIDs() == null) {
                    ((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i))
                            .setPictureIDs(new ArrayList<Integer>());
                }
                ((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i)).getPictureIDs()
                        .add(new IO(getApplicationContext()).savePicture(eventID,
                                IMAGES.get(data.getIntExtra("position", 0))));
                break;
            }
        }

        new IO(getApplicationContext()).saveTeam(eventID, TeamViewer.team);
        imageGalleryAdapter.notifyDataSetChanged();
    }
    /*
     * User deleted an image
     */
    else if (resultCode == Constants.IMAGE_DELETED) {
        // Remove the image from the gallery ID list
        for (int i = 0; i < TeamViewer.team.getTabs().get(rTabIndex).getMetrics().size(); i++) {
            if (TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i).getID() == galleryID) {
                int pictureID = ((RGallery) TeamViewer.team.getTabs().get(rTabIndex).getMetrics().get(i))
                        .getPictureIDs().remove(data.getIntExtra("position", 0));
                // delete from file system
                new IO(getApplicationContext()).deletePicture(eventID, pictureID);
                break;
            }
        }

        IMAGES.remove(data.getIntExtra("position", 0));
        imageGalleryAdapter.notifyDataSetChanged();

        TeamViewer.team.setLastEdit(System.currentTimeMillis());

        new IO(getApplicationContext()).saveTeam(eventID, TeamViewer.team);
    }
}

From source file:com.netcompss.ffmpeg4android_client.BaseVideo.java

@SuppressWarnings("unused")
private String reporteds(String path) {

    ExifInterface exif = null;//from   w w  w  .j av a  2 s  .  c om
    try {
        exif = new ExifInterface(path);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
    Matrix matrix = new Matrix();
    if (orientation == 6) {
        matrix.postRotate(90);
    } else if (orientation == 3) {
        matrix.postRotate(180);
    } else if (orientation == 8) {
        matrix.postRotate(270);
    }

    if (path != null) {

        if (path.contains("http")) {
            try {
                URL url = new URL(path);
                HttpGet httpRequest = null;

                httpRequest = new HttpGet(url.toURI());

                HttpClient httpclient = new DefaultHttpClient();
                HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);

                HttpEntity entity = response.getEntity();
                BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
                InputStream input = bufHttpEntity.getContent();

                Bitmap bitmap = BitmapFactory.decodeStream(input);
                input.close();
                return getPath(bitmap);
            } catch (MalformedURLException e) {
                Log.e("ImageActivity", "bad url", e);
            } catch (Exception e) {
                Log.e("ImageActivity", "io error", e);
            }
        } else {

            Options options = new Options();
            options.inSampleSize = 2;
            options.inJustDecodeBounds = true;
            BitmapFactory.decodeResource(context.getResources(), srcBgId, options);
            options.inJustDecodeBounds = false;
            options.inSampleSize = calculateInSampleSize(options, w, h);
            Bitmap unbgbtmp = BitmapFactory.decodeResource(context.getResources(), srcBgId, options);
            Bitmap unrlbtmp = ScalingUtilities.decodeFile(path, w, h, ScalingLogic.FIT);
            unrlbtmp.recycle();
            Bitmap rlbtmp = null;
            if (unrlbtmp != null) {
                rlbtmp = ScalingUtilities.createScaledBitmap(unrlbtmp, w, h, ScalingLogic.FIT);
            }
            if (unbgbtmp != null && rlbtmp != null) {
                Bitmap bgbtmp = ScalingUtilities.createScaledBitmap(unbgbtmp, w, h, ScalingLogic.FIT);
                Bitmap newscaledBitmap = ProcessingBitmapTwo(bgbtmp, rlbtmp);
                unbgbtmp.recycle();
                return getPath(newscaledBitmap);
            }
        }
    }
    return path;

}

From source file:org.jraf.android.piclabel.app.form.FormActivity.java

protected ImageInfo extractImageInfo(File file) {
    ImageInfo res = new ImageInfo();
    ExifInterface exifInterface = null;/*from  w w w. jav  a 2 s.  c  o m*/
    try {
        exifInterface = new ExifInterface(file.getPath());
    } catch (IOException e) {
        Log.e(TAG, "extractImageInfo Could not read exif", e);
    }

    // Date
    String dateTimeStr = null;
    if (exifInterface != null)
        dateTimeStr = exifInterface.getAttribute(ExifInterface.TAG_DATETIME);
    if (TextUtils.isEmpty(dateTimeStr)) {
        // No date in exif: use 'local' date
        res.dateTime = DateUtils.formatDateTime(this, System.currentTimeMillis(), DateUtils.FORMAT_SHOW_DATE
                | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR);
        res.isLocalDateTime = true;
    } else {
        res.dateTime = parseExifDateTime(dateTimeStr);
        if (res.dateTime == null) {
            // Date in exif could not be parsed: use 'local' date
            DateUtils.formatDateTime(this, System.currentTimeMillis(), DateUtils.FORMAT_SHOW_DATE
                    | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_WEEKDAY | DateUtils.FORMAT_SHOW_YEAR);
            res.isLocalDateTime = true;
        }
    }

    // Location
    float[] latLon = new float[2];
    boolean latLonPresent = exifInterface != null && exifInterface.getLatLong(latLon);
    if (!latLonPresent) {
        // No location in exif: use 'local' location
        res.isLocalLocation = true;
        latLonPresent = getLatestLocalLocation(latLon);
        if (latLonPresent)
            res.location = reverseGeocode(latLon[0], latLon[1]);
    } else {
        res.location = reverseGeocode(latLon[0], latLon[1]);
    }
    if (res.location == null) {
        res.reverseGeocodeProblem = true;
        res.location = "";
    }
    return res;
}