// Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private PositionDto southWestCorner;
// 	private PositionDto northEastCorner;
// 
// 	public PositionDto getSouthWestCorner() {
// 		return southWestCorner;
// 	}
// 
// 	public void setSouthWestCorner(PositionDto southWestCorner) {
// 		this.southWestCorner = southWestCorner;
// 	}
// 
// 	public PositionDto getNorthEastCorner() {
// 		return northEastCorner;
// 	}
// 
// 	public void setNorthEastCorner(PositionDto northEastCorner) {
// 		this.northEastCorner = northEastCorner;
// 	}
// 
// }
// 
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private double[] numbers;
// 
// 	/**
// 	 * This constructor initializes numbers field to hold two double numbers. Do
// 	 * not use this constructor if you need the third elevation parameter.
// 	 */
// 	public PositionDto() {
// 		this.numbers = new double[2];
// 	}
// 
// 	/**
// 	 * Simple coordinate position constructor
// 	 * 
// 	 * @param longitude
// 	 * @param latitude
// 	 */
// 	public PositionDto(double longitude, double latitude) {
// 		this.numbers = new double[] { longitude, latitude };
// 	}
// 
// 	/**
// 	 * Use this constructor if you need elevation parameter
// 	 * 
// 	 * @param longitude
// 	 * @param latitude
// 	 * @param elevation
// 	 */
// 	public PositionDto(double longitude, double latitude, double elevation) {
// 		this.numbers = new double[] { longitude, latitude, elevation };
// 	}
// 
// 	/**
// 	 * Copy constructor
// 	 * 
// 	 * @param position
// 	 */
// 	public PositionDto(PositionDto position) {
// 		if (position != null) {
// 			double[] copyNumbers = position.getNumbers();
// 			this.numbers = new double[copyNumbers.length];
// 			for (int i = 0; i < copyNumbers.length; i++) {
// 				this.numbers[i] = copyNumbers[i];
// 			}
// 		}
// 	}
// 
// 	@Override
// 	public String toString() {
// 		if (numbers == null) {
// 			return "null numbers[]";
// 		}
// 		StringBuilder value = new StringBuilder("[");
// 		for (int i = 0; i < numbers.length; i++) {
// 			value.append(numbers[i]);
// 			if (i < numbers.length - 1) {
// 				value.append(", ");
// 			}
// 		}
// 		value.append("]");
// 		return value.toString();
// 	}
// 
// 	public void setLongitude(double longitude) {
// 		this.numbers[0] = longitude;
// 	}
// 
// 	public double getLongitude() {
// 		return numbers[0];
// 	}
// 
// 	public void setLatitude(double latitude) {
// 		this.numbers[1] = latitude;
// 	}
// 
// 	public double getLatitude() {
// 		return numbers[1];
// 	}
// 
// 	public void setElevation(double elevation) {
// 		this.numbers[2] = elevation;
// 	}
// 
// 	public double getElevation() {
// 		return numbers[2];
// 	}
// 
// 	public double[] getNumbers() {
// 		return numbers;
// 	}
// 
// 	public void setNumbers(double[] numbers) {
// 		this.numbers = numbers;
// 	}
// }


import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.PositionDto;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
package org.ugeojson.parser.util;


/**
 * @author moksuzer
 *
 */
public class BoundingBoxParser {

	private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;

	private BoundingBoxParser() {
	}

