Search in sources :

Example 1 with MultiLineString

use of mil.nga.sf.MultiLineString in project geopackage-android-map by ngageoint.

the class GoogleMapShapeConverter method addToMap.

/**
 * Convert a {@link Geometry} to a Map shape and add it
 *
 * @param map      google map
 * @param geometry geometry
 * @return google map shape
 */
@SuppressWarnings("unchecked")
public GoogleMapShape addToMap(GoogleMap map, Geometry geometry) {
    GoogleMapShape shape = null;
    GeometryType geometryType = geometry.getGeometryType();
    switch(geometryType) {
        case POINT:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MARKER, addLatLngToMap(map, toLatLng((Point) geometry)));
            break;
        case LINESTRING:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE, addPolylineToMap(map, toPolyline((LineString) geometry)));
            break;
        case POLYGON:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toPolygon((Polygon) geometry)));
            break;
        case MULTIPOINT:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_MARKER, addLatLngsToMap(map, toLatLngs((MultiPoint) geometry)));
            break;
        case MULTILINESTRING:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE, addPolylinesToMap(map, toPolylines((MultiLineString) geometry)));
            break;
        case MULTIPOLYGON:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((MultiPolygon) geometry)));
            break;
        case CIRCULARSTRING:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYLINE, addPolylineToMap(map, toPolyline((CircularString) geometry)));
            break;
        case COMPOUNDCURVE:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYLINE, addPolylinesToMap(map, toPolylines((CompoundCurve) geometry)));
            break;
        case CURVEPOLYGON:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toCurvePolygon((CurvePolygon<Curve>) geometry)));
            break;
        case POLYHEDRALSURFACE:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((PolyhedralSurface) geometry)));
            break;
        case TIN:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.MULTI_POLYGON, addPolygonsToMap(map, toPolygons((TIN) geometry)));
            break;
        case TRIANGLE:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.POLYGON, addPolygonToMap(map, toPolygon((Triangle) geometry)));
            break;
        case GEOMETRYCOLLECTION:
            shape = new GoogleMapShape(geometryType, GoogleMapShapeType.COLLECTION, addToMap(map, (GeometryCollection<Geometry>) geometry));
            break;
        default:
            throw new GeoPackageException("Unsupported Geometry Type: " + geometryType.getName());
    }
    return shape;
}
Also used : MultiPoint(mil.nga.sf.MultiPoint) MultiLineString(mil.nga.sf.MultiLineString) CompoundCurve(mil.nga.sf.CompoundCurve) CircularString(mil.nga.sf.CircularString) Triangle(mil.nga.sf.Triangle) CurvePolygon(mil.nga.sf.CurvePolygon) MultiPoint(mil.nga.sf.MultiPoint) Point(mil.nga.sf.Point) PolyhedralSurface(mil.nga.sf.PolyhedralSurface) Geometry(mil.nga.sf.Geometry) GeometryType(mil.nga.sf.GeometryType) LineString(mil.nga.sf.LineString) MultiLineString(mil.nga.sf.MultiLineString) MultiPolygon(mil.nga.sf.MultiPolygon) TIN(mil.nga.sf.TIN) MultiPolygon(mil.nga.sf.MultiPolygon) CurvePolygon(mil.nga.sf.CurvePolygon) Polygon(mil.nga.sf.Polygon) GeoPackageException(mil.nga.geopackage.GeoPackageException)

Example 2 with MultiLineString

use of mil.nga.sf.MultiLineString in project geopackage-android-map by ngageoint.

the class GoogleMapShapeConverterUtils method convertMultiLineString.

/**
 * Test the MultiLineString conversion
 *
 * @param converter
 * @param multiLineString
 */
private static void convertMultiLineString(GoogleMapShapeConverter converter, MultiLineString multiLineString) {
    MultiPolylineOptions polylines = converter.toPolylines(multiLineString);
    TestCase.assertNotNull(polylines);
    TestCase.assertFalse(polylines.getPolylineOptions().isEmpty());
    List<LineString> lineStrings = multiLineString.getLineStrings();
    compareLineStringsAndPolylines(converter, lineStrings, polylines.getPolylineOptions());
    MultiLineString multiLineString2 = converter.toMultiLineStringFromOptions(polylines);
    compareLineStrings(lineStrings, multiLineString2.getLineStrings());
}
Also used : MultiLineString(mil.nga.sf.MultiLineString) LineString(mil.nga.sf.LineString) MultiLineString(mil.nga.sf.MultiLineString)

