prepare integration of anymaps in the project to maintain it and keep it

working with new version of osmdroid
master
Schoumi 4 years ago
parent 96d0d81ade
commit 34f7e505b8

@ -0,0 +1 @@
/build

@ -0,0 +1,36 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
ext {
name = 'AnyMaps - Base Library'
artifactId = 'anymaps.base'
description = 'Base library for AnyMaps libraries. Contains common interface'
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
}
}
}
dependencies {
implementation 'com.android.support:support-annotations:28.0.0'
testImplementation 'junit:junit:4.12'
}

@ -0,0 +1,7 @@
<!--
~ Copyright (c) 2015 Daimler AG / Moovel GmbH
~
~ All rights reserved
-->
<manifest package="com.car2go.maps"/>

@ -0,0 +1,165 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.view.View;
import com.car2go.maps.model.CameraPosition;
import com.car2go.maps.model.Circle;
import com.car2go.maps.model.CircleOptions;
import com.car2go.maps.model.LatLng;
import com.car2go.maps.model.Marker;
import com.car2go.maps.model.MarkerOptions;
import com.car2go.maps.model.Polygon;
import com.car2go.maps.model.PolygonOptions;
import com.car2go.maps.model.Polyline;
import com.car2go.maps.model.PolylineOptions;
/**
* Provider-independent map controller. Originally was designed to mimic Google Map API and being
* adapted to other providers. For detailed documentation on each method please refer Google Maps
* documentation.
*/
public interface AnyMap {
void moveCamera(CameraUpdate cameraUpdate);
void animateCamera(CameraUpdate cameraUpdate);
void animateCamera(CameraUpdate cameraUpdate, CancelableCallback callback);
void animateCamera(CameraUpdate cameraUpdate, int duration, CancelableCallback callback);
CameraPosition getCameraPosition();
Projection getProjection();
Marker addMarker(MarkerOptions options);
Circle addCircle(CircleOptions options);
Polygon addPolygon(PolygonOptions options);
Polyline addPolyline(PolylineOptions options);
UiSettings getUiSettings();
void setOnMapClickListener(OnMapClickListener listener);
void setOnMapLongClickListener(OnMapLongClickListener listener);
void setOnCameraChangeListener(OnCameraChangeListener listener);
void setOnMarkerClickListener(OnMarkerClickListener listener);
void setInfoWindowAdapter(InfoWindowAdapter adapter);
void setTrafficEnabled(boolean enabled);
void setMyLocationEnabled(boolean enabled);
void setMapType(Type type);
void setPadding(int left, int top, int right, int bottom);
void onUserLocationChanged(LatLng location, float accuracy);
enum Type {
NORMAL,
SATELLITE
}
/**
* Features of {@link AnyMap} which might be supported or not supported
* by each particular implementation.
*/
enum Feature {
/**
* Displaying layer with traffic jams on the map
*/
TRAFFIC_LAYER,
/**
* Supporting several {@link com.car2go.maps.AnyMap.Type}. If this capability is not present,
* only one of types is implemented (which one - is not specified).
*/
MAP_TYPES,
/**
* Supports being invisible at first and being revealed (or simply made visible) later on.
*/
REVEALABLE
}
interface OnMapClickListener {
OnMapClickListener NULL = new OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
// Do nothing
}
};
void onMapClick(LatLng latLng);
}
interface OnMapLongClickListener {
OnMapLongClickListener NULL = new OnMapLongClickListener() {
@Override
public void onMapLongClick(LatLng latLng) {
// Do nothing
}
};
void onMapLongClick(LatLng latLng);
}
interface OnCameraChangeListener {
void onCameraChange(CameraPosition cameraPosition);
}
interface OnMarkerClickListener {
OnMarkerClickListener NULL = new OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker) {
// Do nothing
return false;
}
};
boolean onMarkerClick(Marker marker);
}
interface CancelableCallback {
void onFinish();
void onCancel();
}
interface InfoWindowAdapter {
View getInfoWindow(Marker marker);
View getInfoContents(Marker marker);
}
}

@ -0,0 +1,27 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.graphics.Bitmap;
import android.support.annotation.DrawableRes;
import com.car2go.maps.model.BitmapDescriptor;
/**
* Factory for creating BitmapDescriptors.
*/
public interface BitmapDescriptorFactory {
/**
* @return new {@link BitmapDescriptor} from given {@link Bitmap}
*/
BitmapDescriptor fromBitmap(Bitmap bitmap);
/**
* @return new {@link BitmapDescriptor} from given resource
*/
BitmapDescriptor fromResource(@DrawableRes int resourceId);
}

