/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.geo.model; import java.io.Serializable; /** *

* Contains the geofence geometry details. *

*

* A geofence geometry is made up of either a polygon or a circle. Can be either * a polygon or a circle. Including both will return a validation error. *

* *

* Amazon Location doesn't currently support polygons with holes, multipolygons, * polygons that are wound clockwise, or that cross the antimeridian. *

*
*/ public class GeofenceGeometry implements Serializable { /** *

* A circle on the earth, as defined by a center point and a radius. *

*/ private Circle circle; /** *

* A polygon is a list of linear rings which are each made up of a list of * vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an array of * doubles of length 2 (so [double, double]). *

*

* An array of 4 or more vertices, where the first and last vertex are the * same (to form a closed boundary), is called a linear ring. The linear * ring vertices must be listed in counter-clockwise order around the ring’s * interior. The linear ring is represented as an array of vertices, or an * array of arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for future * expansion, the Polygon parameter takes an array of linear rings, which is * represented as an array of arrays of arrays of doubles ( * [[[double, double], ...], ...]). *

*

* A linear ring for use in geofences can consist of between 4 and 1,000 * vertices. *

*/ private java.util.List>> polygon; /** *

* A circle on the earth, as defined by a center point and a radius. *

* * @return

* A circle on the earth, as defined by a center point and a radius. *

*/ public Circle getCircle() { return circle; } /** *

* A circle on the earth, as defined by a center point and a radius. *

* * @param circle

* A circle on the earth, as defined by a center point and a * radius. *

*/ public void setCircle(Circle circle) { this.circle = circle; } /** *

* A circle on the earth, as defined by a center point and a radius. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param circle

* A circle on the earth, as defined by a center point and a * radius. *

* @return A reference to this updated object so that method calls can be * chained together. */ public GeofenceGeometry withCircle(Circle circle) { this.circle = circle; return this; } /** *

* A polygon is a list of linear rings which are each made up of a list of * vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an array of * doubles of length 2 (so [double, double]). *

*

* An array of 4 or more vertices, where the first and last vertex are the * same (to form a closed boundary), is called a linear ring. The linear * ring vertices must be listed in counter-clockwise order around the ring’s * interior. The linear ring is represented as an array of vertices, or an * array of arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for future * expansion, the Polygon parameter takes an array of linear rings, which is * represented as an array of arrays of arrays of doubles ( * [[[double, double], ...], ...]). *

*

* A linear ring for use in geofences can consist of between 4 and 1,000 * vertices. *

* * @return

* A polygon is a list of linear rings which are each made up of a * list of vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an * array of doubles of length 2 (so [double, double]). *

*

* An array of 4 or more vertices, where the first and last vertex * are the same (to form a closed boundary), is called a linear * ring. The linear ring vertices must be listed in * counter-clockwise order around the ring’s interior. The linear * ring is represented as an array of vertices, or an array of * arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for future * expansion, the Polygon parameter takes an array of linear rings, * which is represented as an array of arrays of arrays of doubles ( * [[[double, double], ...], ...]). *

*

* A linear ring for use in geofences can consist of between 4 and * 1,000 vertices. *

*/ public java.util.List>> getPolygon() { return polygon; } /** *

* A polygon is a list of linear rings which are each made up of a list of * vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an array of * doubles of length 2 (so [double, double]). *

*

* An array of 4 or more vertices, where the first and last vertex are the * same (to form a closed boundary), is called a linear ring. The linear * ring vertices must be listed in counter-clockwise order around the ring’s * interior. The linear ring is represented as an array of vertices, or an * array of arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for future * expansion, the Polygon parameter takes an array of linear rings, which is * represented as an array of arrays of arrays of doubles ( * [[[double, double], ...], ...]). *

*

* A linear ring for use in geofences can consist of between 4 and 1,000 * vertices. *

* * @param polygon

* A polygon is a list of linear rings which are each made up of * a list of vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an * array of doubles of length 2 (so [double, double] * ). *

*

* An array of 4 or more vertices, where the first and last * vertex are the same (to form a closed boundary), is called a * linear ring. The linear ring vertices must be listed in * counter-clockwise order around the ring’s interior. The linear * ring is represented as an array of vertices, or an array of * arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for * future expansion, the Polygon parameter takes an array of * linear rings, which is represented as an array of arrays of * arrays of doubles ([[[double, double], ...], ...] * ). *

*

* A linear ring for use in geofences can consist of between 4 * and 1,000 vertices. *

*/ public void setPolygon(java.util.Collection>> polygon) { if (polygon == null) { this.polygon = null; return; } this.polygon = new java.util.ArrayList>>(polygon); } /** *

* A polygon is a list of linear rings which are each made up of a list of * vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an array of * doubles of length 2 (so [double, double]). *

*

* An array of 4 or more vertices, where the first and last vertex are the * same (to form a closed boundary), is called a linear ring. The linear * ring vertices must be listed in counter-clockwise order around the ring’s * interior. The linear ring is represented as an array of vertices, or an * array of arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for future * expansion, the Polygon parameter takes an array of linear rings, which is * represented as an array of arrays of arrays of doubles ( * [[[double, double], ...], ...]). *

*

* A linear ring for use in geofences can consist of between 4 and 1,000 * vertices. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param polygon

* A polygon is a list of linear rings which are each made up of * a list of vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an * array of doubles of length 2 (so [double, double] * ). *

*

* An array of 4 or more vertices, where the first and last * vertex are the same (to form a closed boundary), is called a * linear ring. The linear ring vertices must be listed in * counter-clockwise order around the ring’s interior. The linear * ring is represented as an array of vertices, or an array of * arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for * future expansion, the Polygon parameter takes an array of * linear rings, which is represented as an array of arrays of * arrays of doubles ([[[double, double], ...], ...] * ). *

*

* A linear ring for use in geofences can consist of between 4 * and 1,000 vertices. *

* @return A reference to this updated object so that method calls can be * chained together. */ public GeofenceGeometry withPolygon(java.util.List>... polygon) { if (getPolygon() == null) { this.polygon = new java.util.ArrayList>>( polygon.length); } for (java.util.List> value : polygon) { this.polygon.add(value); } return this; } /** *

* A polygon is a list of linear rings which are each made up of a list of * vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an array of * doubles of length 2 (so [double, double]). *

*

* An array of 4 or more vertices, where the first and last vertex are the * same (to form a closed boundary), is called a linear ring. The linear * ring vertices must be listed in counter-clockwise order around the ring’s * interior. The linear ring is represented as an array of vertices, or an * array of arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for future * expansion, the Polygon parameter takes an array of linear rings, which is * represented as an array of arrays of arrays of doubles ( * [[[double, double], ...], ...]). *

*

* A linear ring for use in geofences can consist of between 4 and 1,000 * vertices. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param polygon

* A polygon is a list of linear rings which are each made up of * a list of vertices. *

*

* Each vertex is a 2-dimensional point of the form: * [longitude, latitude]. This is represented as an * array of doubles of length 2 (so [double, double] * ). *

*

* An array of 4 or more vertices, where the first and last * vertex are the same (to form a closed boundary), is called a * linear ring. The linear ring vertices must be listed in * counter-clockwise order around the ring’s interior. The linear * ring is represented as an array of vertices, or an array of * arrays of doubles ([[double, double], ...]). *

*

* A geofence consists of a single linear ring. To allow for * future expansion, the Polygon parameter takes an array of * linear rings, which is represented as an array of arrays of * arrays of doubles ([[[double, double], ...], ...] * ). *

*

* A linear ring for use in geofences can consist of between 4 * and 1,000 vertices. *

* @return A reference to this updated object so that method calls can be * chained together. */ public GeofenceGeometry withPolygon( java.util.Collection>> polygon) { setPolygon(polygon); return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getCircle() != null) sb.append("Circle: " + getCircle() + ","); if (getPolygon() != null) sb.append("Polygon: " + getPolygon()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getCircle() == null) ? 0 : getCircle().hashCode()); hashCode = prime * hashCode + ((getPolygon() == null) ? 0 : getPolygon().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GeofenceGeometry == false) return false; GeofenceGeometry other = (GeofenceGeometry) obj; if (other.getCircle() == null ^ this.getCircle() == null) return false; if (other.getCircle() != null && other.getCircle().equals(this.getCircle()) == false) return false; if (other.getPolygon() == null ^ this.getPolygon() == null) return false; if (other.getPolygon() != null && other.getPolygon().equals(this.getPolygon()) == false) return false; return true; } }