6 package com.google.appinventor.components.runtime;
26 import org.locationtech.jts.geom.Geometry;
27 import org.osmdroid.util.GeoPoint;
36 @DesignerComponent(version = YaVersion.RECTANGLE_COMPONENT_VERSION,
37 category = ComponentCategory.MAPS,
38 description =
"Rectangle")
41 private double east = 0;
42 private double west = 0;
43 private double north = 0;
44 private double south = 0;
48 public Double visit(
MapMarker marker, Object... arguments) {
49 if ((Boolean) arguments[1]) {
57 public Double visit(
MapLineString lineString, Object... arguments) {
58 if ((Boolean) arguments[1]) {
66 public Double visit(
MapPolygon polygon, Object... arguments) {
67 if ((Boolean) arguments[1]) {
75 public Double visit(
MapCircle circle, Object... arguments) {
76 if ((Boolean) arguments[1]) {
84 public Double visit(
MapRectangle rectangle, Object... arguments) {
85 if ((Boolean) arguments[1]) {
100 description =
"Returns the type of the feature. For rectangles, this returns the text "
115 description =
"The east edge of the rectangle, in decimal degrees east "
116 +
"of the prime meridian.")
141 description =
"The north edge of the rectangle, in decimal degrees north"
142 +
" of the equator.")
167 description =
"The south edge of the rectangle, in decimal degrees north"
168 +
" of the equator.")
193 description =
"The west edge of the rectangle, in decimal degrees east"
194 +
" of the equator.")
214 @
SimpleFunction(description =
"Returns the center of the Rectangle as a list of the form " +
215 "(Latitude Longitude).")
224 @
SimpleFunction(description =
"Returns the bounding box of the Rectangle in the format " +
225 "((North West) (South East)).")
240 @
SimpleFunction(description =
"Moves the Rectangle so that it is centered on the given " +
241 "latitude and longitude while attempting to maintain the width and height of the Rectangle " +
242 "as measured from the center to the edges.")
243 public
void SetCenter(
double latitude,
double longitude) {
244 if (latitude < -90 || latitude > 90) {
248 if (longitude < -180 || longitude > 180) {
253 GeoPoint northPoint =
new GeoPoint(north, currentCenter.getLongitude());
254 GeoPoint southPoint =
new GeoPoint(south, currentCenter.getLongitude());
255 GeoPoint eastPoint =
new GeoPoint(currentCenter.getLatitude(), east);
256 GeoPoint westPoint =
new GeoPoint(currentCenter.getLatitude(), west);
259 currentCenter.setCoords(latitude, longitude);
260 north = currentCenter.destinationPoint(latExtent2, 0.0f).getLatitude();
261 south = currentCenter.destinationPoint(latExtent2, 180.0f).getLatitude();
262 east = currentCenter.destinationPoint(longExtent2, 90.0f).getLongitude();
263 west = currentCenter.destinationPoint(longExtent2, 270.0f).getLongitude();
270 return visitor.
visit(
this, arguments);
279 public void updateBounds(
double north,
double west,
double south,
double east) {