@ -0,0 +1,13 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
/**
* Mimics Google CameraUpdate
*/
public interface CameraUpdate {
}

@ -0,0 +1,31 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import com.car2go.maps.model.LatLng;
import com.car2go.maps.model.LatLngBounds;
/**
* Creates {@link CameraUpdate} objects which can be used to update map camera
*/
public interface CameraUpdateFactory {
/**
* @return {@link CameraUpdate} which moves camera to given position with given zoom level.
*/
CameraUpdate newLatLngZoom(LatLng latLng, float zoomLevel);
/**
* @return {@link CameraUpdate} which moves camera so it displays given bounds with given padding.
*/
CameraUpdate newLatLngBounds(LatLngBounds bounds, int padding);
/**
* @return {@link CameraUpdate} which zooms camera to given zoom level.
*/
CameraUpdate zoomTo(float zoomLevel);
}

@ -0,0 +1,68 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.widget.FrameLayout;
/**
* View container for an {@link AnyMap}.
*/
public abstract class MapContainerView extends FrameLayout {
protected MapContainerView(Context context) {
super(context);
}
protected MapContainerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
/**
* Gets the wrapped {@link AnyMap} asynchronously.
*
* @param callback the callback to use when the map has been got
*/
public abstract void getMapAsync(OnMapReadyCallback callback);
/**
* Propagate the onCreate lifecycle call to the AnyMap.
*
* @param savedInstanceState the savedInstanceState
*/
public abstract void onCreate(Bundle savedInstanceState);
/**
* Propagate the onResume lifecycle call to the AnyMap.
*/
public abstract void onResume();
/**
* Propagate the onPause lifecycle call to the AnyMap.
*/
public abstract void onPause();
/**
* Propagate the onDestroy lifecycle call to the AnyMap.
*/
public abstract void onDestroy();
/**
* Propagate the onLowMemory lifecycle call to the AnyMap.
*/
public abstract void onLowMemory();
/**
* Propagate the onSaveInstanceState lifecycle call to the AnyMap.
*
* @param outState the outState
*/
public abstract void onSaveInstanceState(Bundle outState);
}

@ -0,0 +1,32 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import android.content.Context;
import java.util.Set;
/**
* A util class for initializing the map and retrieving its capabilities.
*/
public interface MapsConfiguration {
/**
* Initializes the maps.
*
* @param context the context
*/
void initialize(Context context);
/**
* Gets the supported features of the {@link AnyMap} implementation. If some features are not supported
* and you will try to call them - nothing will happen.
*
* @return capabilities of the {@link AnyMap} implementation.
*/
Set<AnyMap.Feature> getSupportedFeatures();
}

@ -0,0 +1,16 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
/**
* Mimics Google OnMapReadyCallback
*/
public interface OnMapReadyCallback {
void onMapReady(AnyMap anyMap);
}

@ -0,0 +1,18 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
import com.car2go.maps.model.VisibleRegion;
/**
* Mimics Google Projection
*/
public interface Projection {
VisibleRegion getVisibleRegion();
}

@ -0,0 +1,20 @@
/*
* Copyright (c) 2017 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps;
/**
* Mimics Google UiSettings
*/
public interface UiSettings {
void setAllGesturesEnabled(boolean enabled);
void setMyLocationButtonEnabled(boolean enabled);
void setMapToolbarEnabled(boolean enabled);
}

@ -0,0 +1,13 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Mimics Google BitmapDescriptor
*/
public interface BitmapDescriptor {
}

@ -0,0 +1,88 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Contains information about camera position on the map.
* Immutable.
*/
public class CameraPosition implements Parcelable {
/**
* Center of the camera viewport
*/
public final LatLng target;
/**
* Zoom level of the camera
*/
public final float zoom;
public CameraPosition(LatLng target, float zoom) {
this.target = target;
this.zoom = zoom;
}
protected CameraPosition(Parcel in) {
this.target = in.readParcelable(LatLng.class.getClassLoader());
this.zoom = in.readFloat();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CameraPosition)) {
return false;
}
CameraPosition that = (CameraPosition) o;
return Float.compare(that.zoom, zoom) == 0 && target.equals(that.target);
}
@Override
public int hashCode() {
int result = target.hashCode();
result = 31 * result + (zoom != +0.0f ? Float.floatToIntBits(zoom) : 0);
return result;
}
@Override
public String toString() {
return "CameraPosition{" +
"target=" + target +
", zoom=" + zoom +
'}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.target, flags);
dest.writeFloat(this.zoom);
}
public static final Creator<CameraPosition> CREATOR = new Creator<CameraPosition>() {
public CameraPosition createFromParcel(Parcel source) {
return new CameraPosition(source);
}
public CameraPosition[] newArray(int size) {
return new CameraPosition[size];
}
};
}