	public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
		BoundingBoxDto bboxDto = null;
		JsonElement bboxElement = asJsonObject.get("bbox");
		if (bboxElement != null) {
			double[] bbox = context.deserialize(bboxElement, double[].class);
			bboxDto = new BoundingBoxDto();
			if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
				bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
				bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
			} else {
				bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
// Path: ugeojson-model/src/main/java/org/ugeojson/model/BoundingBoxDto.java
// public class BoundingBoxDto implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private PositionDto southWestCorner;
// 	private PositionDto northEastCorner;
// 
// 	public PositionDto getSouthWestCorner() {
// 		return southWestCorner;
// 	}
// 
// 	public void setSouthWestCorner(PositionDto southWestCorner) {
// 		this.southWestCorner = southWestCorner;
// 	}
// 
// 	public PositionDto getNorthEastCorner() {
// 		return northEastCorner;
// 	}
// 
// 	public void setNorthEastCorner(PositionDto northEastCorner) {
// 		this.northEastCorner = northEastCorner;
// 	}
// 
// }
// 
// Path: ugeojson-model/src/main/java/org/ugeojson/model/PositionDto.java
// public class PositionDto implements Serializable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private double[] numbers;
// 
// 	/**
// 	 * This constructor initializes numbers field to hold two double numbers. Do
// 	 * not use this constructor if you need the third elevation parameter.
// 	 */
// 	public PositionDto() {
// 		this.numbers = new double[2];
// 	}
// 
// 	/**
// 	 * Simple coordinate position constructor
// 	 * 
// 	 * @param longitude
// 	 * @param latitude
// 	 */
// 	public PositionDto(double longitude, double latitude) {
// 		this.numbers = new double[] { longitude, latitude };
// 	}
// 
// 	/**
// 	 * Use this constructor if you need elevation parameter
// 	 * 
// 	 * @param longitude
// 	 * @param latitude
// 	 * @param elevation
// 	 */
// 	public PositionDto(double longitude, double latitude, double elevation) {
// 		this.numbers = new double[] { longitude, latitude, elevation };
// 	}
// 
// 	/**
// 	 * Copy constructor
// 	 * 
// 	 * @param position
// 	 */
// 	public PositionDto(PositionDto position) {
// 		if (position != null) {
// 			double[] copyNumbers = position.getNumbers();
// 			this.numbers = new double[copyNumbers.length];
// 			for (int i = 0; i < copyNumbers.length; i++) {
// 				this.numbers[i] = copyNumbers[i];
// 			}
// 		}
// 	}
// 
// 	@Override
// 	public String toString() {
// 		if (numbers == null) {
// 			return "null numbers[]";
// 		}
// 		StringBuilder value = new StringBuilder("[");
// 		for (int i = 0; i < numbers.length; i++) {
// 			value.append(numbers[i]);
// 			if (i < numbers.length - 1) {
// 				value.append(", ");
// 			}
// 		}
// 		value.append("]");
// 		return value.toString();
// 	}
// 
// 	public void setLongitude(double longitude) {
// 		this.numbers[0] = longitude;
// 	}
// 
// 	public double getLongitude() {
// 		return numbers[0];
// 	}
// 
// 	public void setLatitude(double latitude) {
// 		this.numbers[1] = latitude;
// 	}
// 
// 	public double getLatitude() {
// 		return numbers[1];
// 	}
// 
// 	public void setElevation(double elevation) {
// 		this.numbers[2] = elevation;
// 	}
// 
// 	public double getElevation() {
// 		return numbers[2];
// 	}
// 
// 	public double[] getNumbers() {
// 		return numbers;
// 	}
// 
// 	public void setNumbers(double[] numbers) {
// 		this.numbers = numbers;
// 	}
// }


// Path: ugeojson-parser/src/main/java/org/ugeojson/parser/util/BoundingBoxParser.java
import org.ugeojson.model.BoundingBoxDto;
import org.ugeojson.model.PositionDto;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;

package org.ugeojson.parser.util;


/**
 * @author moksuzer
 *
 */
public class BoundingBoxParser {

	private static final int TWO_DIMENSIONAL_BBOX_LENGTH = 4;

	private BoundingBoxParser() {
	}

	public static BoundingBoxDto parseBbox(JsonObject asJsonObject, JsonDeserializationContext context) {
		BoundingBoxDto bboxDto = null;
		JsonElement bboxElement = asJsonObject.get("bbox");
		if (bboxElement != null) {
			double[] bbox = context.deserialize(bboxElement, double[].class);
			bboxDto = new BoundingBoxDto();
			if (bbox.length == TWO_DIMENSIONAL_BBOX_LENGTH) {
				bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1]));
				bboxDto.setNorthEastCorner(new PositionDto(bbox[2], bbox[3]));
			} else {
				bboxDto.setSouthWestCorner(new PositionDto(bbox[0], bbox[1], bbox[2]));
				bboxDto.setNorthEastCorner(new PositionDto(bbox[3], bbox[4], bbox[5]));