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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations