Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions plugin-annotation/scripts/annotation_manager_unit_test.junit.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,25 @@ public class <%- camelize(type) %>ManagerTest {
public void testGeometry<%- camelize(type) %>() {
<%- type %>Manager = new <%- camelize(type) %>Manager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
<% if (type === "circle" || type === "symbol") { -%>
<%- camelize(type) %> <%- type %> = <%- type %>Manager.create(new <%- camelize(type) %>Options().withLatLng(new LatLng(12, 34)));
LatLng latLng = new LatLng(12, 34);
<%- camelize(type) %>Options options = new <%- camelize(type) %>Options().withLatLng(latLng);
<%- camelize(type) %> <%- type %> = <%- type %>Manager.create(options);
assertEquals(options.getLatLng(), latLng);
assertEquals(<%- type %>.getLatLng(), latLng);
assertEquals(options.getGeometry(), Point.fromLngLat(34, 12));
assertEquals(<%- type %>.getGeometry(), Point.fromLngLat(34, 12));
<% } else if (type === "line") { -%>
List<LatLng>latLngs = new ArrayList<>();
latLngs.add(new LatLng());
latLngs.add(new LatLng(1,1));
<%- camelize(type) %> <%- type %> = <%- type %>Manager.create(new <%- camelize(type) %>Options().withLatLngs(latLngs));
<%- camelize(type) %>Options options = new <%- camelize(type) %>Options().withLatLngs(latLngs);
<%- camelize(type) %> <%- type %> = <%- type %>Manager.create(options);
assertEquals(options.getLatLngs(), latLngs);
assertEquals(line.getLatLngs(), latLngs);
assertEquals(options.getGeometry(), LineString.fromLngLats(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
add(Point.fromLngLat(1, 1));
}}));
assertEquals(line.getGeometry(), LineString.fromLngLats(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
add(Point.fromLngLat(1, 1));
Expand All @@ -345,7 +357,17 @@ public class <%- camelize(type) %>ManagerTest {
innerLatLngs.add(new LatLng(-1,-1));
List<List<LatLng>>latLngs = new ArrayList<>();
latLngs.add(innerLatLngs);
Fill fill = fillManager.create(new <%- camelize(type) %>Options().withLatLngs(latLngs));
<%- camelize(type) %>Options options = new <%- camelize(type) %>Options().withLatLngs(latLngs);
Fill fill = fillManager.create(options);
assertEquals(options.getLatLngs(), latLngs);
assertEquals(fill.getLatLngs(), latLngs);
assertEquals(options.getGeometry(), Polygon.fromLngLats(new ArrayList<List<Point>>() {{
add(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
add(Point.fromLngLat(1, 1));
add(Point.fromLngLat(-1, -1));
}});
}}));
assertEquals(fill.getGeometry(), Polygon.fromLngLats(new ArrayList<List<Point>>() {{
add(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
Expand Down
73 changes: 73 additions & 0 deletions plugin-annotation/scripts/annotation_options.java.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,18 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
return this;
}

/**
* Get the LatLng of the <%- type %>, which represents the location of the <%- type %> on the map
*
* @return the location of the <%- type %> in a longitude and latitude pair
*/
public LatLng getLatLng() {
if (geometry == null) {
return null;
}
return new LatLng(geometry.latitude(), geometry.longitude());
}

/**
* Set the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
*
Expand All @@ -101,6 +113,15 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
this.geometry = geometry;
return this;
}

/**
* Get the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
*
* @return the location of the <%- type %>
*/
public Point getGeometry() {
return geometry;
}
<% } else if (type === "line") { -%>

/**
Expand All @@ -118,6 +139,21 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
return this;
}

/**
* Get a list of LatLng for the line, which represents the locations of the line on the map
*
* @return a list of the locations of the line in a longitude and latitude pairs
*/
public List<LatLng> getLatLngs() {
List<LatLng>latLngs = new ArrayList<>();
if (geometry!=null) {
for (Point coordinate : geometry.coordinates()) {
latLngs.add(new LatLng(coordinate.latitude(), coordinate.longitude()));
}
}
return latLngs;
}

/**
* Set the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
*
Expand All @@ -128,6 +164,15 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
this.geometry = geometry;
return this;
}

/**
* Get the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
*
* @return the location of the <%- type %>
*/
public LineString getGeometry() {
return geometry;
}
<% } else { -%>

/**
Expand All @@ -149,6 +194,25 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
return this;
}

/**
* Get a list of lists of LatLng for the fill, which represents the locations of the fill on the map
*
* @return a list of a lists of the locations of the line in a longitude and latitude pairs
*/
public List<List<LatLng>> getLatLngs() {
List<List<LatLng>> points = new ArrayList<>();
if (geometry != null) {
for (List<Point> coordinates : geometry.coordinates()) {
List<LatLng> innerList = new ArrayList<>();
for (Point point : coordinates) {
innerList.add(new LatLng(point.latitude(), point.longitude()));
}
points.add(innerList);
}
}
return points;
}

/**
* Set the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
*
Expand All @@ -159,6 +223,15 @@ public class <%- camelize(type) %>Options extends Options<<%- camelize(type) %>>
this.geometry = geometry;
return this;
}

/**
* Get the geometry of the <%- type %>, which represents the location of the <%- type %> on the map
*
* @return the location of the <%- type %>
*/
public Polygon getGeometry() {
return geometry;
}
<% } -%>
<% if (type === "symbol") { -%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ public CircleOptions withLatLng(LatLng latLng) {
return this;
}

/**
* Get the LatLng of the circle, which represents the location of the circle on the map
*
* @return the location of the circle in a longitude and latitude pair
*/
public LatLng getLatLng() {
if (geometry == null) {
return null;
}
return new LatLng(geometry.latitude(), geometry.longitude());
}

/**
* Set the geometry of the circle, which represents the location of the circle on the map
*
Expand All @@ -234,6 +246,15 @@ public CircleOptions withGeometry(Point geometry) {
return this;
}

/**
* Get the geometry of the circle, which represents the location of the circle on the map
*
* @return the location of the circle
*/
public Point getGeometry() {
return geometry;
}

/**
* Returns whether this circle is draggable, meaning it can be dragged across the screen when touched and moved.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,25 @@ public FillOptions withLatLngs(List<List<LatLng>> latLngs) {
return this;
}

/**
* Get a list of lists of LatLng for the fill, which represents the locations of the fill on the map
*
* @return a list of a lists of the locations of the line in a longitude and latitude pairs
*/
public List<List<LatLng>> getLatLngs() {
List<List<LatLng>> points = new ArrayList<>();
if (geometry != null) {
for (List<Point> coordinates : geometry.coordinates()) {
List<LatLng> innerList = new ArrayList<>();
for (Point point : coordinates) {
innerList.add(new LatLng(point.latitude(), point.longitude()));
}
points.add(innerList);
}
}
return points;
}

/**
* Set the geometry of the fill, which represents the location of the fill on the map
*
Expand All @@ -164,6 +183,15 @@ public FillOptions withGeometry(Polygon geometry) {
return this;
}

/**
* Get the geometry of the fill, which represents the location of the fill on the map
*
* @return the location of the fill
*/
public Polygon getGeometry() {
return geometry;
}

/**
* Returns whether this fill is draggable, meaning it can be dragged across the screen when touched and moved.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,21 @@ public LineOptions withLatLngs(List<LatLng> latLngs) {
return this;
}

/**
* Get a list of LatLng for the line, which represents the locations of the line on the map
*
* @return a list of the locations of the line in a longitude and latitude pairs
*/
public List<LatLng> getLatLngs() {
List<LatLng>latLngs = new ArrayList<>();
if (geometry!=null) {
for (Point coordinate : geometry.coordinates()) {
latLngs.add(new LatLng(coordinate.latitude(), coordinate.longitude()));
}
}
return latLngs;
}

/**
* Set the geometry of the line, which represents the location of the line on the map
*
Expand All @@ -264,6 +279,15 @@ public LineOptions withGeometry(LineString geometry) {
return this;
}

/**
* Get the geometry of the line, which represents the location of the line on the map
*
* @return the location of the line
*/
public LineString getGeometry() {
return geometry;
}

/**
* Returns whether this line is draggable, meaning it can be dragged across the screen when touched and moved.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,18 @@ public SymbolOptions withLatLng(LatLng latLng) {
return this;
}

/**
* Get the LatLng of the symbol, which represents the location of the symbol on the map
*
* @return the location of the symbol in a longitude and latitude pair
*/
public LatLng getLatLng() {
if (geometry == null) {
return null;
}
return new LatLng(geometry.latitude(), geometry.longitude());
}

/**
* Set the geometry of the symbol, which represents the location of the symbol on the map
*
Expand All @@ -704,6 +716,15 @@ public SymbolOptions withGeometry(Point geometry) {
return this;
}

/**
* Get the geometry of the symbol, which represents the location of the symbol on the map
*
* @return the location of the symbol
*/
public Point getGeometry() {
return geometry;
}

/**
* Set the zIndex of the symbol, which represents the place of the symbol on the map inside a layer.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,12 @@ public void testDeleteCircle() {
@Test
public void testGeometryCircle() {
circleManager = new CircleManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
Circle circle = circleManager.create(new CircleOptions().withLatLng(new LatLng(12, 34)));
LatLng latLng = new LatLng(12, 34);
CircleOptions options = new CircleOptions().withLatLng(latLng);
Circle circle = circleManager.create(options);
assertEquals(options.getLatLng(), latLng);
assertEquals(circle.getLatLng(), latLng);
assertEquals(options.getGeometry(), Point.fromLngLat(34, 12));
assertEquals(circle.getGeometry(), Point.fromLngLat(34, 12));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,17 @@ public void testGeometryFill() {
innerLatLngs.add(new LatLng(-1,-1));
List<List<LatLng>>latLngs = new ArrayList<>();
latLngs.add(innerLatLngs);
Fill fill = fillManager.create(new FillOptions().withLatLngs(latLngs));
FillOptions options = new FillOptions().withLatLngs(latLngs);
Fill fill = fillManager.create(options);
assertEquals(options.getLatLngs(), latLngs);
assertEquals(fill.getLatLngs(), latLngs);
assertEquals(options.getGeometry(), Polygon.fromLngLats(new ArrayList<List<Point>>() {{
add(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
add(Point.fromLngLat(1, 1));
add(Point.fromLngLat(-1, -1));
}});
}}));
assertEquals(fill.getGeometry(), Polygon.fromLngLats(new ArrayList<List<Point>>() {{
add(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,14 @@ public void testGeometryLine() {
List<LatLng>latLngs = new ArrayList<>();
latLngs.add(new LatLng());
latLngs.add(new LatLng(1,1));
Line line = lineManager.create(new LineOptions().withLatLngs(latLngs));
LineOptions options = new LineOptions().withLatLngs(latLngs);
Line line = lineManager.create(options);
assertEquals(options.getLatLngs(), latLngs);
assertEquals(line.getLatLngs(), latLngs);
assertEquals(options.getGeometry(), LineString.fromLngLats(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
add(Point.fromLngLat(1, 1));
}}));
assertEquals(line.getGeometry(), LineString.fromLngLats(new ArrayList<Point>() {{
add(Point.fromLngLat(0, 0));
add(Point.fromLngLat(1, 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,12 @@ public void testDeleteSymbol() {
@Test
public void testGeometrySymbol() {
symbolManager = new SymbolManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController);
Symbol symbol = symbolManager.create(new SymbolOptions().withLatLng(new LatLng(12, 34)));
LatLng latLng = new LatLng(12, 34);
SymbolOptions options = new SymbolOptions().withLatLng(latLng);
Symbol symbol = symbolManager.create(options);
assertEquals(options.getLatLng(), latLng);
assertEquals(symbol.getLatLng(), latLng);
assertEquals(options.getGeometry(), Point.fromLngLat(34, 12));
assertEquals(symbol.getGeometry(), Point.fromLngLat(34, 12));
}

Expand Down