@ -0,0 +1,13 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Draws circle on the map
*/
public interface Circle extends DrawableComponent {
}

@ -0,0 +1,102 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.support.annotation.ColorInt;
/**
* Accumulates parameters which are required to create {@link Circle} component.
* Mutable.
*/
public class CircleOptions {
private LatLng center;
private double radius;
private int fillColor;
private int strokeColor;
private float strokeWidth;
/**
* @param point center of the circle
* @return same {@link CircleOptions}
*/
public CircleOptions center(LatLng point) {
center = point;
return this;
}
/**
* @param radius radius of the circle in meters
* @return same {@link CircleOptions}
*/
public CircleOptions radius(double radius) {
this.radius = radius;
return this;
}
/**
* @param color color used to fill the circle
* @return same {@link CircleOptions}
*/
public CircleOptions fillColor(@ColorInt int color) {
fillColor = color;
return this;
}
/**
* @param color color of the circle outline (stroke)
* @return same {@link CircleOptions}
*/
public CircleOptions strokeColor(@ColorInt int color) {
strokeColor = color;
return this;
}
/**
* @param width width of the stroke in pixels
* @return same {@link CircleOptions}
*/
public CircleOptions strokeWidth(float width) {
strokeWidth = width;
return this;
}
/**
* @see #center(LatLng)
*/
public LatLng getCenter() {
return center;
}
/**
* @see #radius(double)
*/
public double getRadius() {
return radius;
}
/**
* @see #fillColor(int)
*/
public int getFillColor() {
return fillColor;
}
/**
* @see #strokeColor(int)
*/
public int getStrokeColor() {
return strokeColor;
}
/**
* @see #strokeWidth(float)
*/
public float getStrokeWidth() {
return strokeWidth;
}
}

@ -0,0 +1,27 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Entity which can be drawn on map
*/
public interface DrawableComponent {
/**
* Changes visibility of the component
*
* @param visible {@code true} to make component visible.
* {@code false} to make component invisible.
*/
void setVisible(boolean visible);
/**
* Removes component from the map. If it's already removed, does nothing.
*/
void remove();
}

@ -0,0 +1,14 @@
package com.car2go.maps.model;
/**
* Defines handling of geofences
*/
public interface Geofence {
/**
* Checks if a location is inside the geofence or not
* @param latLng location to change
* @return {@code true} if location is inside the geofence
*/
public boolean contains(LatLng latLng);
}

@ -0,0 +1,96 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.location.Location;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Latitude/Longitude pair.
* Immutable.
*/
public class LatLng implements Parcelable {
/**
* Latitude on the map
*/
public final double latitude;
/**
* Longitude on the map
*/
public final double longitude;
public static LatLng fromLocation(Location location) {
return new LatLng(location.getLatitude(), location.getLongitude());
}
public LatLng(double latitude, double longitude) {
this.latitude = latitude;
this.longitude = longitude;
}
protected LatLng(Parcel in) {
this.latitude = in.readDouble();
this.longitude = in.readDouble();
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof LatLng)) {
return false;
}
LatLng latLng = (LatLng) o;
return Double.compare(latLng.latitude, latitude) == 0 && Double.compare(latLng.longitude, longitude) == 0;
}
@Override
public int hashCode() {
int result;
long temp;
temp = Double.doubleToLongBits(latitude);
result = (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(longitude);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public String toString() {
return "LatLng{" +
"latitude=" + latitude +
", longitude=" + longitude +
'}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeDouble(this.latitude);
dest.writeDouble(this.longitude);
}
public static final Creator<LatLng> CREATOR = new Creator<LatLng>() {
public LatLng createFromParcel(Parcel source) {
return new LatLng(source);
}
public LatLng[] newArray(int size) {
return new LatLng[size];
}
};
}

@ -0,0 +1,171 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.os.Parcel;
import android.os.Parcelable;
/**
* (Pseudo)Rectangular region on the map.
* Immutable.
*/
public class LatLngBounds implements Parcelable {
/**
* South-West point of the region.
*/
public final LatLng southwest;
/**
* North-East point of the region.
*/
public final LatLng northeast;
public LatLngBounds(LatLng southwest, LatLng northeast) {
this.southwest = southwest;
this.northeast = northeast;
}
protected LatLngBounds(Parcel in) {
this.southwest = in.readParcelable(LatLng.class.getClassLoader());
this.northeast = in.readParcelable(LatLng.class.getClassLoader());
}
/**
* @return {@link com.car2go.maps.model.LatLngBounds.Builder} for {@link LatLngBounds}
*/
public static Builder builder() {
return new Builder();
}
/**
* @return center of the region
*/
public LatLng getCenter() {
// Implementation copied from original obfuscated version of LatLngBounds
double var1 = (this.southwest.latitude + this.northeast.latitude) / 2.0D;
double var3 = this.northeast.longitude;
double var5 = this.southwest.longitude;
double var7;
if (var5 <= var3) {
var7 = (var3 + var5) / 2.0D;
} else {
var7 = (var3 + 360.0D + var5) / 2.0D;
}
return new LatLng(var1, var7);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof LatLngBounds)) return false;
LatLngBounds that = (LatLngBounds) o;
return southwest.equals(that.southwest) && northeast.equals(that.northeast);
}
@Override
public int hashCode() {
int result = southwest.hashCode();
result = 31 * result + northeast.hashCode();
return result;
}
@Override
public String toString() {
return "LatLngBounds{" +
"southwest=" + southwest +
", northeast=" + northeast +
'}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.southwest, 0);
dest.writeParcelable(this.northeast, 0);
}
public static final Parcelable.Creator<LatLngBounds> CREATOR = new Parcelable.Creator<LatLngBounds>() {
public LatLngBounds createFromParcel(Parcel source) {
return new LatLngBounds(source);
}
public LatLngBounds[] newArray(int size) {
return new LatLngBounds[size];
}
};
/**
* Builds new instances of {@link LatLngBounds}
*/
public static class Builder {
private double southWestLattitude = 1.0D / 0.0;
private double northEastLattitude = -1.0D / 0.0;
private double southWestLongitude = 0.0D / 0.0;
private double northEastLongitude = 0.0D / 0.0;
/**
* Ensures that given point will be within output bounds. Output bounds guaranteed to be
* as small as possible and enclose all given points.
*
* @return same {@link com.car2go.maps.model.LatLngBounds.Builder}
*/
public Builder include(LatLng point) {
southWestLattitude = Math.min(southWestLattitude, point.latitude);
northEastLattitude = Math.max(northEastLattitude, point.latitude);
if (Double.isNaN(southWestLongitude)) {
southWestLongitude = point.longitude;
northEastLongitude = point.longitude;
} else if (!withinBounds(point.longitude)) {
if (degreeDifference(southWestLongitude, point.longitude) < degreeDifference(point.longitude, northEastLongitude)) {
southWestLongitude = point.longitude;
} else {
northEastLongitude = point.longitude;
}
}
return this;
}
private double degreeDifference(double first, double second) {
return (first - second + 360.0D) % 360.0D;
}
private boolean withinBounds(double longitude) {
return this.southWestLongitude <= this.northEastLongitude
? this.southWestLongitude <= longitude && longitude <= this.northEastLongitude
: this.southWestLongitude <= longitude || longitude <= this.northEastLongitude;
}
/**
* @return new instance of {@link LatLngBounds}
* @throws IllegalStateException if less than 2 unique points were specified
*/
public LatLngBounds build() {
if (Double.isNaN(southWestLongitude)) {
throw new IllegalStateException("No included points");
}
return new LatLngBounds(
new LatLng(southWestLattitude, southWestLongitude),
new LatLng(northEastLattitude, northEastLongitude)
);
}
}
}

@ -0,0 +1,45 @@
/*
* Copyright (c) 2016 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.graphics.Bitmap;
/**
* Draws marker (with icon) on the map
*/
public interface Marker extends DrawableComponent {
/**
* Changes icon of the marker to given {@link Bitmap}
*/
void setIcon(BitmapDescriptor icon);
/**
* @return current position of the marker
*/
LatLng getPosition();
/**
* Shows information window associated with this marker, if any.
*/
void showInfoWindow();
/**
* Sets the rotation of the marker.
*
* @param rotation the rotation value
*/
void setRotation(float rotation);
/**
* Sets the Z index of the marker
*
* @param z z index of the marker
*/
void setZ(int z);
}

@ -0,0 +1,128 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Accumulates parameters which are required to create {@link Marker} component.
* Mutable.
*/
public class MarkerOptions {
private float alpha = 1f;
private LatLng position;
private boolean visible = true;
private float anchorU = 0f;
private float anchorV = 0f;
private BitmapDescriptor icon;
private int z = 0;
/**
* @param alpha alpha-level of the marker. In range [0..1]. Default value is 1.
* @return same {@link MarkerOptions}
*/
public MarkerOptions alpha(float alpha) {
this.alpha = alpha;
return this;
}
/**
* @param position position of the marker's anchor on the map
* @return same {@link MarkerOptions}
*/
public MarkerOptions position(LatLng position) {
this.position = position;
return this;
}
/**
* @param visible {@code true} to make marker visible by default. {@code false} to make marker
* invisible by default. Default value is {@code true}.
* @return same {@link MarkerOptions}
*/
public MarkerOptions visible(boolean visible) {
this.visible = visible;
return this;
}
/**
* Specifies anchor of the marker (which part of marker's icon is considered position of the
* marker on the map). (0, 0) denotes top left corner. (1, 1) denotes bottom right corner.
*
* @param u U coordinate of the anchor relatively to the icon. Default value is 0.
* @param v V coordinate of the anchor relatively to the icon. Default value is 0.
* @return same {@link MarkerOptions}
*/
public MarkerOptions anchor(float u, float v) {
anchorU = u;
anchorV = v;
return this;
}
/**
* @param icon icon of the marker
* @return same {@link MarkerOptions}
*/
public MarkerOptions icon(BitmapDescriptor icon) {
this.icon = icon;
return this;
}
public MarkerOptions z(int z) {
this.z = z;
return this;
}
/**
* @see #alpha(float)
*/
public float getAlpha() {
return alpha;
}
/**
* @see #position(LatLng)
*/
public LatLng getPosition() {
return position;
}
/**
* @see #visible(boolean)
*/
public boolean isVisible() {
return visible;
}
/**
* @see #anchor(float, float)
*/
public float getAnchorU() {
return anchorU;
}
/**
* @see #anchor(float, float)
*/
public float getAnchorV() {
return anchorV;
}
/**
* @see #icon(BitmapDescriptor)
*/
public BitmapDescriptor getIcon() {
return icon;
}
/**
* @see #z(int)
*/
public int getZ() {
return z;
}
}

@ -0,0 +1,29 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import java.util.List;
/**
* Draws polygon on the map. Might contain holes within the polygon.
*/
public interface Polygon extends DrawableComponent {
/**
* @param holes holes within the polygon area. If holes are outside of the polygon, behavior
* is undefined.
*/
void setHoles(List<List<LatLng>> holes);
/**
* @return a snapshot of the vertices of this polygon at this time.
* The list returned is a copy of the list of vertices and so changes to the polygon's vertices
* will not be reflected by this list, nor will changes to this list be reflected by the polygon.
*/
List<LatLng> getPoints();
}

@ -0,0 +1,119 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.support.annotation.ColorInt;
import java.util.ArrayList;
import java.util.List;
/**
* Accumulates parameters which are required to create {@link Polygon} component.
* Mutable.
*/
public class PolygonOptions {
private final List<LatLng> points = new ArrayList<>();
private int fillColor;
private float strokeWidth;
private int strokeColor;
private boolean outsider = false;
/**
* @param color color used to fill the polygon
* @return same {@link PolygonOptions}
*/
public PolygonOptions fillColor(@ColorInt int color) {
fillColor = color;
return this;
}
/**
* @param width width of the polygon outline in pixels.
* @return same {@link PolygonOptions}
*/
public PolygonOptions strokeWidth(float width) {
strokeWidth = width;
return this;
}
/**
* @param color color of the polygon outline
* @return same {@link PolygonOptions}
*/
public PolygonOptions strokeColor(@ColorInt int color) {
strokeColor = color;
return this;
}
/**
* @param outsider {@code true} to invert filling of this polygon. That is, filling everything
* with color except for the holes. {@code false} for normal drawing routine.
* @return same {@link PolygonOptions}
*/
public PolygonOptions outsider(boolean outsider) {
this.outsider = outsider;
return this;
}
/**
* Adds given point to the polygon
*
* @return same {@link PolygonOptions}
*/
public PolygonOptions add(LatLng point) {
points.add(point);
return this;
}
/**
* Adds all points from list to the polygon
*
* @return same {@link PolygonOptions}
*/
public PolygonOptions addAll(List<LatLng> points) {
this.points.addAll(points);
return this;
}
/**
* @see #fillColor(int)
*/
public int getFillColor() {
return fillColor;
}
/**
* @see #strokeWidth(float)
*/
public float getStrokeWidth() {
return strokeWidth;
}
/**
* @see #strokeColor(int)
*/
public int getStrokeColor() {
return strokeColor;
}
/**
* @see #outsider(boolean)
*/
public boolean isOutsider() {
return outsider;
}
/**
* @see #add(LatLng)
* @see #addAll(List)
*/
public List<LatLng> getPoints() {
return points;
}
}

