Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] #352 - introduced annotation abstract class, removed multip…
Browse files Browse the repository at this point in the history
…oint from Polyline/Polygon inheritance.
  • Loading branch information
tobrun committed Jul 26, 2016
1 parent 05a0e7f commit ffcb8bc
Show file tree
Hide file tree
Showing 11 changed files with 179 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.mapbox.mapboxsdk.maps.MapboxMap;

/**
* Annotation is an overlay on top of a {@link MapView},
* AnnotationDefinition is an overlay on top of a {@link MapView},
* from which {@link Polygon}, {@link Polyline} and {@link Marker} are derived.
* <p>
* it manages attachment to a map and identification, but does not require
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
* Contains the Mapbox Maps Android Annotation API classes.
* Contains the Mapbox Maps Android AnnotationDefinition API classes.
*/
package com.mapbox.mapboxsdk.annotations;
Original file line number Diff line number Diff line change
@@ -1,51 +1,56 @@
package com.mapbox.mapboxsdk.annotationsrework;

import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapboxMap;

/**
* The Annotation protocol is used to provide annotation-related information
* to a map view. To use this protocol, you adopt it in any custom objects that
* store or represent annotation data. Each object then serves as the source of
* information about a single map annotation and provides critical information,
* such as the annotation’s location on the map. Annotation objects do not provide
* the visual representation of the annotation but typically coordinate (in
* conjunction with the map view’s delegate) the creation of an appropriate
* objects to handle the display.
* <p>
* An object that adopts this protocol must implement the `coordinate` property.
* </p>
* <p>
* The other methods of this protocol are optional.
* </p>
*/
public interface Annotation {

// /**
// * Returns the center point (specified as a map coordinate) of the annotation.
// *
// * @return center point for an annotation
// */
// LatLng getCoordinate();
//
// /**
// * Returns the title of an annotation.
// * <p>
// * Although this property is optional, if you support the selection of annotations
// * in your map view, you are expected to provide this property. This string is
// * displayed in the {@link com.mapbox.mapboxsdk.annotations.InfoWindow} for the associated annotation.
// * </p>
// *
// * @return title used for an annotation.
// */
// String getTitle();
//
// /**
// * Returns the snippet of an annotation.
// * <p>
// * This string is displayed in the {@link com.mapbox.mapboxsdk.annotations.InfoWindow} for the associated annotation.
// * <p/>
// *
// * @return snippet used for an annotation and shown in an InfoWindow
// */
// String getSnippet();
public class Annotation implements AnnotationDefinition {

private long id = -1;
private LatLng coordinate;
private String title;
private String snippet;
private MapboxMap mapboxMap;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public void setCoordinate(LatLng coordinate) {
this.coordinate = coordinate;
}

@Override
public LatLng getCoordinate() {
return coordinate;
}

public void setTitle(String title) {
this.title = title;
}

@Override
public String getTitle() {
return title;
}

@Override
public String getSnippet() {
return snippet;
}

public void setSnippet(String snippet) {
this.snippet = snippet;
}

public MapboxMap getMapboxMap() {
return mapboxMap;
}

public void setMapboxMap(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.mapbox.mapboxsdk.annotationsrework;

import com.mapbox.mapboxsdk.geometry.LatLng;

/**
* The AnnotationDefinition protocol is used to provide annotation-related information
* to a map view. To use this protocol, you adopt it in any custom objects that
* store or represent annotation data. Each object then serves as the source of
* information about a single map annotation and provides critical information,
* such as the annotation’s location on the map. AnnotationDefinition objects do not provide
* the visual representation of the annotation but typically coordinate (in
* conjunction with the map view’s delegate) the creation of an appropriate
* objects to handle the display.
* <p>
* An object that adopts this protocol must implement the `coordinate` property.
* </p>
* <p>
* The other methods of this protocol are optional.
* </p>
*/
public interface AnnotationDefinition {

/**
* Returns the center point (specified as a map coordinate) of the annotation.
*
* @return center point for an annotation
*/
LatLng getCoordinate();

/**
* Returns the title of an annotation.
* <p>
* Although this property is optional, if you support the selection of annotations
* in your map view, you are expected to provide this property. This string is
* displayed in the {@link com.mapbox.mapboxsdk.annotations.InfoWindow} for the associated annotation.
* </p>
*
* @return title used for an annotation.
*/
String getTitle();

/**
* Returns the snippet of an annotation.
* <p>
* This string is displayed in the {@link com.mapbox.mapboxsdk.annotations.InfoWindow} for the associated annotation.
* <p/>
*
* @return snippet used for an annotation and shown in an InfoWindow
*/
String getSnippet();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,58 +14,58 @@
* 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 Annotation objects, some kinds of `Feature`
* 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.
*/
public interface Feature extends Annotation {
public interface Feature extends AnnotationDefinition {

// /**
// * An long that uniquely identifies the feature in its containing
// * <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>.
// *
// * 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:
// *
// * 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
// */
// long getId();
//
// /**
// * A Map of attributes for this feature specified by the
// * <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>.
// *
// * 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.
// * 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.
// */
// Map<String,Object> getAttributes();
//
// /**
// *
// * Returns the feature attribute for the given attribute name.
// *
// * 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);
/**
* A long that uniquely identifies the feature in its containing
* <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>.
*
* 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:
*
* 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
*/
long getFeatureId();

/**
* A Map of attributes for this feature specified by the
* <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources">tile source</a>.
*
* 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.
* 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.
*/
Map<String,Object> getAttributes();

/**
*
* Returns the feature attribute for the given attribute name.
*
* 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);
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
package com.mapbox.mapboxsdk.annotationsrework;

import com.mapbox.mapboxsdk.geometry.LatLng;
public abstract class MultiPoint extends MultiShape {

import java.util.List;

/**
* The `MultiPoint` class is an abstract superclass used to define shapes
* composed of multiple points. You should not create instances of this class
* directly. Instead, you should create instances of the `Polyline` or
* `Polygon` classes. However, you can use the method and properties of this
* class to access information about the specific points associated with the line
* or polygon.
*/
public abstract class MultiPoint extends Shape {

private List<LatLng>coordinates;

public List<LatLng> getCoordinates() {
return coordinates;
}

public int getSize(){
return coordinates.size();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.mapbox.mapboxsdk.annotationsrework;

import com.mapbox.mapboxsdk.geometry.LatLng;

import java.util.List;

public class MultiShape extends Shape{

private List<LatLng> coordinates;

public List<LatLng> getCoordinates() {
return coordinates;
}

public int getSize(){
return coordinates.size();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import com.mapbox.mapboxsdk.geometry.LatLng;

public interface Overlay extends Annotation {
public interface Overlay extends AnnotationDefinition {

LatLng getCoordinate();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.mapbox.mapboxsdk.annotationsrework;

public class Polygon {
public class Polygon extends MultiShape{

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package com.mapbox.mapboxsdk.annotationsrework;

public class Polyline extends MultiPoint{
public class Polyline extends MultiShape{

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.mapbox.mapboxsdk.annotationsrework;

public abstract class Shape implements Annotation {
public abstract class Shape implements AnnotationDefinition {

}

0 comments on commit ffcb8bc

Please sign in to comment.