This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] #352 - migrated Annotation implementation to Shape, reworke…
…d package structure
- Loading branch information
Showing
35 changed files
with
185 additions
and
405 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...pboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/AnnotationDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
public interface AnnotationDefinition { | ||
|
||
} |
67 changes: 32 additions & 35 deletions
67
...rm/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Feature.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,70 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
import java.util.HashMap; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Feature is used to provide details about geographic features | ||
* contained in a map view’s. | ||
* <p> | ||
* The `Feature` protocol is used to provide details about geographic features | ||
* contained in a map view’s | ||
* <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile sources</a>. | ||
* Each concrete subclass of `MGLShape` in turn has a subclass that conforms to | ||
* Each concrete subclass of `Shape` in turn has a subclass that conforms to | ||
* this protocol. | ||
* </p> | ||
* <p> | ||
* Typically, you do not create feature objects yourself but rather obtain them | ||
* using `-[MGLMapView visibleFeaturesAtPoint:]` and related methods. Each feature | ||
* object associates a shape with an identifier and attributes as specified by the | ||
* source. Like ordinary `MGLAnnotation` objects, some kinds of `MGLFeature` | ||
* Typically,you do not create feature objects yourself but rather obtain them | ||
* using{ | ||
* | ||
* @link com.mapbox.mapboxsdk.maps.MapboxMap#getVisibleFeatures(PointF)} | ||
* and related methods.Each feature object associates a shape with an identifier and | ||
* attributes as specified by the source.Like ordinary AnnotationDefinition objects,some kinds of `Feature` | ||
* objects can also be added to a map view using `-[MGLMapView addAnnotations:]` | ||
* and related methods. | ||
* </p> | ||
*/ | ||
public class Feature { | ||
public interface Feature extends AnnotationDefinition { | ||
|
||
/** | ||
* An object that uniquely identifies the feature in its containing | ||
* A long that uniquely identifies the feature in its containing | ||
* <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>. | ||
* <p/> | ||
* <p> | ||
* The identifier corresponds to the | ||
* <a href="https://github.com/mapbox/vector-tile-spec/tree/master/2.1#42-features">feature identifier</a> | ||
* (`id`) in the tile source. If the source does not specify the feature’s | ||
* identifier, the value of this property is `nil`. If specified, the identifier | ||
* may be an integer, floating-point number, or string. These data types are | ||
* mapped to instances of the following Foundation classes: | ||
* <p/> | ||
* <table> | ||
* <thead> | ||
* <tr><th>In the tile source</th><th>This property</th></tr> | ||
* </thead> | ||
* <tbody> | ||
* <tr><td>Integer</td> <td><code>NSNumber</code> (use the <code>unsignedLongLongValue</code> or <code>longLongValue</code> property)</td></tr> | ||
* <tr><td>Floating-point number</td> <td><code>NSNumber</code> (use the <code>doubleValue</code> property)</td></tr> | ||
* <tr><td>String</td> <td><code>NSString</code></td></tr> | ||
* </tbody> | ||
* </table> | ||
* <p/> | ||
* <p> | ||
* For details about the identifiers used in most Mapbox-provided styles, consult | ||
* the | ||
* <a href="https://www.mapbox.com/vector-tiles/mapbox-streets/">Mapbox Streets</a> | ||
* layer reference. | ||
* | ||
* @return the identifier associated with this feature | ||
*/ | ||
private long id = -1; | ||
|
||
long getFeatureId(); | ||
|
||
/** | ||
* A HashMap of attributes for this feature specified by the | ||
* A Map of attributes for this feature specified by the | ||
* <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>. | ||
* <p/> | ||
* <p> | ||
* The keys and values of this dictionary are determined by the tile source. In | ||
* the tile source, each attribute name is a string, while each attribute value | ||
* may be a null value, Boolean value, integer, floating-point number, or string. | ||
* <p/> | ||
* <p/> | ||
* These data types are mapped to instances of the following Foundation classes: | ||
* For details about the attribute names and values found in Mapbox-provided | ||
* vector tile sources, consult the | ||
* <a href="https://www.mapbox.com/vector-tiles/mapbox-streets/">Mapbox Streets</a> | ||
* and | ||
* <a href="https://www.mapbox.com/vector-tiles/mapbox-terrain/">Mapbox Terrain</a> | ||
* layer references. | ||
*/ | ||
private HashMap<String, Object> attributes = new HashMap<>(); | ||
|
||
} | ||
Map<String, Object> getAttributes(); | ||
|
||
/** | ||
* Returns the feature attribute for the given attribute name. | ||
* <p> | ||
* See the `attributes` property’s documentation for details on keys and values | ||
* associated with this method. | ||
* | ||
* @param key the key associated to the attribute | ||
* @return the | ||
*/ | ||
Object getAttribute(String key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 1 addition & 48 deletions
49
...android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,5 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
public class MultiPoint extends PointCollectionShape { | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Multipoint is an abstract annotation for combining geographical locations. | ||
*/ | ||
public abstract class MultiPoint extends Annotation { | ||
|
||
private List<LatLng> points; | ||
private float alpha = 1.0f; | ||
|
||
protected MultiPoint() { | ||
super(); | ||
points = new ArrayList<>(); | ||
} | ||
|
||
/** | ||
* Returns a copy of the points. | ||
* | ||
* @return points - as a copy | ||
*/ | ||
public List<LatLng> getPoints() { | ||
return new ArrayList<>(points); | ||
} | ||
|
||
/** | ||
* Sets the points of this polyline. This method will take a copy | ||
* of the points, so further mutations to points will have no effect | ||
* on this polyline. | ||
* | ||
* @param points the points of the polyline | ||
*/ | ||
void setPoints(List<LatLng> points) { | ||
this.points = new ArrayList<>(points); | ||
} | ||
|
||
void addPoint(LatLng point) { | ||
points.add(point); | ||
} | ||
|
||
public float getAlpha() { | ||
return alpha; | ||
} | ||
|
||
void setAlpha(float alpha) { | ||
this.alpha = alpha; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...droid/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPolygon.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
import java.util.List; | ||
|
||
public class MultiPolygon extends Shape{ | ||
|
||
private List<Polygon> polygons; | ||
|
||
public MultiPolygon(List<Polygon> polygons) { | ||
this.polygons = polygons; | ||
} | ||
|
||
public List<Polygon> getPolygons() { | ||
return polygons; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...roid/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPolyline.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
import java.util.List; | ||
|
||
public class MultiPolyline extends Shape { | ||
|
||
private List<Polyline> polylines; | ||
|
||
public MultiPolyline(List<Polyline> polylines) { | ||
this.polylines = polylines; | ||
} | ||
|
||
public List<Polyline> getPolylines() { | ||
return polylines; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...pboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PointCollectionShape.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
import com.mapbox.mapboxsdk.geometry.LatLng; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public abstract class PointCollectionShape extends Shape { | ||
|
||
private List<LatLng> points; | ||
private float alpha = 1.0f; | ||
|
||
protected PointCollectionShape() { | ||
super(); | ||
points = new ArrayList<>(); | ||
} | ||
|
||
/** | ||
* Returns a copy of the points. | ||
* | ||
* @return points - as a copy | ||
*/ | ||
public List<LatLng> getPoints() { | ||
return new ArrayList<>(points); | ||
} | ||
|
||
/** | ||
* Sets the points of this polyline. This method will take a copy | ||
* of the points, so further mutations to points will have no effect | ||
* on this polyline. | ||
* | ||
* @param points the points of the polyline | ||
*/ | ||
void setPoints(List<LatLng> points) { | ||
this.points = new ArrayList<>(points); | ||
} | ||
|
||
void addPoint(LatLng point) { | ||
points.add(point); | ||
} | ||
|
||
public float getAlpha() { | ||
return alpha; | ||
} | ||
|
||
void setAlpha(float alpha) { | ||
this.alpha = alpha; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...id/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/ShapeCollection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.mapbox.mapboxsdk.annotations; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The `MGLShapeCollection` class represents a shape consisting of one or more | ||
* distinct but related shapes that are instances of `MGLShape`. The constituent | ||
* shapes can be a mixture of different kinds of shapes. | ||
* <p> | ||
* `ShapeCollection` objects cannot be added to a map view using | ||
* {@link com.mapbox.mapboxsdk.maps.MapboxMap#addAnnotations} and related methods. | ||
* </p> | ||
*/ | ||
public class ShapeCollection extends Shape { | ||
|
||
private List<Shape> shapes; | ||
|
||
public ShapeCollection(List<Shape> shapes) { | ||
this.shapes = shapes; | ||
} | ||
|
||
public List<Shape> getShapes() { | ||
return shapes; | ||
} | ||
} |
Oops, something went wrong.