@ -0,0 +1,13 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
/**
* Draws polyline on the map
*/
public interface Polyline extends DrawableComponent {
}

@ -0,0 +1,83 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.support.annotation.ColorInt;
import java.util.ArrayList;
import java.util.List;
/**
* Accumulates parameters which are required to create {@link Polyline} component.
* Mutable.
*/
public class PolylineOptions {
private int color;
private float width;
private final List<LatLng> points = new ArrayList<>();
/**
* @param color color of the line
* @return same {@link PolylineOptions}
*/
public PolylineOptions color(@ColorInt int color) {
this.color = color;
return this;
}
/**
* @param width width of the line in pixels
* @return same {@link PolylineOptions}
*/
public PolylineOptions width(float width) {
this.width = width;
return this;
}
/**
* Adds point to polyline
*
* @return same {@link PolylineOptions}
*/
public PolylineOptions add(LatLng point) {
points.add(point);
return this;
}
/**
* Adds all points from list to polyline
*
* @return same {@link PolylineOptions}
*/
public PolylineOptions addAll(List<LatLng> points) {
this.points.addAll(points);
return this;
}
/**
* @see #color(int)
*/
public int getColor() {
return color;
}
/**
* @see #width(float)
*/
public float getWidth() {
return width;
}
/**
* @see #add(LatLng)
* @see #addAll(List)
*/
public List<LatLng> getPoints() {
return points;
}
}

@ -0,0 +1,34 @@
package com.car2go.maps.model;
/**
* A rectangular geofence composed of two locations.
*
* The locations should be the North-West corner and the South-East corner of the rect.
*/
public class RectGeofence implements Geofence {
private final LatLng northWest;
private final LatLng southEast;
public RectGeofence(LatLng northWest, LatLng southEast) {
this.northWest = northWest;
this.southEast = southEast;
if ((northWest.latitude <= southEast.latitude) || (northWest.longitude >= southEast.longitude)) {
throw new IllegalArgumentException("North West point should be in the Top Left corner of the rect");
}
}
@Override
public boolean contains(LatLng latLng) {
double longitude = latLng.longitude;
double latitude = latLng.latitude;
double leftBorder = northWest.longitude;
double rightBorder = southEast.longitude;
double bottomBorder = southEast.latitude;
double topBorder = northWest.latitude;
return latitude >= bottomBorder && latitude <= topBorder && longitude >= leftBorder && longitude <= rightBorder;
}
}

@ -0,0 +1,77 @@
/*
* Copyright (c) 2015 Daimler AG / Moovel GmbH
*
* All rights reserved
*/
package com.car2go.maps.model;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Visible region on the map.
* Immutable.
*/
public class VisibleRegion implements Parcelable {
/**
* Currently visible bounds.
*/
public final LatLngBounds latLngBounds;
public VisibleRegion(LatLngBounds latLngBounds) {
this.latLngBounds = latLngBounds;
}
protected VisibleRegion(Parcel in) {
this.latLngBounds = in.readParcelable(LatLngBounds.class.getClassLoader());
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof VisibleRegion)) {
return false;
}
VisibleRegion that = (VisibleRegion) o;
return latLngBounds.equals(that.latLngBounds);
}
@Override
public int hashCode() {
return latLngBounds.hashCode();
}
@Override
public String toString() {
return "VisibleRegion{" +
"latLngBounds=" + latLngBounds +
'}';
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(this.latLngBounds, flags);
}
public static final Parcelable.Creator<VisibleRegion> CREATOR = new Parcelable.Creator<VisibleRegion>() {
public VisibleRegion createFromParcel(Parcel source) {
return new VisibleRegion(source);
}
public VisibleRegion[] newArray(int size) {
return new VisibleRegion[size];
}
};
}