Search in sources :

Example 1 with MultiPolygon

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

the class GoogleMapShapeConverter method toMultiPolygon.

/**
 * Convert a list of {@link com.google.android.gms.maps.model.Polygon} to a
 * {@link MultiPolygon}
 *
 * @param polygonList polygon list
 * @param hasZ        has z flag
 * @param hasM        has m flag
 * @return multi polygon
 */
public MultiPolygon toMultiPolygon(List<com.google.android.gms.maps.model.Polygon> polygonList, boolean hasZ, boolean hasM) {
    MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM);
    for (com.google.android.gms.maps.model.Polygon mapPolygon : polygonList) {
        Polygon polygon = toPolygon(mapPolygon);
        multiPolygon.addPolygon(polygon);
    }
    return multiPolygon;
}
Also used : MultiPolygon(mil.nga.sf.MultiPolygon) MultiPolygon(mil.nga.sf.MultiPolygon) CurvePolygon(mil.nga.sf.CurvePolygon) Polygon(mil.nga.sf.Polygon)

Example 2 with MultiPolygon

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

the class GoogleMapShapeConverter method addPolygonsToMap.

/**
 * Add a list of Polygons to the map
 *
 * @param map      google map
 * @param polygons multi polygon options
 * @return multi polygon
 */
public static mil.nga.geopackage.map.geom.MultiPolygon addPolygonsToMap(GoogleMap map, MultiPolygonOptions polygons) {
    mil.nga.geopackage.map.geom.MultiPolygon multiPolygon = new mil.nga.geopackage.map.geom.MultiPolygon();
    for (PolygonOptions polygonOption : polygons.getPolygonOptions()) {
        if (polygons.getOptions() != null) {
            polygonOption.fillColor(polygons.getOptions().getFillColor());
            polygonOption.strokeColor(polygons.getOptions().getStrokeColor());
            polygonOption.geodesic(polygons.getOptions().isGeodesic());
            polygonOption.visible(polygons.getOptions().isVisible());
            polygonOption.zIndex(polygons.getOptions().getZIndex());
            polygonOption.strokeWidth(polygons.getOptions().getStrokeWidth());
        }
        com.google.android.gms.maps.model.Polygon polygon = addPolygonToMap(map, polygonOption);
        multiPolygon.add(polygon);
    }
    return multiPolygon;
}
Also used : MultiPolygon(mil.nga.sf.MultiPolygon) PolygonOptions(com.google.android.gms.maps.model.PolygonOptions)

Example 3 with MultiPolygon

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

the class GoogleMapShapeConverter method toMultiPolygonFromOptions.

/**
 * Convert a list of {@link PolygonOptions} to a {@link MultiPolygon}
 *
 * @param multiPolygonOptions multi polygon options
 * @param hasZ                has z flag
 * @param hasM                has m flag
 * @return multi polygon
 */
public MultiPolygon toMultiPolygonFromOptions(MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM) {
    MultiPolygon multiPolygon = new MultiPolygon(hasZ, hasM);
    for (PolygonOptions mapPolygon : multiPolygonOptions.getPolygonOptions()) {
        Polygon polygon = toPolygon(mapPolygon);
        multiPolygon.addPolygon(polygon);
    }
    return multiPolygon;
}
Also used : MultiPolygon(mil.nga.sf.MultiPolygon) PolygonOptions(com.google.android.gms.maps.model.PolygonOptions) MultiPolygon(mil.nga.sf.MultiPolygon) CurvePolygon(mil.nga.sf.CurvePolygon) Polygon(mil.nga.sf.Polygon)

Example 4 with MultiPolygon

use of mil.nga.sf.MultiPolygon 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 5 with MultiPolygon

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

the class GoogleMapShapeConverterUtils method convertMultiPolygon.

/**
 * Test the MultiPolygon conversion
 *
 * @param converter
 * @param multiPolygon
 */
private static void convertMultiPolygon(GoogleMapShapeConverter converter, MultiPolygon multiPolygon) {
    MultiPolygonOptions mapPolygons = converter.toPolygons(multiPolygon);
    TestCase.assertNotNull(mapPolygons);
    TestCase.assertFalse(mapPolygons.getPolygonOptions().isEmpty());
    List<Polygon> polygons = multiPolygon.getPolygons();
    comparePolygonsAndMapPolygons(converter, polygons, mapPolygons.getPolygonOptions());
    MultiPolygon multiPolygon2 = converter.toMultiPolygonFromOptions(mapPolygons);
    comparePolygons(polygons, multiPolygon2.getPolygons());
}
Also used : MultiPolygon(mil.nga.sf.MultiPolygon) MultiPolygon(mil.nga.sf.MultiPolygon) Polygon(mil.nga.sf.Polygon)

Aggregations

MultiPolygon (mil.nga.sf.MultiPolygon)7 Polygon (mil.nga.sf.Polygon)6 CurvePolygon (mil.nga.sf.CurvePolygon)5 PolygonOptions (com.google.android.gms.maps.model.PolygonOptions)4 GeoPackageException (mil.nga.geopackage.GeoPackageException)2 Geometry (mil.nga.sf.Geometry)2 LatLng (com.google.android.gms.maps.model.LatLng)1 Marker (com.google.android.gms.maps.model.Marker)1 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)1 Polyline (com.google.android.gms.maps.model.Polyline)1 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CircularString (mil.nga.sf.CircularString)1 CompoundCurve (mil.nga.sf.CompoundCurve)1 GeometryCollection (mil.nga.sf.GeometryCollection)1 GeometryType (mil.nga.sf.GeometryType)1 LineString (mil.nga.sf.LineString)1 MultiLineString (mil.nga.sf.MultiLineString)1 MultiPoint (mil.nga.sf.MultiPoint)1