Search in sources :

Example 1 with Polygon

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

the class GoogleMapShapeConverter method toPolygon.

/**
 * Convert a list of {@link LatLng} and list of hole list {@link LatLng} to
 * a {@link Polygon}
 *
 * @param latLngs lat lngs
 * @param holes   list of holes
 * @param hasZ    has z flag
 * @param hasM    has m flag
 * @return polygon
 */
public Polygon toPolygon(List<LatLng> latLngs, List<List<LatLng>> holes, boolean hasZ, boolean hasM) {
    Polygon polygon = new Polygon(hasZ, hasM);
    // Close the ring if needed and determine orientation
    closePolygonRing(latLngs);
    PolygonOrientation ringOrientation = getOrientation(latLngs);
    // Add the polygon points
    LineString polygonLineString = new LineString(hasZ, hasM);
    for (LatLng latLng : latLngs) {
        Point point = toPoint(latLng);
        // Add exterior in desired orientation order
        if (exteriorOrientation == null || exteriorOrientation == ringOrientation) {
            polygonLineString.addPoint(point);
        } else {
            polygonLineString.getPoints().add(0, point);
        }
    }
    polygon.addRing(polygonLineString);
    // Add the holes
    if (holes != null) {
        for (List<LatLng> hole : holes) {
            // Close the hole if needed and determine orientation
            closePolygonRing(hole);
            PolygonOrientation ringHoleOrientation = getOrientation(hole);
            LineString holeLineString = new LineString(hasZ, hasM);
            for (LatLng latLng : hole) {
                Point point = toPoint(latLng);
                // Add holes in desired orientation order
                if (holeOrientation == null || holeOrientation == ringHoleOrientation) {
                    holeLineString.addPoint(point);
                } else {
                    holeLineString.getPoints().add(0, point);
                }
            }
            polygon.addRing(holeLineString);
        }
    }
    return polygon;
}
Also used : LineString(mil.nga.sf.LineString) MultiLineString(mil.nga.sf.MultiLineString) LatLng(com.google.android.gms.maps.model.LatLng) MultiPoint(mil.nga.sf.MultiPoint) Point(mil.nga.sf.Point) MultiPolygon(mil.nga.sf.MultiPolygon) CurvePolygon(mil.nga.sf.CurvePolygon) Polygon(mil.nga.sf.Polygon)

Example 2 with Polygon

use of mil.nga.sf.Polygon 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 3 with Polygon

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

the class GoogleMapShapeConverter method toPolyhedralSurfaceWithOptions.

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

Example 4 with Polygon

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

the class GoogleMapShapeConverter method toPolygons.

/**
 * Convert a {@link PolyhedralSurface} to a {@link MultiPolygonOptions}
 *
 * @param polyhedralSurface polyhedral surface
 * @return multi polygon options
 */
public MultiPolygonOptions toPolygons(PolyhedralSurface polyhedralSurface) {
    MultiPolygonOptions polygons = new MultiPolygonOptions();
    for (Polygon polygon : polyhedralSurface.getPolygons()) {
        PolygonOptions polygonOptions = toPolygon(polygon);
        polygons.add(polygonOptions);
    }
    return polygons;
}
Also used : PolygonOptions(com.google.android.gms.maps.model.PolygonOptions) MultiPolygon(mil.nga.sf.MultiPolygon) CurvePolygon(mil.nga.sf.CurvePolygon) Polygon(mil.nga.sf.Polygon)

Example 5 with Polygon

use of mil.nga.sf.Polygon 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)

Aggregations

Polygon (mil.nga.sf.Polygon)13 MultiPolygon (mil.nga.sf.MultiPolygon)12 CurvePolygon (mil.nga.sf.CurvePolygon)9 PolygonOptions (com.google.android.gms.maps.model.PolygonOptions)6 PolyhedralSurface (mil.nga.sf.PolyhedralSurface)4 Point (mil.nga.sf.Point)3 LatLng (com.google.android.gms.maps.model.LatLng)2 GeoPackageException (mil.nga.geopackage.GeoPackageException)2 Geometry (mil.nga.sf.Geometry)2 LineString (mil.nga.sf.LineString)2 MultiLineString (mil.nga.sf.MultiLineString)2 MultiPoint (mil.nga.sf.MultiPoint)2 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