Example 3 with MultiLineString

use of mil.nga.sf.MultiLineString in project geopackage-android-map by ngageoint.

the class GoogleMapShapeConverter method toMultiLineStringFromList.

/**
 * Convert a list of LatLng lists to a {@link MultiLineString}
 *
 * @param polylineList polyline list
 * @param hasZ         has z flag
 * @param hasM         has m flag
 * @return multi line string
 */
public MultiLineString toMultiLineStringFromList(List<List<LatLng>> polylineList, boolean hasZ, boolean hasM) {
    MultiLineString multiLineString = new MultiLineString(hasZ, hasM);
    for (List<LatLng> polyline : polylineList) {
        LineString lineString = toLineString(polyline);
        multiLineString.addLineString(lineString);
    }
    return multiLineString;
}
Also used : MultiLineString(mil.nga.sf.MultiLineString) LineString(mil.nga.sf.LineString) MultiLineString(mil.nga.sf.MultiLineString) LatLng(com.google.android.gms.maps.model.LatLng)

Example 4 with MultiLineString

use of mil.nga.sf.MultiLineString in project geopackage-android-map by ngageoint.

the class GoogleMapShapeConverter method toPolylines.

/**
 * Convert a {@link MultiLineString} to a {@link MultiPolylineOptions}
 *
 * @param multiLineString multi line string
 * @return multi polyline options
 */
public MultiPolylineOptions toPolylines(MultiLineString multiLineString) {
    MultiPolylineOptions polylines = new MultiPolylineOptions();
    for (LineString lineString : multiLineString.getLineStrings()) {
        PolylineOptions polyline = toPolyline(lineString);
        polylines.add(polyline);
    }
    return polylines;
}
Also used : LineString(mil.nga.sf.LineString) MultiLineString(mil.nga.sf.MultiLineString) PolylineOptions(com.google.android.gms.maps.model.PolylineOptions)

Example 5 with MultiLineString

use of mil.nga.sf.MultiLineString in project geopackage-android-map by ngageoint.

the class GoogleMapShapeConverter method toMultiLineString.

/**
 * Convert a list of {@link Polyline} to a {@link MultiLineString}
 *
 * @param polylineList polyline list
 * @param hasZ         has z flag
 * @param hasM         has m flag
 * @return multi line string
 */
public MultiLineString toMultiLineString(List<Polyline> polylineList, boolean hasZ, boolean hasM) {
    MultiLineString multiLineString = new MultiLineString(hasZ, hasM);
    for (Polyline polyline : polylineList) {
        LineString lineString = toLineString(polyline);
        multiLineString.addLineString(lineString);
    }
    return multiLineString;
}
Also used : MultiLineString(mil.nga.sf.MultiLineString) LineString(mil.nga.sf.LineString) MultiLineString(mil.nga.sf.MultiLineString) Polyline(com.google.android.gms.maps.model.Polyline)

Aggregations

LineString (mil.nga.sf.LineString)6 MultiLineString (mil.nga.sf.MultiLineString)6 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)2 LatLng (com.google.android.gms.maps.model.LatLng)1 Polyline (com.google.android.gms.maps.model.Polyline)1 GeoPackageException (mil.nga.geopackage.GeoPackageException)1 CircularString (mil.nga.sf.CircularString)1 CompoundCurve (mil.nga.sf.CompoundCurve)1 CurvePolygon (mil.nga.sf.CurvePolygon)1 Geometry (mil.nga.sf.Geometry)1 GeometryType (mil.nga.sf.GeometryType)1 MultiPoint (mil.nga.sf.MultiPoint)1 MultiPolygon (mil.nga.sf.MultiPolygon)1 Point (mil.nga.sf.Point)1 Polygon (mil.nga.sf.Polygon)1 PolyhedralSurface (mil.nga.sf.PolyhedralSurface)1 TIN (mil.nga.sf.TIN)1 Triangle (mil.nga.sf.Triangle)1