001 /*
002 * Apache License
003 * Version 2.0, January 2004
004 * http://www.apache.org/licenses/
005 *
006 * Copyright 1996-2008 by Sven Homburg
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 */
014 package org.chenillekit.google.utils.geocode;
015
016 import org.chenillekit.google.utils.JSONException;
017 import org.chenillekit.google.utils.JSONObject;
018
019 /**
020 * @version $Id: LatLng.java 558 2009-09-18 08:16:07Z mlusetti $
021 */
022 public class LatLng
023 {
024 private double latitude;
025 private double longitude;
026
027 public LatLng(double latitude, double longitude)
028 {
029 this.latitude = latitude;
030 this.longitude = longitude;
031 }
032
033 public LatLng(JSONObject json)
034 {
035 buildFromJSON(json);
036 }
037
038 private void buildFromJSON(JSONObject json)
039 {
040 try
041 {
042 longitude = json.getJSONArray("coordinates").getDouble(0);
043 latitude = json.getJSONArray("coordinates").getDouble(1);
044 }
045 catch (JSONException e)
046 {
047 throw new RuntimeException(e);
048 }
049 }
050
051 public double getLatitude()
052 {
053 return latitude;
054 }
055
056 public void setLatitude(double latitude)
057 {
058 this.latitude = latitude;
059 }
060
061 public double getLongitude()
062 {
063 return longitude;
064 }
065
066 public void setLongitude(double longitude)
067 {
068 this.longitude = longitude;
069 }
070 }