Search in sources :

Example 1 with Geometry

use of com.google.maps.android.data.Geometry in project android-maps-utils by googlemaps.

the class KmlMultiGeometryTest method createMultiGeometry.

public KmlMultiGeometry createMultiGeometry() {
    ArrayList<Geometry> kmlGeometries = new ArrayList<Geometry>();
    ArrayList<LatLng> coordinates = new ArrayList<LatLng>();
    coordinates.add(new LatLng(0, 0));
    coordinates.add(new LatLng(50, 50));
    coordinates.add(new LatLng(100, 100));
    Geometry kmlGeometry = new KmlLineString(coordinates);
    kmlGeometries.add(kmlGeometry);
    return new KmlMultiGeometry(kmlGeometries);
}
Also used : Geometry(com.google.maps.android.data.Geometry) ArrayList(java.util.ArrayList) LatLng(com.google.android.gms.maps.model.LatLng)

Example 2 with Geometry

use of com.google.maps.android.data.Geometry in project android-maps-utils by googlemaps.

the class GeoJsonMultiLineString method getLineStrings.

/**
     * Gets a list of GeoJsonLineStrings
     *
     * @return list of GeoJsonLineStrings
     */
public List<GeoJsonLineString> getLineStrings() {
    // Convert list of Geometry types to list of GeoJsonLineString types
    List<Geometry> geometryList = getGeometryObject();
    ArrayList<GeoJsonLineString> geoJsonLineStrings = new ArrayList<GeoJsonLineString>();
    for (Geometry geometry : geometryList) {
        GeoJsonLineString lineString = (GeoJsonLineString) geometry;
        geoJsonLineStrings.add(lineString);
    }
    return geoJsonLineStrings;
}
Also used : MultiGeometry(com.google.maps.android.data.MultiGeometry) Geometry(com.google.maps.android.data.Geometry) ArrayList(java.util.ArrayList)

Example 3 with Geometry

use of com.google.maps.android.data.Geometry in project android-maps-utils by googlemaps.

the class GeoJsonMultiPoint method getPoints.

/**
     * Gets a list of GeoJsonPoints
     *
     * @return list of GeoJsonPoints
     */
public List<GeoJsonPoint> getPoints() {
    //convert list of Geometry types to list of GeoJsonPoint types
    List<Geometry> geometryList = getGeometryObject();
    ArrayList<GeoJsonPoint> geoJsonPoints = new ArrayList<GeoJsonPoint>();
    for (Geometry geometry : geometryList) {
        GeoJsonPoint point = (GeoJsonPoint) geometry;
        geoJsonPoints.add(point);
    }
    return geoJsonPoints;
}
Also used : MultiGeometry(com.google.maps.android.data.MultiGeometry) Geometry(com.google.maps.android.data.Geometry) ArrayList(java.util.ArrayList)

Example 4 with Geometry

use of com.google.maps.android.data.Geometry in project android-maps-utils by googlemaps.

the class GeoJsonMultiPolygon method getPolygons.

/**
     * Gets a list of GeoJsonPolygons
     *
     * @return list of GeoJsonPolygons
     */
public List<GeoJsonPolygon> getPolygons() {
    //convert list of Geometry types to list of GeoJsonPolygon types
    List<Geometry> geometryList = getGeometryObject();
    ArrayList<GeoJsonPolygon> geoJsonPolygon = new ArrayList<GeoJsonPolygon>();
    for (Geometry geometry : geometryList) {
        GeoJsonPolygon polygon = (GeoJsonPolygon) geometry;
        geoJsonPolygon.add(polygon);
    }
    return geoJsonPolygon;
}
Also used : MultiGeometry(com.google.maps.android.data.MultiGeometry) Geometry(com.google.maps.android.data.Geometry) ArrayList(java.util.ArrayList)

Example 5 with Geometry

use of com.google.maps.android.data.Geometry in project android-maps-utils by googlemaps.

the class GeoJsonParser method parseGeometryToFeature.

/**
     * Converts a Geometry object into a GeoJsonFeature object. A geometry object has no ID,
     * properties or bounding box so it is set to null.
     *
     * @param geoJsonGeometry Geometry object to convert into a Feature object
     * @return new Feature object
     */
private static GeoJsonFeature parseGeometryToFeature(JSONObject geoJsonGeometry) {
    Geometry geometry = parseGeometry(geoJsonGeometry);
    if (geometry != null) {
        return new GeoJsonFeature(geometry, null, new HashMap<String, String>(), null);
    }
    Log.w(LOG_TAG, "Geometry could not be parsed");
    return null;
}
Also used : Geometry(com.google.maps.android.data.Geometry)

Aggregations

Geometry (com.google.maps.android.data.Geometry)11 ArrayList (java.util.ArrayList)6 MultiGeometry (com.google.maps.android.data.MultiGeometry)3 HashMap (java.util.HashMap)2 LatLng (com.google.android.gms.maps.model.LatLng)1 LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)1 Feature (com.google.maps.android.data.Feature)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 XmlPullParser (org.xmlpull.v1.XmlPullParser)1